test: replace and activate json linting #834
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
The current linting setup does not catch any
json
errors in the examples.eslint-plugin-json-format is installed, however it is not configured in .eslintrc to be active in terms of the plugin itself, nor the filename extension
*.json
.Steps to reproduce
Ubuntu
22.04.4
LTS, Node.js20.12.2
LTSExecute
git clone https://github.com/cypress-io/cypress-example-kitchensink cd cypress-example-kitchensink npm ci npm run lint
and confirm that no errors are reported.
Now temporarily delete the end-of-line commas in cypress/fixtures/example.json and save the file.
Execute again
and note that no errors are reported even though the JSON file above is incorrect.
JSON Plugins
eslint-plugin-json-format was last published 5 years ago and it seems unlikely that it will be maintained in the future, or that it will offer ESLint
9.x
compatibility with flat config file support.eslint-plugin-jsonc is a maintained plugin which provides linting for JSON, JSONC and JSON5 files. It is compatible with ESLint >= 6. It provides legacy and flat config file support.
Options
Correcting the configuration for eslint-plugin-json-format would only be a short-term solution. eslint-plugin-jsonc is used instead.
Change
plugin:jsonc/recommended-with-json
configuration toextends
of .eslintrc