Skip to content

Commit 9493ca2

Browse files
Merge pull request #23 from cypress-io/issue-22-add-globals-to-recommended
Add globals to recommended config
2 parents b1c83da + 7a89fc9 commit 9493ca2

File tree

6 files changed

+8247
-5370
lines changed

6 files changed

+8247
-5370
lines changed

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2+
"plugins": [
3+
"@cypress/dev"
4+
],
25
"extends": [
3-
"plugin:cypress-dev/general"
6+
"plugin:@cypress/dev/general"
47
]
58
}

README.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
An ESLint plugin for your [Cypress](https://cypress.io) tests.
44

5-
Specifies globals for Cypress `cy`, `Cypress`, browser and mocha globals.
5+
Note: If you installed ESLint globally then you must also install `eslint-plugin-cypress` globally.
66

77
## Installation
88

@@ -15,32 +15,51 @@ npm install eslint-plugin-cypress --save-dev
1515
Add an `.eslintrc.json` file to your `cypress` directory with the following:
1616

1717
```json
18-
// my-project/cypress/.eslintrc.json
19-
2018
{
2119
"plugins": [
2220
"cypress"
23-
],
21+
]
22+
}
23+
```
24+
25+
You can add rules:
26+
27+
```json
28+
{
29+
"rules": {
30+
"no-assigning-return-values": "error",
31+
"no-unnecessary-waiting": "error",
32+
"assertion-before-screenshot": "warn",
33+
}
34+
}
35+
```
36+
37+
You can whitelist globals provided by Cypress:
38+
39+
```json
40+
{
2441
"env": {
2542
"cypress/globals": true
2643
}
2744
}
2845
```
2946

30-
## Rules
47+
## Recommended configuration
3148

32-
These rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices). Use them by adding the following to your eslint config:
49+
Use the recommended configuration and you can forego configuring _plugins_, _rules_, and _env_ individually. See below for which rules are included.
3350

3451
```json
35-
// my-project/cypress/.eslintrc.json
36-
3752
{
3853
"extends": [
3954
"plugin:cypress/recommended"
4055
]
4156
}
4257
```
4358

59+
## Rules
60+
61+
These rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices).
62+
4463
Rules with a check mark (✅) are enabled by default while using the `plugin:cypress/recommended` config.
4564

4665
**NOTE**: These rules currently require eslint 5.0 or greater. If you would like support added for eslint 4.x, please 👍 [this issue](https://github.com/cypress-io/eslint-plugin-cypress/issues/14).

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
chai: false,
2020
}),
2121
parserOptions: {
22-
ecmaVersion: 2017,
22+
ecmaVersion: 2019,
2323
sourceType: 'module',
2424
},
2525
},

lib/config/recommended.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
module.exports = {
44
plugins: ['cypress'],
5+
env: {
6+
'cypress/globals': true,
7+
},
58
rules: {
69
'cypress/no-assigning-return-values': 'error',
710
'cypress/no-unnecessary-waiting': 'error',

0 commit comments

Comments
 (0)