Skip to content

fix: don't allow trailing commas in JSON mode - #604

Merged
lumirlumir merged 1 commit into
mainfrom
fix/json-mode-trailing-commas
Nov 4, 2026
Merged

lumirlumir merged 1 commit into
mainfrom
fix/json-mode-trailing-commas

Conversation

@Pixel998

@Pixel998 Pixel998 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR fixes a bug where JSON mode accepts trailing commas if Allow Trailing Commas was turned on in JSONC mode.

Steps to reproduce

  1. Select JSON in the language options and turn on Allow Trailing Commas.
  2. Change Mode to json.
  3. Replace the editor contents with {"foo":"bar",}.
  4. Notice the AST is shown instead of a parse error.

What changes did you make? (Give an overview)

Passed allowTrailingCommas to the parser only in JSONC mode.

Related Issues

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

Summary by CodeRabbit

  • Bug Fixes
    • JSON mode now correctly reports a parse error for trailing commas, while JSONC continues to allow them.

@eslint-github-bot eslint-github-bot Bot added the bug Something isn't working label Oct 27, 2026
@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for eslint-code-explorer ready!

Name Link
🔨 Latest commit f20eebb
🔍 Latest deploy log https://app.netlify.com/projects/eslint-code-explorer/deploys/6ae11c2ef7e59bcff3e9d498
😎 Deploy Preview https://deploy-preview-604--eslint-code-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 794f44cc-89c2-4727-abd7-1771c98e30e1
Commits

Reviewing files that changed from the base of the PR and between 3d0c7d9 and f20eebb.

Files selected for processing: 2
  • e2e-tests/code-editing-and-ast-interaction.test.ts
  • src/hooks/use-ast.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

JSON parsing now allows trailing commas only in JSONC mode. An end-to-end test checks that JSON mode reports a parse error for input with a trailing comma.

Changes: JSON trailing-comma mode handling

Layer / File(s) Summary
Mode-specific parsing and regression test
src/hooks/use-ast.ts, e2e-tests/code-editing-and-ast-interaction.test.ts
JSON parsing passes allowTrailingCommas only in JSONC mode. The test checks that JSON mode displays the expected parse error for a trailing comma.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: lumirlumir

Merge Risk: Minimal · up to f20ee

No actionable merge-blocking risk was identified; the change addresses the reported JSON parsing behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing trailing commas in JSON mode.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eslintbot eslintbot added this to Triage Oct 27, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Oct 27, 2026
@Pixel998 Pixel998 moved this from Needs Triage to Implementing in Triage Oct 27, 2026
@Pixel998
Pixel998 marked this pull request as ready for review October 27, 2026 22:01
@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Oct 30, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Triaging in Triage Oct 30, 2026
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Oct 30, 2026

@lumirlumir lumirlumir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

Leaving it open for two more days, just in case someone else wants to review.

@lumirlumir lumirlumir moved this from Triaging to Merge Candidates in Triage Oct 30, 2026
@lumirlumir
lumirlumir merged commit b9f44e4 into main Nov 4, 2026
13 checks passed
@lumirlumir lumirlumir moved this from Merge Candidates to Complete in Triage Nov 8, 2026
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 bug Something isn't working

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants