fix(linter/plugins): decode escapes in identifier tokens#19838
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes token serialization in the linter and JS plugin layer to use ESLint-compatible (Espree) token values for identifiers containing Unicode escape sequences (e.g., \u0061). Previously, the linter() constructor had decode_identifier_escapes: false (matching TS-ESLint's behavior), while ESLint's Espree parser decodes escapes in the token value. The fix replaces ESTreeTokenOptions::linter() with the existing ESTreeTokenOptions::test262() (Espree-compatible) and removes the now-redundant linter() constructor.
Changes:
- Remove
ESTreeTokenOptions::linter()and replace both call sites withESTreeTokenOptions::test262() - Add
escaped_idents.jsfixture file covering Unicode-escaped identifiers and legacy keyword identifiers - Update the test snapshot to reflect correctly decoded token values
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_estree_tokens/src/lib.rs |
Removes the linter() constructor (which differed from test262() only in decode_identifier_escapes: false) |
crates/oxc_linter/src/lib.rs |
Switches token options from removed linter() to test262() |
apps/oxlint/src/js_plugins/parse.rs |
Switches token options from removed linter() to test262() |
apps/oxlint/test/fixtures/tokens/files/escaped_idents.js |
New test fixture with Unicode escape sequences in identifiers and legacy keywords |
apps/oxlint/test/fixtures/tokens/output.snap.md |
Updated snapshot showing decoded identifier values matching ESLint behavior |
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
a175b31 to
425151b
Compare
0f666d6 to
7a9d19e
Compare
Fix tokens in linter. Use options for tokens which match ESLint's tokens style, instead of matching TS-ESLint's.
7a9d19e to
04c4284
Compare
425151b to
7682e5a
Compare

Fix tokens in linter. Use options for tokens which match ESLint's tokens style, instead of matching TS-ESLint's.