fix: preserve parsing error locations in Bun - #281
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe JSON parser now returns line and column values for parsing failures. Tests verify locations for invalid comments and trailing commas in JSON and JSONC. ChangesJSON error locations
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to JSON parsing errors now retain line and column locations in Bun, matching Node.js behavior. The focused implementation and coverage introduce no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
How did these properties become non-enumerable? I couldn't reproduce this locally. |
|
I was able to reproduce the missing |
Prerequisites checklist
AI acknowledgment
What is the purpose of this pull request?
Environment
Which language are you using?
json
What did you do?
Install
eslint@10.7.0and@eslint/json@2.1.0, then save this asrepro.mjs:Run
bun repro.mjsand compare withnode repro.mjs.What did you expect to happen?
The parsing error includes
line: 2andcolumn: 1, as it does in Node.js.What actually happened?
Bun omits both properties:
[ { "ruleId": null, "fatal": true, "severity": 2, "message": "Parsing error: Unexpected character '/' found." } ]Link to Minimal Reproducible Example
The standalone reproduction is included above.
Related reproduction in CI: https://github.com/eslint/json/actions/runs/33971265538/job/101320084273?pr=281
What changes did you make? (Give an overview)
In Bun, the parser error's
lineandcolumnare non-enumerable, so...exinJSONLanguage.parse()drops them. Explicitly copyingline: ex.lineandcolumn: ex.columnpreserves the location.Related Issues
Ref: #259
Is there anything you'd like reviewers to focus on?
I found it while working on #259.
Summary by CodeRabbit
Bug Fixes
Tests