Skip to content

fix: JS path uses espree so ESLint sees loc, range, tokens#199

Merged
NullVoxPopuli merged 2 commits intoember-tooling:mainfrom
NullVoxPopuli-ai-agent:fix/js-path-loc-range
Apr 25, 2026
Merged

fix: JS path uses espree so ESLint sees loc, range, tokens#199
NullVoxPopuli merged 2 commits intoember-tooling:mainfrom
NullVoxPopuli-ai-agent:fix/js-path-loc-range

Conversation

@NullVoxPopuli-ai-agent
Copy link
Copy Markdown

Summary

The JS-fallback path (taken when @typescript-eslint/parser isn't installed) parsed with oxc-parser, but oxc emits only start/end byte 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 in a project without @typescript-eslint/parser fails with:

TypeError: AST is missing location information.
    at validate (eslint/lib/languages/js/source-code/source-code.js:63:9)

Even if loc/range are backfilled, the next rule that walks tokens (e.g. no-dupe-args) blows up because program.tokens is empty — oxc doesn't emit tokens at all.

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 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 pass
  • Verified end-to-end against bobisjan/website PR 2263: pnpm lint succeeds after patching the installed parser with this change (also requires the ember-estree ^0.6.2 bump that already landed in v0.11.0)

🤖 Generated with Claude Code

NullVoxPopuli and others added 2 commits April 25, 2026 10:56
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 NullVoxPopuli added the bug Something isn't working label Apr 25, 2026
@NullVoxPopuli NullVoxPopuli merged commit b78a558 into ember-tooling:main Apr 25, 2026
35 checks passed
@NullVoxPopuli NullVoxPopuli deleted the fix/js-path-loc-range branch April 25, 2026 15:59
@github-actions github-actions Bot mentioned this pull request Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants