Common ESLint rules shared by Cypress packages.
Note that this is meant for packages that are part of Cypress and not necessarily for a project that uses Cypress.
npm install --save-dev eslint-plugin-cypress-dev
Extend one or more of the presets depending on the nature of the package:
// .eslintrc.json
{
"extends": [
"plugin:cypress-dev/general",
"plugin:cypress-dev/tests",
"plugin:cypress-dev/react"
]
}
You can relax rules
// .eslintrc.json
{
"extends": [
"plugin:cypress-dev/general"
],
"rules": {
"comma-dangle": "off",
"no-debugger": "warn"
},
"env": {
"node": true
}
}
The majority of the rules concerning JavaScript. Should usually be used at the root of the package.
Test-specific configuration and rules. Should be used within the test
directory.
React and JSX-specific configuration and rules.
Due to a limitation in how ESLint plugins work, your package needs to install the ESLint plugins that this plugin depends on:
If using the tests
preset:
npm install --save-dev eslint-plugin-mocha
If using the react
preset:
npm install --save-dev babel-eslint eslint-plugin-react
Use plugin ESLint by Dirk Baeumer to lint and auto fix JS files using ESLint. This repository includes example .vscode/settings.json file.
Install package linter-eslint (and its dependencies) to enable linting. Go into the settings for this package and enable "Fix on save" option to auto-fix white space issues and other things.
Install ESLint-Formatter, then set the following settings:
{
"format_on_save": true,
"debug": true
}
This project is licensed under the terms of the MIT license.