(var)
variable declarations (var/let/const), including destructuring patterns
(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.
(var _ _ (is var))Selects in lines { 1 } but not in { 2, 3 }:
var legacy = 1
let modern = 2
const stable = 3Locate environment destructuring for migration to a config loader.
(var (obj) (mem env process) (is const))Selects in lines { 1 } but not in { 2, 3 }:
const { API_URL } = process.env
const { API_URL } = config
let { API_URL } = process.envIdentify array initializations to migrate to typed arrays.
(var _ (arr))Selects in lines { 1, 2 } but not in { 3 }:
const items = []
let ids = [1, 2]
const count = 1Arguments
name
• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
• (:kind) • (:ref) • (:text) • (arr) • (attr) • (bool) • (call) • (child) • (comp) • (export) • (fun) • (id) • (id+) • (import) • (jsx) • (mem) • (null) • (num) • (obj) • (of) • (prop) • (regex) • (regex+) • (str) • (str*) • (str+) • (tpl) • (tpl*) • (var) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)
init
• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
• (arr) • (bin) • (bool) • (call) • (comp) • (fun) • (id) • (id+) • (jsx) • (mem) • (null) • (num) • (obj) • (of) • (regex) • (regex+) • (str) • (str*) • (str+) • (tpl) • (tpl*) • (:ref) • (:into) • (:and) • (:or) • (:not) • (:text) • (:kind) • (:replace) • (:capture)
kind
Does NOT support: Refinement — Replacement