Skip to content
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(code-editor): lint and fold json #1818

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

anderssonjohan
Copy link
Contributor

@anderssonjohan anderssonjohan commented Aug 29, 2022

Adds linting and folding support for JSON! 🎉

(needs tooltip CSS from @Kiarokh or @LucyChyzhova !)

Screen Shot 2022-08-29 at 17 00 19

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

@github-actions
Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-1818/

@anderssonjohan anderssonjohan force-pushed the code-editor-lint-and-fold-json branch from 6d0a9e5 to 2a29195 Compare August 29, 2022 15:15
mjlime
mjlime previously approved these changes Aug 29, 2022
@dorisenthecat
Copy link

Since we have gotten questions from users that didn't know that double vs single quotes matters in json I tried this

image

This linter is technically correct and shows a parser error, for none developers it highlights the line before the error and says something incomprehensible? It took me several minutes just to understand --------------------^ wasn't a line break but an arrow 😄 But getting this in a screenshot from a user asking for help is much much better than screenshot of a wall of json.

Compared to vscode

image

dorisenthecat
dorisenthecat previously approved these changes Aug 31, 2022
@adrianschmidt
Copy link
Contributor

Prettier is able to autofix single-quotes in json:

Screenshot from prettier.io/playground showing that Prettier replaces single-quotes in json with double-quotes.

Link to Prettier playground for json

Is there a Prettier-plugin for the code editor? Or could auto-fix be enabled for the linter that's added here?

@anderssonjohan
Copy link
Contributor Author

Prettier is able to autofix single-quotes in json:

Screenshot from prettier.io/playground showing that Prettier replaces single-quotes in json with double-quotes.

Link to Prettier playground for json

Is there a Prettier-plugin for the code editor? Or could auto-fix be enabled for the linter that's added here?

There's a formatting addon to codemirror but I haven't yet found a codemirror + prettier example but it should be doable: https://discuss.codemirror.net/t/formatting-the-code/2442/5

The question is how much all this will add to the lime-elements dist size; Will it be ok or too much?

mjlime
mjlime previously approved these changes Aug 31, 2022
@Kiarokh Kiarokh dismissed stale reviews from mjlime and dorisenthecat via f8795f0 August 31, 2022 11:45
@anderssonjohan anderssonjohan force-pushed the code-editor-lint-and-fold-json branch from 587f1a1 to f18d8c7 Compare September 1, 2022 09:56
@anderssonjohan anderssonjohan merged commit 8e3c790 into next Sep 1, 2022
@anderssonjohan anderssonjohan deleted the code-editor-lint-and-fold-json branch September 1, 2022 10:06
@dorisenthecat
Copy link

This so cool @anderssonjohan 🥳

@lime-ci
Copy link
Contributor

lime-ci commented Sep 1, 2022

🎉 This PR is included in version 36.0.0-next.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

@anderssonjohan
Copy link
Contributor Author

@adrianschmidt @dorisenthecat The error caught by JSON.parse is actually better than the one from json-lint :/
See the message below the code editor in this screenshot:

Screen Shot 2022-09-02 at 12 53 04

@adrianschmidt
Copy link
Contributor

I don't want any error message, I want it to be fixed automatically 😄

But yeah, in lieu of that, use the one that gives better error messages, of course! 👍

@lime-ci
Copy link
Contributor

lime-ci commented Oct 4, 2022

🎉 This PR is included in version 36.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants