eslint-plugin-cypress 5.1.1 → 5.2.1

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/CONTRIBUTING.md CHANGED
@@ -43,9 +43,13 @@ To add a new rule:
43
43
 
44
44
  This plugin uses the ESLint [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) to generate consistent documentation.
45
45
 
46
- - Install with `npm install eslint-doc-generator -g`
46
+ - Install with `npm install eslint-doc-generator@latest -g`
47
47
  - Run `eslint-doc-generator` in the root directory of the plugin
48
48
 
49
+ Note that [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) has some unresolved issues running under
50
+ Microsoft Windows (see issue[#265](https://github.com/cypress-io/eslint-plugin-cypress/issues/265)).
51
+ Do not attempt to run under Windows until these issues are resolved.
52
+
49
53
  ## Merging pull requests
50
54
 
51
55
  This information is for Cypress.io Members or Collaborators who merge pull requests:
package/README.md CHANGED
@@ -75,6 +75,8 @@ These rules enforce some of the [best practices recommended for using Cypress](h
75
75
 
76
76
  In the following sections, different examples of possible configuration file contents are given, together with some brief explanations. Adapt these examples according to your needs.
77
77
 
78
+ The examples use the `defineConfig()` helper, introduced with ESLint [9.22.0](https://eslint.org/blog/2025/03/eslint-v9.22.0-released/). Refer to the blog article [Evolving flat config with extends](https://eslint.org/blog/2025/03/flat-config-extends-define-config-global-ignores/) for background information. If you are using ESLint `<9.22.0`, import `defineConfig` from [@eslint/config-helpers](https://www.npmjs.com/package/@eslint/config-helpers) instead of from `eslint/config`.
79
+
78
80
  ### Cypress
79
81
 
80
82
  All rules are available by importing from `eslint-plugin-cypress` and can be individually activated.
@@ -82,8 +84,9 @@ All rules are available by importing from `eslint-plugin-cypress` and can be ind
82
84
  - [cypress/unsafe-to-chain-command](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/unsafe-to-chain-command.md) is activated and set to `error`
83
85
 
84
86
  ```js
87
+ import { defineConfig } from 'eslint/config'
85
88
  import pluginCypress from 'eslint-plugin-cypress'
86
- export default [
89
+ export default defineConfig([
87
90
  {
88
91
  plugins: {
89
92
  cypress: pluginCypress,
@@ -92,7 +95,7 @@ export default [
92
95
  'cypress/unsafe-to-chain-command': 'error',
93
96
  },
94
97
  },
95
- ]
98
+ ])
96
99
  ```
97
100
 
98
101
  ### Cypress recommended
@@ -102,15 +105,19 @@ The `eslint-plugin-cypress` [recommended rules](#rules) `configs.recommended` ar
102
105
  - [cypress/no-unnecessary-waiting](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-unnecessary-waiting.md) which is set to `off`
103
106
 
104
107
  ```js
108
+ import { defineConfig } from 'eslint/config'
105
109
  import pluginCypress from 'eslint-plugin-cypress'
106
- export default [
107
- pluginCypress.configs.recommended,
110
+ export default defineConfig([
108
111
  {
112
+ files: ['cypress/**/*.js'],
113
+ extends: [
114
+ pluginCypress.configs.recommended,
115
+ ],
109
116
  rules: {
110
117
  'cypress/no-unnecessary-waiting': 'off',
111
118
  },
112
119
  },
113
- ]
120
+ ])
114
121
  ```
115
122
 
116
123
  ### Cypress globals
@@ -118,8 +125,16 @@ export default [
118
125
  The `configs.globals` are activated.
119
126
 
120
127
  ```js
128
+ import { defineConfig } from 'eslint/config'
121
129
  import pluginCypress from 'eslint-plugin-cypress'
122
- export default [pluginCypress.configs.globals]
130
+ export default defineConfig([
131
+ {
132
+ files: ['cypress/**/*.js'],
133
+ extends: [
134
+ pluginCypress.configs.globals,
135
+ ],
136
+ },
137
+ ])
123
138
  ```
124
139
 
125
140
  ## Disable rules
@@ -187,12 +202,16 @@ npm install eslint-plugin-mocha@^11 --save-dev
187
202
  ```
188
203
 
189
204
  ```js
205
+ import { defineConfig } from 'eslint/config'
190
206
  import pluginMocha from 'eslint-plugin-mocha'
191
207
  import pluginCypress from 'eslint-plugin-cypress'
192
- export default [
193
- pluginMocha.configs.recommended,
194
- pluginCypress.configs.recommended,
208
+ export default defineConfig([
195
209
  {
210
+ files: ['cypress/**/*.js'],
211
+ extends: [
212
+ pluginMocha.configs.recommended,
213
+ pluginCypress.configs.recommended,
214
+ ],
196
215
  rules: {
197
216
  'mocha/no-exclusive-tests': 'error',
198
217
  'mocha/no-pending-tests': 'error',
@@ -200,7 +219,7 @@ export default [
200
219
  'cypress/no-unnecessary-waiting': 'off',
201
220
  },
202
221
  },
203
- ]
222
+ ])
204
223
  ```
205
224
 
206
225
  ### Cypress and Chai recommended
@@ -216,17 +235,21 @@ npm install eslint-plugin-chai-friendly@^1.0.1 --save-dev
216
235
  ```
217
236
 
218
237
  ```js
238
+ import { defineConfig } from 'eslint/config'
219
239
  import pluginCypress from 'eslint-plugin-cypress'
220
240
  import pluginChaiFriendly from 'eslint-plugin-chai-friendly'
221
- export default [
222
- pluginCypress.configs.recommended,
223
- pluginChaiFriendly.configs.recommendedFlat,
241
+ export default defineConfig([
224
242
  {
243
+ files: ['cypress/**/*.js'],
244
+ extends: [
245
+ pluginCypress.configs.recommended,
246
+ pluginChaiFriendly.configs.recommendedFlat,
247
+ ],
225
248
  rules: {
226
249
  'cypress/no-unnecessary-waiting': 'off',
227
250
  },
228
251
  },
229
- ]
252
+ ])
230
253
  ```
231
254
 
232
255
  ## Contributing
@@ -1,4 +1,6 @@
1
- # Require screenshots to be preceded by an assertion (`cypress/assertion-before-screenshot`)
1
+ # cypress/assertion-before-screenshot
2
+
3
+ 📝 Require screenshots to be preceded by an assertion.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow assigning return values of `cy` calls (`cypress/no-assigning-return-values`)
1
+ # cypress/no-assigning-return-values
2
+
3
+ 📝 Disallow assigning return values of `cy` calls.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended` config.
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `async`/`await` in Cypress `before` methods (`cypress/no-async-before`)
1
+ # cypress/no-async-before
2
+
3
+ 📝 Disallow using `async`/`await` in Cypress `before` methods.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `async`/`await` in Cypress test cases (`cypress/no-async-tests`)
1
+ # cypress/no-async-tests
2
+
3
+ 📝 Disallow using `async`/`await` in Cypress test cases.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended` config.
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow chain of `cy.get()` calls (`cypress/no-chained-get`)
1
+ # cypress/no-chained-get
2
+
3
+ 📝 Disallow chain of `cy.get()` calls.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `cy.debug()` calls (`cypress/no-debug`)
1
+ # cypress/no-debug
2
+
3
+ 📝 Disallow using `cy.debug()` calls.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `force: true` with action commands (`cypress/no-force`)
1
+ # cypress/no-force
2
+
3
+ 📝 Disallow using `force: true` with action commands.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `cy.pause()` calls (`cypress/no-pause`)
1
+ # cypress/no-pause
2
+
3
+ 📝 Disallow using `cy.pause()` calls.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow waiting for arbitrary time periods (`cypress/no-unnecessary-waiting`)
1
+ # cypress/no-unnecessary-waiting
2
+
3
+ 📝 Disallow waiting for arbitrary time periods.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended` config.
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow using `cy.xpath()` calls (`cypress/no-xpath`)
1
+ # cypress/no-xpath
2
+
3
+ 📝 Disallow using `cy.xpath()` calls.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Require `data-*` attribute selectors (`cypress/require-data-selectors`)
1
+ # cypress/require-data-selectors
2
+
3
+ 📝 Require `data-*` attribute selectors.
2
4
 
3
5
  <!-- end auto-generated rule header -->
4
6
 
@@ -1,4 +1,6 @@
1
- # Disallow actions within chains (`cypress/unsafe-to-chain-command`)
1
+ # cypress/unsafe-to-chain-command
2
+
3
+ 📝 Disallow actions within chains.
2
4
 
3
5
  💼 This rule is enabled in the ✅ `recommended` config.
4
6
 
package/lib/flat.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { ESLint, Linter } from 'eslint'
2
+
3
+ declare const plugin: {
4
+ meta: { name: string, version: string }
5
+ configs: {
6
+ globals: Linter.Config<Linter.RulesRecord>
7
+ recommended: Linter.Config<Linter.RulesRecord>
8
+ }
9
+ rules: NonNullable<ESLint.Plugin['rules']>
10
+ }
11
+
12
+ export = plugin
@@ -49,6 +49,7 @@ const schema = {
49
49
  default: [],
50
50
  },
51
51
  },
52
+ additionalProperties: false,
52
53
  }
53
54
 
54
55
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-cypress",
3
- "version": "5.1.1",
3
+ "version": "5.2.1",
4
4
  "description": "An ESLint plugin for projects using Cypress",
5
5
  "main": "./lib/flat.js",
6
6
  "exports": {
@@ -34,14 +34,17 @@
34
34
  "globals": "^16.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@stylistic/eslint-plugin": "^4.4.0",
38
- "eslint": "^9.27.0",
39
- "eslint-plugin-eslint-plugin": "^6.4.0",
37
+ "@eslint/js": "^9.39.1",
38
+ "@stylistic/eslint-plugin": "^5.4.0",
39
+ "eslint": "^9.39.1",
40
+ "eslint-plugin-eslint-plugin": "^7.0.0",
40
41
  "eslint-plugin-mocha": "^11.1.0",
41
42
  "husky": "^9.1.7",
42
- "prettier": "^3.5.3",
43
- "semantic-release": "24.2.5",
44
- "vitest": "^3.1.4"
43
+ "prettier": "^3.6.2",
44
+ "semantic-release": "24.2.7",
45
+ "typescript": "^5.9.3",
46
+ "typescript-eslint": "^8.45.0",
47
+ "vitest": "^4.0.4"
45
48
  },
46
49
  "scripts": {
47
50
  "lint": "eslint",