Skip to content

fix(json-formatter): accept JSON5 in Validate when JSON5 is on - #441

Merged
anurag629 merged 1 commit into
codercops:developfrom
prakashNalla:fix/json5-validate
Oct 31, 2026
Merged

anurag629 merged 1 commit into
codercops:developfrom
prakashNalla:fix/json5-validate

Conversation

@prakashNalla

Copy link
Copy Markdown
Collaborator

What and why

With "Accept JSON5" ticked, Validate still checked the raw input as strict JSON, so {b: 2, a: 1,} showed "Invalid JSON" while Format, Minify and Sort keys accepted it. Validate now goes through the same strictInput() step as Minify and Sort keys.

Closes #440

How I tested this

  • Added a case to the JSON5 block in JsonFormatterClient.test.tsx that turns on JSON5, validates {b: 2, a: 1,} and expects "Valid JSON ✓" with no "Invalid JSON". It fails without the change.
  • npm run lint: 0 errors, the same 11 warnings as on develop.
  • npm run test: 67 files, 2524 tests pass.
  • npm run build: passes.

AI assistance

Claude helped me w/ understand the issue

Type of change

  • Bug fix

Checklist

  • I was assigned the linked issue
  • npm run lint && npm run test && npm run build passes locally
  • Logic changes live in lib/ and have a test in lib/__tests__/
  • For a bug fix: the new test fails without my change
  • No analytics, trackers, or calls that send user data off-device
  • Works in both light and dark themes (if UI changed)
  • Inputs have labels and it works with the keyboard alone (if UI changed)
  • New tool: registry entry, page.tsx, client component, opengraph-image.tsx, and the bug report dropdown are all done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Formatter: Validate rejects JSON5 even with Accept JSON5 on

2 participants