Skip to content

(call) - JavaScript

function calls

clojure
(call receiver? args?)

Where:

  1. receiver: the function being called (the x in x()) *
  2. args: arguments supplied to the call *

Matching:

  1. regular calls, e.g. x()
  2. dynamic imports, e.g. import()

Examples

Remove leftover debug logging before a release by finding calls to console.log.

clojure
(call (mem log console))

Selects in lines { 1 } but not in { 2, 3 }:

typescript
console.log("debug", payload)
console.info("debug", payload)
logger.log("debug", payload)

Find setTimeout calls that execute string code instead of a callback.

clojure
(call setTimeout (arg 1 (str)))

Selects in lines { 1 } but not in { 2, 3 }:

typescript
setTimeout("window.location.reload()", 1000)
setTimeout(() => window.location.reload(), 1000)
setTimeout(() => {}, 0)

Harden API requests by finding POST fetch calls that omit headers.

clojure
(call fetch
  (:and
    (arg 2 (obj (prop method (str "POST"))))
    (:not (arg 2 (obj (prop headers))))))

Selects in lines { 1 } but not in { 2, 3, 4 }:

typescript
fetch("/api/users", { method: "POST" })
fetch("/api/users", { method: "POST", headers: { "Content-Type": "application/json" } })
fetch("/api/users", { method: "GET" })
fetch("/api/users")

Arguments

receiver

args

Copyright © 2022-present Semantic Works, Inc.