fix: JS path uses espree so ESLint sees loc, range, tokens#199
Merged
NullVoxPopuli merged 2 commits intoember-tooling:mainfrom Apr 25, 2026
Merged
Conversation
The JS-fallback path (taken when @typescript-eslint/parser isn't installed) parsed with oxc-parser, but oxc emits only start/end offsets — no loc, no range array, no tokens. ESLint's SourceCode validate() requires loc and range on the Program node, so linting any .gjs file failed with `TypeError: AST is missing location information.` Rules that walk tokens (e.g. no-dupe-args) also blew up later. Switch the JS path to espree (already a transitive dep of eslint; now declared directly). Espree produces an ESLint-compatible AST with loc, range, tokens, and comments natively. The TS path is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add a regression test that forces the JS-fallback path via useBabel:true and asserts the contract ESLint requires: loc/range on Program and inner nodes, a non-empty token stream, and a no-throw end-to-end Linter pass with no-dupe-args (which dereferences token loc and crashed under oxc). 3 of 5 assertions fail under the previous oxc-based code, including the exact "AST is missing location information" parsing error. Expand the JS-path comment to flag oxc as the preferred parser once upstream lands native loc support, with a link to the tracking issue (oxc-project/oxc#10307). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
NullVoxPopuli
approved these changes
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JS-fallback path (taken when
@typescript-eslint/parserisn't installed) parsed withoxc-parser, but oxc emits onlystart/endbyte offsets — noloc, norangearray, notokens. ESLint'sSourceCode.validate()requireslocandrangeon the Program node, so linting any.gjsfile in a project without@typescript-eslint/parserfails with:Even if
loc/rangeare backfilled, the next rule that walks tokens (e.g.no-dupe-args) blows up becauseprogram.tokensis empty — oxc doesn't emit tokens at all.Switch the JS path to
espree(already a transitive dep ofeslint; now declared directly). Espree produces an ESLint-compatible AST withloc,range,tokens, andcommentsnatively. The TS path is untouched.Repro
A consumer hit this in bobisjan/website#2263 — a project that doesn't use TypeScript and doesn't install
@typescript-eslint/parser. Lint now passes against that branch with this fix applied.Test plan
pnpm test— all 47 existing tests passpnpm lintsucceeds after patching the installed parser with this change (also requires theember-estree ^0.6.2bump that already landed in v0.11.0)🤖 Generated with Claude Code