eslint-plugin-cypress 6.4.3 → 7.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/CONTRIBUTING.md CHANGED
@@ -29,7 +29,7 @@ To add a new rule:
29
29
  - Add a `meta.messages` property (see [MessageIds](https://eslint.org/docs/latest/extend/custom-rules#messageids))
30
30
  - Select the appropriate `meta.type` property using `problem`, `suggestion`, or `layout`
31
31
  - Complete the new rule by adding content to the three files previously created
32
- - Run `eslint-doc-generator` to generate automated documentation sections (see [Document generation](#document-generation) below)
32
+ - Run `npx eslint-doc-generator` to generate automated documentation sections (see [Document generation](#document-generation) below)
33
33
  - Review documentation changes
34
34
  - Run `npm run lint`
35
35
  - Run `npm run format`
@@ -41,14 +41,17 @@ To add a new rule:
41
41
 
42
42
  ## Document generation
43
43
 
44
- This plugin uses the ESLint [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) to generate consistent documentation.
44
+ This plugin uses the [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) package to generate consistent documentation.
45
45
 
46
- - Install with `npm install eslint-doc-generator@latest -g`
47
- - Run `eslint-doc-generator` in the root directory of the plugin
46
+ - Run `npx eslint-doc-generator` in the root directory of the plugin
48
47
 
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.
48
+ Previous compatibility issues with Windows are resolved, and
49
+ [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator)
50
+ is now installed together with other dependencies through `npm ci`.
51
+ If you previously had [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) installed globally,
52
+ to work with this repo, you can now uninstall it:
53
+
54
+ - Run `npm uninstall eslint-doc-generator -g` (only if previously installed)
52
55
 
53
56
  ## Merging pull requests
54
57
 
package/README.md CHANGED
@@ -6,7 +6,7 @@ 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) `v9` or `v10`. Lower versions are no longer supported.
9
+ Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v10`. Lower versions are no longer supported.
10
10
 
11
11
  ```sh
12
12
  npm install eslint eslint-plugin-cypress --save-dev
@@ -22,7 +22,6 @@ yarn add eslint eslint-plugin-cypress --dev
22
22
 
23
23
  ESLint as of `v10` and this plugin no longer support the use of the deprecated [eslintrc-type](https://eslint.org/docs/v9.x/use/configure/configuration-files-deprecated) config file format.
24
24
  You must use a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format.
25
- This is the default in ESLint `v9`, and in ESLint `v10` it is the only config format available.
26
25
 
27
26
  To set up a configuration, add a file `eslint.config.mjs` to the root directory of your Cypress project and include the following instructions to import the available configurations using:
28
27
 
@@ -79,8 +78,6 @@ These rules enforce some of the [best practices recommended for using Cypress](h
79
78
 
80
79
  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.
81
80
 
82
- 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`.
83
-
84
81
  ### Cypress
85
82
 
86
83
  All rules are available by importing from `eslint-plugin-cypress` and can be individually activated.
@@ -114,9 +111,7 @@ import pluginCypress from 'eslint-plugin-cypress'
114
111
  export default defineConfig([
115
112
  {
116
113
  files: ['cypress/**/*.js'],
117
- extends: [
118
- pluginCypress.configs.recommended,
119
- ],
114
+ extends: [pluginCypress.configs.recommended],
120
115
  rules: {
121
116
  'cypress/no-unnecessary-waiting': 'off',
122
117
  },
@@ -134,9 +129,7 @@ import pluginCypress from 'eslint-plugin-cypress'
134
129
  export default defineConfig([
135
130
  {
136
131
  files: ['cypress/**/*.js'],
137
- extends: [
138
- pluginCypress.configs.globals,
139
- ],
132
+ extends: [pluginCypress.configs.globals],
140
133
  },
141
134
  ])
142
135
  ```
@@ -160,7 +153,7 @@ If you already have a TypeScript codebase, you can skip the next step. If not, y
160
153
  "allowJs": true,
161
154
  "checkJs": false,
162
155
  "noEmit": true
163
- },
156
+ }
164
157
  }
165
158
  ```
166
159
 
@@ -177,7 +170,7 @@ export default defineConfig([
177
170
  projectService: true,
178
171
  },
179
172
  },
180
- }
173
+ },
181
174
  ])
182
175
  ```
183
176
 
@@ -234,15 +227,19 @@ During test spec development, [Mocha exclusive tests](https://mochajs.org/#exclu
234
227
 
235
228
  ### Cypress and Mocha recommended
236
229
 
237
- [eslint-plugin-mocha@^11](https://www.npmjs.com/package/eslint-plugin-mocha) is added to the example [Cypress recommended](#cypress-recommended).
230
+ [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) is added to the example [Cypress recommended](#cypress-recommended).
238
231
 
239
232
  The settings for individual `mocha` rules from the `configs.recommended` option are changed.
240
233
 
241
- - [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md) and [mocha/no-pending-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-pending-tests.md) are set to `error` instead of `warn`
242
- - [mocha/no-mocha-arrows](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-mocha-arrows.md) is set to `off` instead of `error`
234
+ - [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md)
235
+ and [mocha/no-pending-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-pending-tests.md)
236
+ are set to `error` instead of `warn`
237
+ - [mocha/no-mocha-arrows](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-mocha-arrows.md)
238
+ and [mocha/no-async-in-sync-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/documentation/rules/no-async-in-sync-tests.md)
239
+ are set to `off` instead of `error`
243
240
 
244
241
  ```shell
245
- npm install eslint-plugin-mocha@^11 --save-dev
242
+ npm install eslint-plugin-mocha --save-dev
246
243
  ```
247
244
 
248
245
  ```js
@@ -257,6 +254,7 @@ export default defineConfig([
257
254
  pluginCypress.configs.recommended,
258
255
  ],
259
256
  rules: {
257
+ 'mocha/no-async-in-sync-tests': 'off', // for Cypress compatibility
260
258
  'mocha/no-exclusive-tests': 'error',
261
259
  'mocha/no-pending-tests': 'error',
262
260
  'mocha/no-mocha-arrows': 'off',
@@ -275,7 +273,7 @@ Using an assertion such as `expect(value).to.be.true` can fail the ESLint rule `
275
273
  The recommended rules for both plugins are used: `pluginCypress.configs.recommended` and `pluginChaiFriendly.configs.recommendedFlat`:
276
274
 
277
275
  ```shell
278
- npm install eslint-plugin-chai-friendly@^1.0.1 --save-dev
276
+ npm install eslint-plugin-chai-friendly --save-dev
279
277
  ```
280
278
 
281
279
  ```js
@@ -26,7 +26,10 @@ Examples of **correct** code for this rule:
26
26
  cy.get('elem').should('have.text', 'blah')
27
27
  cy.get('.err').should('be.empty').and('be.hidden')
28
28
  cy.contains('Login').and('be.visible')
29
- cy.get('foo').should('be.visible').and('have.text', 'bar').and('have.class', 'active')
29
+ cy.get('foo')
30
+ .should('be.visible')
31
+ .and('have.text', 'bar')
32
+ .and('have.class', 'active')
30
33
  ```
31
34
 
32
35
  ## When Not To Use It
@@ -22,16 +22,16 @@ cy.get('[daedta-cy=submit]').click()
22
22
  cy.get('[d-cy=submit]')
23
23
  cy.get('.btn-large').click()
24
24
  cy.get('.btn-.large').click()
25
- cy.get(condition ? "[data-cy=submit]" : ".btn-large")
25
+ cy.get(condition ? '[data-cy=submit]' : '.btn-large')
26
26
 
27
- const CLASS_SELECTOR = ".my-class";
27
+ const CLASS_SELECTOR = '.my-class'
28
28
  cy.get(CLASS_SELECTOR)
29
29
 
30
30
  const TYPE = 'submit'
31
31
  const SUBMIT_TEMPLATE = `.${TYPE}`
32
32
  cy.get(SUBMIT_TEMPLATE)
33
33
 
34
- const MY_SUBMIT_TEMPLATE = SUBMIT_TEMPLATE;
34
+ const MY_SUBMIT_TEMPLATE = SUBMIT_TEMPLATE
35
35
  cy.get(MY_SUBMIT_TEMPLATE)
36
36
  ```
37
37
 
@@ -41,16 +41,16 @@ Examples of **correct** code for this rule:
41
41
  cy.get('[data-cy=submit]').click()
42
42
  cy.get('[data-QA=submit]')
43
43
  cy.get(`[data-QA=submit]`)
44
- cy.get(condition ? "[data-cy=submit]" : "[data-QA=submit]")
44
+ cy.get(condition ? '[data-cy=submit]' : '[data-QA=submit]')
45
45
 
46
- const ASSESSMENT_SUBMIT = "[data-cy=assessment-submit]"
46
+ const ASSESSMENT_SUBMIT = '[data-cy=assessment-submit]'
47
47
  cy.get(ASSESSMENT_SUBMIT).click()
48
48
 
49
49
  const TYPE = 'submit'
50
50
  const SUBMIT_TEMPLATE = `[data-QA=${TYPE}]`
51
51
  cy.get(SUBMIT_TEMPLATE)
52
52
 
53
- const MY_SUBMIT_TEMPLATE = SUBMIT_TEMPLATE;
53
+ const MY_SUBMIT_TEMPLATE = SUBMIT_TEMPLATE
54
54
  cy.get(MY_SUBMIT_TEMPLATE)
55
55
  ```
56
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-cypress",
3
- "version": "6.4.3",
3
+ "version": "7.0.0",
4
4
  "description": "An ESLint plugin for projects using Cypress",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -29,7 +29,7 @@
29
29
  "homepage": "https://github.com/cypress-io/eslint-plugin-cypress#readme",
30
30
  "peerDependencies": {
31
31
  "@typescript-eslint/parser": ">=8",
32
- "eslint": ">=9"
32
+ "eslint": ">=10"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@typescript-eslint/parser": {
@@ -37,20 +37,21 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "globals": "^17.7.0"
40
+ "globals": "^17.9.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@eslint/js": "^10.0.1",
44
44
  "@stylistic/eslint-plugin": "^5.10.0",
45
- "@typescript-eslint/rule-tester": "^8.62.1",
46
- "cypress": "^15.18.1",
47
- "eslint": "^10.6.0",
48
- "eslint-plugin-eslint-plugin": "^7.4.1",
49
- "eslint-plugin-mocha": "^11.3.0",
45
+ "@typescript-eslint/rule-tester": "^8.66.0",
46
+ "cypress": "^15.20.0",
47
+ "eslint": "^10.8.0",
48
+ "eslint-doc-generator": "^3.7.0",
49
+ "eslint-plugin-eslint-plugin": "^7.6.1",
50
+ "eslint-plugin-mocha": "^12.0.2",
50
51
  "husky": "^9.1.7",
51
- "prettier": "^3.9.4",
52
- "typescript": "^5.9.3",
53
- "typescript-eslint": "^8.62.1",
52
+ "prettier": "^3.9.6",
53
+ "typescript": "^6.0.3",
54
+ "typescript-eslint": "^8.66.0",
54
55
  "vitest": "^4.1.10"
55
56
  },
56
57
  "scripts": {
@@ -60,5 +61,8 @@
60
61
  "format:check": "prettier --check .",
61
62
  "test": "vitest run",
62
63
  "prepare": "husky"
64
+ },
65
+ "allowScripts": {
66
+ "cypress": true
63
67
  }
64
68
  }