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

--sort-keys doesn't exits with exit code 0 even if keys were not sorted before #99

Open
felixfbecker opened this issue Oct 13, 2017 · 2 comments

Comments

@felixfbecker
Copy link

This means jsonlint can't be used to verify that object keys are sorted.

@prantlf
Copy link

prantlf commented May 19, 2019

The options --sort-keys is an additional option for parsing and validation. Only parsing and validation affect the exit code. If the JSON data were actually sorted, or if the sorting had no effect on already sorted content , has no effect on the exit code.

If you want to verify, or rather ensure, that object keys are sorted, you can use both --sort-keys and --in-place' options together. If the file does not change after executing jsonlint`, it was already sorted. Rewriting the file should not be a problem; git detects file changes automatically, for example.

@kopach
Copy link

kopach commented Jan 8, 2020

I do agree with @felixfbecker. What I would expect from a linter tool is to throw an error (exit with 0) in case conditions doesn't met. So, I could use this in automated way (e.g. on CI) to force some codding standards. linters like eslint or tslint do provide --fix option in case file overriding is needed. Any chance to have jslint exit with 0 in case keys aren't sorted?

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

No branches or pull requests

3 participants