Skip to content

(id+)

static property names across member access and object property definitions (the b in a.b, a["b"], or { b: ... })

clojure
(id+ val)

Where:

  1. val: property name to match across access and definition forms *

Expanding into:

clojure
(:or (id \1)
     (str \1)
     (comp (str \1))
     (comp (:ref (str \1))))

Matching:

  1. dot access, e.g. a.b
  2. computed access with string literal, e.g. a["b"]
  3. object property keys, e.g. { "b": value }
  4. computed access via string-valued reference, e.g. a[key]

Behavior

  • Computed identifiers only match when the identifier is a known reference to the target string literal (e.g., a[key] with key = "b").

Examples

Find accesses to a deprecated response field across dot and computed forms.

clojure
(mem (id+ legacyId))

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

typescript
const key = "legacyId"
response.legacyId
response["legacyId"]
response[key]
response[dynamicKey]

Locate config objects defining timeoutMs, even when keys are computed.

clojure
(obj (prop (id+ timeoutMs)))

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

typescript
const key = "timeoutMs"
const config1 = { timeoutMs: 1000 }
const config2 = { "timeoutMs": 2000 }
const config3 = { [key]: 3000 }
const config4 = { [other]: 4000 }

Audit __proto__ accesses to prevent prototype pollution.

clojure
(mem (id+ __proto__))

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

typescript
const key = "__proto__"
obj.__proto__
obj["__proto__"]
obj[key]
obj[otherKey]

Arguments

val

• Identifier • String

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.