microsoft / microsoft/node-jsonc-parser
Perhaps trailing commas should be enabled by default
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 759
- Forks
- 66
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 7
Description
For any use of JSONC that is user-facing in VS code, for example in a .jsonc file saved by the user, or even the user settings JSONC file, trailing commas don't trigger an error:
-
User config example:
-
Standalone
.jsoncfile example: -
Only in
.jsonis it shown as an error:
Visual Studio Code's own uses of JSONC seem for uses where trailing commas are desired, like the user config. An intended strength of the JSONC format seems to be easy user editing and writing. For "strict" uses of automatically generated files where the syntax is meant to stay super correct, there's still JSON as there always was as the more common choice.
Based on this, I would suggest that perhaps trailing commas should be enabled in the parser by default, so that e.g. parsing the VS Code config in JSONC works without manual changes.
I'm sure some will disagree, but the option to turn it off would remain in any case.
(Please note I'm not suggesting to remove the warning in the VS Code UI about trailing commas as discussed here, since I realize other JSONC parsers might still treat this differently.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the parser option default in src/impl/parser.ts at the linked location, then inspect how trailing commas are covered elsewhere in the repository. Determine whether enabling them by default preserves the opt-out behavior and update the relevant parser tests to confirm both defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100