Skip to content

feat: add support for allowTrailingCommas option in JSON#96

Merged
amareshsm merged 3 commits into
eslint:mainfrom
lumirlumir:feat-add-support-for-allow-trailing-commas-option-in-json
May 6, 2025
Merged

feat: add support for allowTrailingCommas option in JSON#96
amareshsm merged 3 commits into
eslint:mainfrom
lumirlumir:feat-add-support-for-allow-trailing-commas-option-in-json

Conversation

@lumirlumir
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir commented May 5, 2025

Prerequisites checklist

What is the purpose of this pull request?

Hello,

I've added support for the allowTrailingCommas option in JSON.

Code Explorer can now parse trailing commas in JSONC mode!

Please let me know if there's anything I might have missed.

What changes did you make? (Give an overview)

Before

image

After

image

Related Issues

Is there anything you'd like reviewers to focus on?

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2025

Deploy Preview for eslint-code-explorer ready!

Name Link
🔨 Latest commit 82e639b
🔍 Latest deploy log https://app.netlify.com/sites/eslint-code-explorer/deploys/6819eab50c27820008ecd08d
😎 Deploy Preview https://deploy-preview-96--eslint-code-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lumirlumir lumirlumir marked this pull request as ready for review May 5, 2025 13:27
@nzakas
Copy link
Copy Markdown
Member

nzakas commented May 5, 2025

Thanks for taking a look at this. There's a bit of complexity here: allowTrailingCommas is only valid for the JSONC language. For JSON, trailing commas are never allowed, and for JSON5 trailing commas are always allowed. So, we can't just have a radio button for "allow trailing commas" because it doesn't work properly in JSON and JSON5 modes. Can we maybe disable the radio button in those cases?

@amareshsm
Copy link
Copy Markdown
Member

Thanks for taking a look at this. There's a bit of complexity here: allowTrailingCommas is only valid for the JSONC language. For JSON, trailing commas are never allowed, and for JSON5 trailing commas are always allowed. So, we can't just have a radio button for "allow trailing commas" because it doesn't work properly in JSON and JSON5 modes. Can we maybe disable the radio button in those cases?

Can we display the "Allow trailing commas" option only when the selected mode is JSONC?

Comment thread src/components/options.tsx
@lumirlumir
Copy link
Copy Markdown
Member Author

@nzakas @amareshsm

Thanks for the reviews!

I've added a new commit in 82e639b.

Now, allowTrailingCommas appears only when JSONC mode is enabled.

@lumirlumir lumirlumir requested a review from amareshsm May 6, 2025 10:59
Copy link
Copy Markdown
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would like @amareshsm to review before merging.

@nzakas nzakas added this to Triage May 6, 2025
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage May 6, 2025
@nzakas nzakas moved this from Needs Triage to Second Review Needed in Triage May 6, 2025
@amareshsm amareshsm added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 6, 2025
Copy link
Copy Markdown
Member

@amareshsm amareshsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks.

@amareshsm amareshsm merged commit 64c6298 into eslint:main May 6, 2025
8 checks passed
@github-project-automation github-project-automation Bot moved this from Second Review Needed to Complete in Triage May 6, 2025
@lumirlumir lumirlumir deleted the feat-add-support-for-allow-trailing-commas-option-in-json branch May 6, 2025 16:55
@lumirlumir lumirlumir mentioned this pull request Jul 30, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion feature

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants