Add JSONC support for structured module globals#304
Conversation
- recognize `.jsonc` alongside JSON5 in module import handling - add coverage for JSONC structured globals detection and import
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds .jsonc support: a JSONC test fixture and Jest tests, a new Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/language/modules/jsonc-import.js (1)
10-24: Consider adding one negative-path JSONC import test.Current coverage is happy-path only; adding a malformed JSONC import assertion would better guard parser error handling regressions.
As per coding guidelines: JavaScript tests should cover happy paths, edge cases, and error cases.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/language/modules/jsonc-import.js` around lines 10 - 24, Add a negative-path test to the existing "JSONC import" suite that asserts a malformed JSONC file import/parsing throws; create a new test (e.g., test("fails on malformed JSONC", ...)) that attempts to import or parse a deliberately-bad JSONC fixture (or use dynamic import/require inside a function) and expect it to throw (using expect(() => importOrParseBadJsonc()).toThrow() or await expect(importBadJsonc()).rejects.toThrow()); reference the suite name "JSONC import" and the new test name so it's added alongside the existing tests for top-level scalars and arrays/nested objects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/language/modules/jsonc-import.js`:
- Around line 10-24: Add a negative-path test to the existing "JSONC import"
suite that asserts a malformed JSONC file import/parsing throws; create a new
test (e.g., test("fails on malformed JSONC", ...)) that attempts to import or
parse a deliberately-bad JSONC fixture (or use dynamic import/require inside a
function) and expect it to throw (using expect(() =>
importOrParseBadJsonc()).toThrow() or await
expect(importBadJsonc()).rejects.toThrow()); reference the suite name "JSONC
import" and the new test name so it's added alongside the existing tests for
top-level scalars and arrays/nested objects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 620fb803-7ab7-413a-8678-f5902c350325
📒 Files selected for processing (4)
tests/language/modules/helpers/config.jsonctests/language/modules/jsonc-import.jsunits/Goccia.FileExtensions.pasunits/Goccia.ScriptLoader.Globals.Test.pas
Benchmark Results364 benchmarks Interpreted: 🟢 191 improved · 🔴 44 regressed · 129 unchanged · avg +2.2% arraybuffer.js — Interp: 🟢 14 · avg +5.8% · Bytecode: 🟢 14 · avg +32.3%
arrays.js — Interp: 🟢 7, 🔴 3, 9 unch. · avg +1.2% · Bytecode: 🟢 19 · avg +40.0%
async-await.js — Interp: 🟢 1, 🔴 2, 3 unch. · avg -0.0% · Bytecode: 🟢 6 · avg +39.8%
base64.js — Interp: 🟢 9, 1 unch. · avg +5.3% · Bytecode: 🟢 10 · avg +38.3%
classes.js — Interp: 🟢 20, 🔴 1, 10 unch. · avg +1.3% · Bytecode: 🟢 23, 8 unch. · avg +19.8%
closures.js — Interp: 🟢 2, 🔴 5, 4 unch. · avg -0.9% · Bytecode: 🟢 11 · avg +23.5%
collections.js — Interp: 🟢 4, 🔴 4, 4 unch. · avg +0.3% · Bytecode: 🟢 11, 1 unch. · avg +40.5%
destructuring.js — Interp: 🟢 14, 🔴 2, 6 unch. · avg +2.7% · Bytecode: 🟢 22 · avg +22.0%
fibonacci.js — Interp: 🟢 1, 🔴 4, 3 unch. · avg -1.4% · Bytecode: 🟢 8 · avg +31.4%
float16array.js — Interp: 🟢 16, 🔴 6, 10 unch. · avg +3.8% · Bytecode: 🟢 29, 🔴 3 · avg +27.0%
for-of.js — Interp: 🔴 2, 5 unch. · avg -0.9% · Bytecode: 🟢 7 · avg +27.9%
helpers/bench-module.js — Interp: 0 · Bytecode: 0
iterators.js — Interp: 🟢 17, 🔴 2, 23 unch. · avg +1.7% · Bytecode: 🟢 40, 2 unch. · avg +16.8%
json.js — Interp: 🟢 5, 🔴 2, 13 unch. · avg +0.5% · Bytecode: 🟢 20 · avg +34.4%
jsx.jsx — Interp: 🟢 17, 4 unch. · avg +3.8% · Bytecode: 🟢 21 · avg +23.8%
modules.js — Interp: 🟢 7, 🔴 1, 1 unch. · avg +3.0% · Bytecode: 🟢 9 · avg +37.4%
numbers.js — Interp: 🟢 6, 5 unch. · avg +2.4% · Bytecode: 🟢 10, 🔴 1 · avg +28.6%
objects.js — Interp: 🟢 6, 1 unch. · avg +6.0% · Bytecode: 🟢 7 · avg +27.6%
promises.js — Interp: 🟢 12 · avg +5.2% · Bytecode: 🟢 12 · avg +27.6%
regexp.js — Interp: 🟢 4, 🔴 1, 6 unch. · avg +1.0% · Bytecode: 🟢 11 · avg +30.5%
strings.js — Interp: 🟢 8, 🔴 1, 10 unch. · avg +2.0% · Bytecode: 🟢 19 · avg +33.5%
typed-arrays.js — Interp: 🟢 15, 🔴 1, 6 unch. · avg +3.3% · Bytecode: 🟢 22 · avg +31.6%
uint8array-encoding.js — Interp: 🟢 6, 🔴 7, 5 unch. · avg +0.6% · Bytecode: 🟢 18 · avg +31.1%
Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
Suite Timing
Measured on ubuntu-latest x64. |
- Verify malformed JSONC throws SyntaxError - Extend JSONC import test coverage
Summary
.jsoncfiles as structured module globals alongside.json5.Testing
Goccia.ScriptLoader.Globals.Test.pasforconfig.jsoncdetection.tests/language/modules/jsonc-import.jsusingtests/language/modules/helpers/config.jsonc.