Skip to content

Commit 9a1aae9

Browse files
committed
create a cypress/globals env instead of an extends config
1 parent 973542c commit 9a1aae9

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Cypress ESLint Plugin
22

3-
An ESLint plugin for projects that use Cypress.
3+
An ESLint plugin for projects using [Cypress](https://cypress.io) for tests.
44

5-
Specifies the environment and globals (`cy`, `Cypress`, etc) for use when writing tests using [Cypress](https://cypress.io).
5+
Specifies globals for Cypress (`cy` & `Cypress`) as well as browser and mocha globals.
66

77
## Installation
88

@@ -12,12 +12,17 @@ npm install eslint-plugin-cypress --save-dev
1212

1313
## Usage
1414

15-
Add `cypress` as a plugin in your `.eslintrc`:
15+
Add an `.eslintrc` file to your `cypress` directory with the following:
1616

1717
```json
18+
// my-project/cypress/.eslintrc
19+
1820
{
1921
"plugins": [
2022
"cypress"
21-
]
23+
],
24+
"env": {
25+
"cypress/globals": true
26+
}
2227
}
2328
```

index.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1+
const globals = require('globals')
2+
13
module.exports = {
2-
env: {
3-
browser: true,
4-
},
5-
parserOptions: {
6-
ecmaVersion: 6,
4+
environments: {
5+
globals: {
6+
globals: Object.assign(globals.browser, globals.mocha, {
7+
cy: false,
8+
Cypress: false,
9+
expect: false,
10+
assert: false,
11+
}),
12+
parserOptions: {
13+
ecmaVersion: 2017,
14+
},
15+
},
716
},
8-
globals: {
9-
cy: true,
10-
Cypress: true,
11-
12-
describe: true,
13-
context: true,
14-
it: true,
15-
before: true,
16-
beforeEach: true,
17-
after: true,
18-
afterEach: true,
19-
expect: true,
20-
assert: true,
21-
}
2217
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
"homepage": "https://github.com/cypress-io/eslint-plugin-cypress#readme",
2121
"peerDependencies": {
2222
"eslint": ">= 3.2.1"
23+
},
24+
"dependencies": {
25+
"globals": "^11.0.1"
2326
}
2427
}

0 commit comments

Comments
 (0)