cypress-io / cypress-example-kitchensink

This is an example app used to showcase Cypress.io testing.
https://example.cypress.io/
MIT License
1.22k stars 2.2k forks source link

test: replace and activate json linting #834

Closed MikeMcC399 closed 5 months ago

MikeMcC399 commented 5 months ago

Issue

Steps to reproduce

Ubuntu 22.04.4 LTS, Node.js 20.12.2 LTS

Execute

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

npm run lint

and note that no errors are reported even though the JSON file above is incorrect.

JSON Plugins

Options

Correcting the configuration for eslint-plugin-json-format would only be a short-term solution. eslint-plugin-jsonc is used instead.

Change

  1. Uninstall eslint-plugin-json-format
  2. Install eslint-plugin-jsonc
  3. Add plugin:jsonc/recommended-with-json configuration to extends of .eslintrc
cypress-app-bot commented 5 months ago
MikeMcC399 commented 5 months ago

Verification

Ubuntu 22.04.4 LTS, Node.js 20.12.2 LTS

Execute

git clone --branch replace/json-linting https://github.com/MikeMcC399/cypress-example-kitchensink --depth 1
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 the local copy of cypress/fixtures/example.json and save the file.

Execute again

npm run lint

and note that a JSON error is correctly detected in an error message similar to the following:

$ npm run lint

> cypress-example-kitchensink@0.0.0-development lint
> eslint --fix cypress app/assets/js/scripts.js

.../cypress-example-kitchensink/cypress/fixtures/example.json
  3:3  error  Parsing error: Unexpected token '"email"'

✖ 1 problem (1 error, 0 warnings)
MikeMcC399 commented 5 months ago
cypress-app-bot commented 5 months ago

:tada: This PR is included in version 2.0.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket: