-
Notifications
You must be signed in to change notification settings - Fork 16
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
Linting JSON #45
Comments
Prettier supports formatting of JSON files, not linting. Not sure about ESLint. Have you tried to run in on JSON files? We recommend JSON because it’s easier to manipulate via code, using Mrm for example. |
@sapegin What I get when I run
I guess Prettier will do its formatting if run directly, but not if run via |
Yeah, looks like they don’t support JSON. |
That's right - apparently ESLint does not support JSON. Prettier can format it, but not via the Things seem to be in a bit of a state of flux at the moment - I suppose they always are - what with ESLint and Stylelint both having I'm using Prettier via ESLint, having it over-ride ESLint's rules. The only thing I have tweaked with it is to have single quotes, to fit in more with Airbnb config, which I am using. |
You should disable all style rules in ESLint otherwise you’ll have funny conflicts between ESLint and Prettier ;-) ESLint supports JSX too, but Prettier supports CSS and GraphQL. I’m not sure that formatting of JSON is very useful ;-) |
Yes, I do that using this, otherwise ESLint objects to Prettier's formatting, which seems to be dominant. I think it's possible for JSON to get into a bit of a mess - I like anything that can auto-format things perfectly! :) Might be especially good for teams, with beginners etc. |
I think it depends on what kind of JSON files you have. Files like |
Is there anything we should improve in the book about this? |
Maybe we could show how to validate JSON (precommit). It’s easy to break if you are in a rush and perform manual changes. |
I wondered if you guys have any recommendation of the best way currently to lint (and fix) JSON files - maybe this is worth mentioning. ESLint doesn't seem to do it, although there do seem to be plugins. I think Prettier supports it, but not via the eslint-plugin-prettier (which is how I'm using it).
Also re. JSON it might be worth recommending a config file format, as there are several to choose from, and saying why the JSON extension is the best choice, if it is.
The text was updated successfully, but these errors were encountered: