eslint-plugin-cypress 2.15.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.node-version CHANGED
@@ -1 +1 @@
1
- 16.15.0
1
+ 20.12.2
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 16.15.0
1
+ 20.12.2
@@ -0,0 +1,16 @@
1
+ # Contributing to cypress-io/eslint-plugin-cypress
2
+
3
+ Thanks for taking the time to contribute! :smile:
4
+
5
+ To add a new rule:
6
+ * Fork and clone this repository
7
+ * Generate a new rule (a [yeoman generator](https://github.com/eslint/generator-eslint) is available)
8
+ * Write test scenarios then implement logic
9
+ * Describe the rule in the generated `docs` file
10
+ * Run `npm test` to run [Jest](https://jestjs.io/) or
11
+ * Run `npm start` to run [Jest](https://jestjs.io/) in [watchAll](https://jestjs.io/docs/cli#--watchall) mode where it remains active and reruns when source changes are made
12
+ * Make sure all tests are passing
13
+ * Add the rule to the [README](README.md) file
14
+ * Create a PR
15
+
16
+ Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
package/README.md CHANGED
@@ -6,6 +6,8 @@ Note: If you installed ESLint globally then you must also install `eslint-plugin
6
6
 
7
7
  ## Installation
8
8
 
9
+ Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v7` or `v8`. ESLint `v9` is **not** supported yet.
10
+
9
11
  ```sh
10
12
  npm install eslint-plugin-cypress --save-dev
11
13
  ```
@@ -115,8 +117,6 @@ These rules enforce some of the [best practices recommended for using Cypress](h
115
117
 
116
118
  Rules with a check mark (✅) are enabled by default while using the `plugin:cypress/recommended` config.
117
119
 
118
- **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).
119
-
120
120
  | | Rule ID | Description |
121
121
  | :-- | :------------------------------------------------------------------------- | :-------------------------------------------------------------- |
122
122
  | ✅ | [no-assigning-return-values](./docs/rules/no-assigning-return-values.md) | Prevent assigning return values of cy calls |
@@ -128,6 +128,44 @@ Rules with a check mark (✅) are enabled by default while using the `plugin:cyp
128
128
  | | [require-data-selectors](./docs/rules/require-data-selectors.md) | Only allow data-\* attribute selectors (require-data-selectors) |
129
129
  | | [no-pause](./docs/rules/no-pause.md) | Disallow `cy.pause()` parent command |
130
130
 
131
+ ## Mocha and Chai
132
+
133
+ Cypress is built on top of [Mocha](https://on.cypress.io/guides/references/bundled-libraries#Mocha) and [Chai](https://on.cypress.io/guides/references/bundled-libraries#Chai). See the following sections for information on using ESLint plugins [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) and [eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly) together with `eslint-plugin-cypress`.
134
+
135
+ ## Mocha `.only` and `.skip`
136
+
137
+ During test spec development, [Mocha exclusive tests](https://mochajs.org/#exclusive-tests) `.only` or [Mocha inclusive tests](https://mochajs.org/#inclusive-tests) `.skip` may be used to control which tests are executed, as described in the Cypress documentation [Excluding and Including Tests](https://on.cypress.io/guides/core-concepts/writing-and-organizing-tests#Excluding-and-Including-Tests). To apply corresponding rules, you can install and use [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha). The rule [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md) detects the use of `.only` and the [mocha/no-skipped-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-skipped-tests.md) rule detects the use of `.skip`:
138
+
139
+ ```sh
140
+ npm install --save-dev eslint-plugin-mocha
141
+ ```
142
+
143
+ In your `.eslintrc.json`:
144
+
145
+ ```json
146
+ {
147
+ "plugins": [
148
+ "cypress",
149
+ "mocha"
150
+ ],
151
+ "rules": {
152
+ "mocha/no-exclusive-tests": "warn",
153
+ "mocha/no-skipped-tests": "warn"
154
+ }
155
+ }
156
+ ```
157
+
158
+ Or you can simply use the `cypress/recommended` and `mocha/recommended` configurations together, for example:
159
+
160
+ ```json
161
+ {
162
+ "extends": [
163
+ "plugin:cypress/recommended",
164
+ "plugin:mocha/recommended"
165
+ ]
166
+ }
167
+ ```
168
+
131
169
  ## Chai and `no-unused-expressions`
132
170
 
133
171
  Using an assertion such as `expect(value).to.be.true` can fail the ESLint rule `no-unused-expressions` even though it's not an error in this case. To fix this, you can install and use [eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly).
@@ -159,16 +197,6 @@ Or you can simply add its `recommended` config:
159
197
  }
160
198
  ```
161
199
 
162
- ## Contribution Guide
163
-
164
- To add a new rule:
165
- * Fork and clone this repository
166
- * Generate a new rule (a [yeoman generator](https://github.com/eslint/generator-eslint) is available)
167
- * Run `yarn start` or `npm start`
168
- * Write test scenarios then implement logic
169
- * Describe the rule in the generated `docs` file
170
- * Make sure all tests are passing
171
- * Add the rule to this README
172
- * Create a PR
200
+ ## Contributing
173
201
 
174
- Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
202
+ Please see our [Contributing Guideline](./CONTRIBUTING.md) which explains how to contribute rules or other fixes and features to the repo.
package/circle.yml CHANGED
@@ -5,15 +5,13 @@ workflows:
5
5
  main:
6
6
  jobs:
7
7
  - lint
8
- - test-v4
9
- - test-v5
10
- - test-v6
8
+ - test-v7
9
+ - test-v8
11
10
  - release:
12
11
  requires:
13
12
  - lint
14
- - test-v4
15
- - test-v5
16
- - test-v6
13
+ - test-v7
14
+ - test-v8
17
15
  filters:
18
16
  branches:
19
17
  only:
@@ -22,64 +20,58 @@ workflows:
22
20
  jobs:
23
21
  lint:
24
22
  docker:
25
- - image: circleci/node:16
23
+ - image: cimg/node:20.12.2
26
24
  steps:
27
25
  - checkout
28
26
  - run:
29
27
  name: Install dependencies
30
28
  command: npm ci
29
+ - run:
30
+ name: Show ESLint version
31
+ command: npx eslint --version
31
32
  - run:
32
33
  name: Lint code
33
34
  command: npm run lint
34
35
 
35
- test-v4:
36
+ test-v7:
36
37
  docker:
37
- - image: circleci/node:16
38
+ - image: cimg/node:20.12.2
38
39
  steps:
39
40
  - checkout
40
41
  - run:
41
42
  name: Install dependencies
42
43
  command: npm ci
43
44
  - run:
44
- name: Install ESLint 4
45
- command: npm install eslint@4
45
+ name: Install ESLint 7
46
+ command: npm install eslint@7
46
47
  - run:
47
- name: Test ESLint 4
48
- command: npm test
49
-
50
- test-v5:
51
- docker:
52
- - image: circleci/node:16
53
- steps:
54
- - checkout
48
+ name: Show ESLint version
49
+ command: npx eslint --version
55
50
  - run:
56
- name: Install dependencies
57
- command: npm ci
58
- - run:
59
- name: Install ESLint 5
60
- command: npm install eslint@5
61
- - run:
62
- name: Test ESLint 5
51
+ name: Test ESLint 7
63
52
  command: npm test
64
53
 
65
- test-v6:
54
+ test-v8:
66
55
  docker:
67
- - image: circleci/node:16
56
+ - image: cimg/node:20.12.2
68
57
  steps:
69
58
  - checkout
70
59
  - run:
71
60
  name: Install dependencies
72
61
  command: npm ci
73
62
  - run:
74
- name: Install ESLint 6
75
- command: npm install eslint@6
63
+ name: Install ESLint 8
64
+ command: npm install eslint@8
65
+ - run:
66
+ name: Show ESLint version
67
+ command: npx eslint --version
76
68
  - run:
77
- name: Test ESLint 6
69
+ name: Test ESLint 8
78
70
  command: npm test
79
71
 
80
72
  release:
81
73
  docker:
82
- - image: circleci/node:16
74
+ - image: cimg/node:20.12.2
83
75
  steps:
84
76
  - checkout
85
77
  - run:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-cypress",
3
- "version": "2.15.2",
3
+ "version": "3.0.0",
4
4
  "description": "An ESLint plugin for projects using Cypress",
5
5
  "main": "index.js",
6
6
  "author": "Cypress-io",
@@ -19,33 +19,32 @@
19
19
  },
20
20
  "homepage": "https://github.com/cypress-io/eslint-plugin-cypress#readme",
21
21
  "peerDependencies": {
22
- "eslint": ">= 3.2.1"
22
+ "eslint": ">=7 <9"
23
23
  },
24
24
  "dependencies": {
25
25
  "globals": "^13.20.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cypress/eslint-plugin-dev": "3.2.0",
29
- "@cypress/eslint-plugin-json": "3.2.1",
30
- "eslint": "^5.7.0",
28
+ "@cypress/eslint-plugin-dev": "3.9.1",
29
+ "@cypress/eslint-plugin-json": "3.2.3",
30
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
31
+ "@typescript-eslint/parser": "^4.33.0",
32
+ "eslint": "^7.32.0",
33
+ "eslint-plugin-mocha": "^6.3.0",
31
34
  "husky": "^8.0.3",
32
- "jest": "^24.8.0",
35
+ "jest": "^29.7.0",
33
36
  "semantic-release": "19.0.3"
34
37
  },
38
+ "overrides": {
39
+ "eslint-plugin-mocha": "$eslint-plugin-mocha"
40
+ },
35
41
  "scripts": {
36
42
  "lint": "eslint \"*.js\" \"**/**/*.js\"",
37
43
  "lint-fix": "npm run lint -- --fix",
38
44
  "semantic-release": "semantic-release",
39
- "start": "yarn run test-watch",
45
+ "start": "npm run test-watch",
40
46
  "test": "jest",
41
- "test:v4": "npm i eslint@4.x && npm run test",
42
- "test:v6": "npm i eslint@6.x && npm run test",
43
47
  "test-watch": "jest --watchAll",
44
48
  "prepare": "husky install"
45
- },
46
- "jest": {
47
- "testMatch": [
48
- "**/tests/**/*.js"
49
- ]
50
49
  }
51
50
  }