Skip to content

Commit ad5782e

Browse files
Create README.md
1 parent 593258b commit ad5782e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# cypress-eslint
2+
Cypress plugin that will run linting via ESLint on your spec files and display linting errors in your terminal.
3+
4+
This uses the `file:preprocessor` event which means it will lint files as they are loaded by Cypress. If you are running your full suite of tests, all the spec files will be linted, but if you are only running tests on a specific test suite then only the files that it loads will be linted.
5+
6+
This will use the `.eslintrc` file in your project root combined with the `.eslintrc` file in your Cypress directory (if you have one). This means you can easily set custom rules just for your Cypress spec files.
7+
8+
## Install
9+
10+
```bash
11+
# npm
12+
npm i cypress-eslint --save-dev
13+
14+
# yarn
15+
yarn add cypress-eslint --dev
16+
```
17+
18+
## Usage
19+
20+
If you are not currently using another plugin on the `file:preprocessor` event
21+
```javascript
22+
// cypress/plugins/index.js
23+
const cypressEslint = require('cypress-eslint');
24+
25+
module.exports = (on) => {
26+
on('file:preprocessor', cypressEslint());
27+
};
28+
29+
```
30+
31+
If you are using another plugin on the `file:preprocessor` event, pass this in as a parameter to cypress eslint
32+
```javascript
33+
// cypress/plugins/index.js
34+
35+
const cypressEslint = require('cypress-eslint');
36+
const babelEsX = require('cypress-babel-esx');
37+
38+
module.exports = (on) => {
39+
on('file:preprocessor', cypressEslint(babelEsX()));
40+
};
41+
```

0 commit comments

Comments
 (0)