-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add allowTrailingCommas option for JSONC #42
Conversation
I think it's fine to throw an error when this option is used in a mode where it isn't applicable, regardless of the value. |
@nzakas There's a check failing because of a formatting problem reported by Prettier. Can you take a look? |
Hmm, I'm not seeing anything locally. 🤔 |
Rebasing worked. 👍 |
Sorry, I left a suggestion to fix the prettier error last week, by apparently forgot to click the submit review button. |
Co-authored-by: Milos Djermanovic <[email protected]>
Co-authored-by: Milos Djermanovic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request?
Add support for trailing commas to the JSONC language.
What changes did you make? (Give an overview)
This pull request introduces support for allowing trailing commas in JSONC files and includes several updates to the codebase and documentation to reflect this new feature. The most important changes include adding a new option to enable trailing commas, updating the
JSONLanguage
class to validate and handle this option, and adding tests to ensure the feature works as expected.New Feature: Allow Trailing Commas in JSONC
allowTrailingCommas
language option.Code Updates
src/languages/json-language.js
:JSONLanguageOptions
to include theallowTrailingCommas
property.validateLanguageOptions
method to check for theallowTrailingCommas
option and ensure it is only used in JSONC mode.parse
method to accept and handle theallowTrailingCommas
option.Dependency Update
@humanwhocodes/momoa
dependency to version^3.3.0
.Tests
tests/languages/json-language.test.js
:validateLanguageOptions
method to ensure it correctly handles theallowTrailingCommas
option.parse
method to verify that trailing commas are correctly parsed or rejected based on theallowTrailingCommas
option.Related Issues
fixes #41
Is there anything you'd like reviewers to focus on?
Right now,
validateLanguageOptions()
throws an error when it findsallowTrailingCommas
in JSON mode (where it cannot be enabled) and JSON5 mode (where it cannot be disabled). Would it be better to check the value ofallowTrailingCommas
before deciding to throw an error? So in JSON mode it would only throw ifallowTrailingCommas
istrue
and in JSON5 mode it would only throw an error ifallowTrailingCommas
isfalse
?