(var) - JavaScript
variable declarations (var/let/const), including destructuring patterns
clojure
(var name? init? kind?)Where:
- name: binding name or pattern *
- init: initializer expression *
- kind: the declaration keyword (var, let, or const) *
Matching:
- var declarations, e.g.
var x = 1 - let declarations, e.g.
let x = 1 - const declarations, e.g.
const x = 1 - object destructuring, e.g.
const { a } = obj - array destructuring, e.g.
const [a] = list
Behavior
- When a declaration has multiple declarators, the statement matches if any declarator satisfies the constraints.
Examples
Find lingering var declarations before enforcing no-var.
clojure
(var _ _ (is var))Selects in lines { 1 } but not in { 2, 3 }:
typescript
var legacy = 1
let modern = 2
const stable = 3Locate environment destructuring for migration to a config loader.
clojure
(var (obj) (mem env process) (is const))Selects in lines { 1 } but not in { 2, 3 }:
typescript
const { API_URL } = process.env
const { API_URL } = config
let { API_URL } = process.envIdentify array initializations to migrate to typed arrays.
clojure
(var _ (arr))Selects in lines { 1, 2 } but not in { 3 }:
typescript
const items = []
let ids = [1, 2]
const count = 1Arguments
name
init
kind
Does NOT support: Refinement — Replacement