Open felixfbecker opened 6 years ago
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.
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?
This means jsonlint can't be used to verify that object keys are sorted.