Commit 0440b0f
feat(linter/eslint): implement
This PR implements the `eslint/id-match` rule, which enforces a
configured naming regex for identifiers
ESLint ref: https://eslint.org/docs/latest/rules/id-match
Issue: #479
### Behavior Differences from ESLint
This implementation is intentionally stricter in two cases:
- Computed destructuring keys are checked, for example `const {
[bad_name]: x } = obj` and `({ [bad_name]: x } = obj)`, because the
computed key is a normal reference expression, not a binding introduced
by destructuring
- With `properties` enabled, ordinary top-level dynamic import option
keys are checked, for example `import("x", { bad_option: true })`.
Import attributes inside `with { ... }` are still ignored
### TypeScript
TypeScript syntax is supported on a best-effort basis for identifiers
that flow through the same visited AST node kinds and transparent
wrappers such as `as`, `satisfies`, non-null assertions, and
instantiation expressions
This is not a replacement for `@typescript-eslint/naming-convention` or
future tsgolint naming-convention work:
oxc-project/tsgolint#186
### Regex Compatibility
The pattern is compiled with Rust regex syntax. JavaScript-specific
regex features such as lookaround and backreferences are not supported.
Unicode escapes should use Rust syntax, for example `\u{XXXX}`
### Algorithmic Complexity
The generated rule runner limits the hot path to identifier-like AST
nodes:
- `BindingIdentifier`
- `IdentifierReference`
- `IdentifierName`
- `PrivateIdentifier`
- `LabelIdentifier`
Each visited identifier first runs the regex check and returns
immediately when the name matches
For non-default configurations, the hot path is linear in the total
length of checked identifier names, with additional ancestor/context
checks only for failed regex matches
Space complexity is `O(1)` beyond the compiled regex and options. The
hot path does not allocate unless a diagnostic is emitted
The default pattern `^.+$` matches every non-empty identifier name, so
`should_run` skips rule work entirely for the default configuration
### AI Disclosure
Claude Opus 4.7 & Codex GPT 5.5
---------
Co-authored-by: Cameron Clark <cameron.clark@hey.com>id-match rule (#22379)1 parent 0f26de6 commit 0440b0f
10 files changed
Lines changed: 2083 additions & 1 deletion
File tree
- apps/oxlint/src-js/package
- crates/oxc_linter/src
- generated
- rules/eslint
- snapshots
- utils
- npm/oxlint
- tasks/website_linter/src/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
0 commit comments