Add JSON syntax linting to CodeMirror v6 editor#3825
Add JSON syntax linting to CodeMirror v6 editor#3825khanniie merged 3 commits intoprocessing:develop-codemirror-v6from
Conversation
|
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. |
|
@Geethegreat Thanks for adding JSON linting — this definitely improves parity with JS/CSS Since we’re already on CodeMirror v6, we could potentially leverage @codemirror/lang-json’s syntax tree and surface diagnostics from error nodes instead. This would give more accurate ranges and a smoother typing experience, closer to what users expect from modern editors. @raclim WDYT? |
|
@Jatin24062005 Thanks for the feedback that’s a very fair point. Leveraging Curious to hear your thoughts, @raclim ready to adapt based on what the maintainers prefer here. |
|
hi all! I'll switch to the branch and check it out myself when I have a moment, but regarding the potential flickering issue, is it possible to see a screen recording of what it looks like for you? If flickering were an issue, I believe that we'd be seeing that in the other existing linters as well (js, css, html) so I suspect there's some sort of key debouncing built into codemirror to circumvent this issue anyways : ) I like the existing parse suggestion and don't think we need to over-engineer this, especially considering this codemirror thread where the creator suggests something quite similar to this solution here: I do think you could look into using the function mentioned there just to avoid duplicate code! Really appreciate the contribution and am excited about the momentum for v6! Thanks for all the great discussion : ) |
|
Hi @Geethegreat, just wanted to check in on if you were still interested in working on this PR? I think it's almost there, so let me know if you want to make the final changes or if it would be okay for me to add some changes on top of your branch to merge it in. |
Thanks for the pointers @khanniie! Using the helper from |
|
Sure no problem, I'd love to polish it and submit the pr. |
|
Hi @khanniie! Updated to use jsonParseLinter from @codemirror/lang-json as suggested this eliminates the duplicate JSON.parse logic and uses the upstream getErrorPosition helper. Ready for review! 🙂 |
|
LGTM! Thanks for the work here! Just tested and it works great : ) |
|
are you able to resolve the conflicts so that we can merge it in? @Geethegreat apologies for the extra work! |
|
Hi @khanniie! I've resolved the merge conflicts, its ready to be merged. |
|
@Geethegreat yay! Thank you so much! Merged! |
Fixes #3817
Changes:
Adds JSON syntax linting support to the CodeMirror v6 editor. The new linter parses JSON content and surfaces syntax errors at the correct character position.
I have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #123