Skip to content

(id)

identifiers

clojure
(id val?)

Where:

  1. val: identifier name to match *

Matching:

  1. variable and function names, e.g. foo
  2. property names in member expressions, e.g. obj.prop
  3. private property identifiers (with # prefix), e.g. obj.#private
  4. shorthand properties, e.g. { name }
  5. super keyword, e.g. super
  6. import keyword in dynamic imports, e.g. import
  7. identifiers in spread elements, e.g. ...spread

Behavior

  • Matches identifiers in various contexts: variables, properties, parameters, JSX attributes, and more.
  • For private properties like obj.#field, include the # prefix in the query: (id #field).
  • Supports JSX namespace names like svg:href using colon notation: (id svg:href).
  • The special identifier <> matches JSX fragments.

Examples

Find usages of deprecated variable names before refactoring.

clojure
(id oldConfigName)

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

typescript
const value = oldConfigName.get()
const other = newConfigName.get()
function process(oldConfigName) { }

Locate React useState hooks to migrate to a new state management library.

clojure
(call (id /use[A-Z]\w+/))

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

typescript
const [count, setCount] = useState(0)
const data = useMemo(() => {}, [])
const value = customHook()

Find components using private fields before refactoring to WeakMaps.

clojure
(mem (id /#\w+/))

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

typescript
class Widget {
  #counter = 0
  get() { return this.#counter }
  set(val) { this.#counter = val }
}

Arguments

val

• Identifier • String • Pattern

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.