eslint-plugin-cypress 6.4.2 → 6.4.4
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 +10 -7
- package/README.md +20 -22
- package/docs/rules/no-and.md +4 -1
- package/docs/rules/require-data-selectors.md +6 -6
- package/lib/rules/no-and.js +1 -1
- package/package.json +14 -10
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
|
|
44
|
+
This plugin uses the [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) package to generate consistent documentation.
|
|
45
45
|
|
|
46
|
-
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
@@ -53,22 +53,24 @@ These rules enforce some of the [best practices recommended for using Cypress](h
|
|
|
53
53
|
|
|
54
54
|
💼 Configurations enabled in.\
|
|
55
55
|
✅ Set in the `recommended` configuration.\
|
|
56
|
+
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
|
|
56
57
|
❌ Deprecated.
|
|
57
58
|
|
|
58
|
-
| Name
|
|
59
|
-
| :----------------------------------------------------------------------- |
|
|
60
|
-
| [assertion-before-screenshot](docs/rules/assertion-before-screenshot.md) | require screenshots to be preceded by an assertion
|
|
61
|
-
| [no-
|
|
62
|
-
| [no-
|
|
63
|
-
| [no-async-
|
|
64
|
-
| [no-
|
|
65
|
-
| [no-
|
|
66
|
-
| [no-
|
|
67
|
-
| [no-
|
|
68
|
-
| [no-
|
|
69
|
-
| [no-
|
|
70
|
-
| [
|
|
71
|
-
| [
|
|
59
|
+
| Name | Description | 💼 | 🔧 | ❌ |
|
|
60
|
+
| :----------------------------------------------------------------------- | :-------------------------------------------------------------- | :- | :- | :- |
|
|
61
|
+
| [assertion-before-screenshot](docs/rules/assertion-before-screenshot.md) | require screenshots to be preceded by an assertion | | | |
|
|
62
|
+
| [no-and](docs/rules/no-and.md) | enforce `.should()` over `.and()` for starting assertion chains | | 🔧 | |
|
|
63
|
+
| [no-assigning-return-values](docs/rules/no-assigning-return-values.md) | disallow assigning return values of `cy` calls | ✅ | | |
|
|
64
|
+
| [no-async-before](docs/rules/no-async-before.md) | disallow using `async`/`await` in Cypress `before` methods | | | |
|
|
65
|
+
| [no-async-tests](docs/rules/no-async-tests.md) | disallow using `async`/`await` in Cypress test cases | ✅ | | |
|
|
66
|
+
| [no-chained-get](docs/rules/no-chained-get.md) | disallow chain of `cy.get()` calls | | | |
|
|
67
|
+
| [no-debug](docs/rules/no-debug.md) | disallow using `cy.debug()` calls | | | |
|
|
68
|
+
| [no-force](docs/rules/no-force.md) | disallow using `force: true` with action commands | | | |
|
|
69
|
+
| [no-pause](docs/rules/no-pause.md) | disallow using `cy.pause()` calls | | | |
|
|
70
|
+
| [no-unnecessary-waiting](docs/rules/no-unnecessary-waiting.md) | disallow waiting for arbitrary time periods | ✅ | | |
|
|
71
|
+
| [no-xpath](docs/rules/no-xpath.md) | disallow using `cy.xpath()` calls | | | ❌ |
|
|
72
|
+
| [require-data-selectors](docs/rules/require-data-selectors.md) | require `data-*` attribute selectors | | | |
|
|
73
|
+
| [unsafe-to-chain-command](docs/rules/unsafe-to-chain-command.md) | disallow actions within chains | ✅ | | |
|
|
72
74
|
|
|
73
75
|
<!-- end auto-generated rules list -->
|
|
74
76
|
<!-- prettier-ignore-end -->
|
|
@@ -112,9 +114,7 @@ import pluginCypress from 'eslint-plugin-cypress'
|
|
|
112
114
|
export default defineConfig([
|
|
113
115
|
{
|
|
114
116
|
files: ['cypress/**/*.js'],
|
|
115
|
-
extends: [
|
|
116
|
-
pluginCypress.configs.recommended,
|
|
117
|
-
],
|
|
117
|
+
extends: [pluginCypress.configs.recommended],
|
|
118
118
|
rules: {
|
|
119
119
|
'cypress/no-unnecessary-waiting': 'off',
|
|
120
120
|
},
|
|
@@ -132,9 +132,7 @@ import pluginCypress from 'eslint-plugin-cypress'
|
|
|
132
132
|
export default defineConfig([
|
|
133
133
|
{
|
|
134
134
|
files: ['cypress/**/*.js'],
|
|
135
|
-
extends: [
|
|
136
|
-
pluginCypress.configs.globals,
|
|
137
|
-
],
|
|
135
|
+
extends: [pluginCypress.configs.globals],
|
|
138
136
|
},
|
|
139
137
|
])
|
|
140
138
|
```
|
|
@@ -158,7 +156,7 @@ If you already have a TypeScript codebase, you can skip the next step. If not, y
|
|
|
158
156
|
"allowJs": true,
|
|
159
157
|
"checkJs": false,
|
|
160
158
|
"noEmit": true
|
|
161
|
-
}
|
|
159
|
+
}
|
|
162
160
|
}
|
|
163
161
|
```
|
|
164
162
|
|
|
@@ -175,7 +173,7 @@ export default defineConfig([
|
|
|
175
173
|
projectService: true,
|
|
176
174
|
},
|
|
177
175
|
},
|
|
178
|
-
}
|
|
176
|
+
},
|
|
179
177
|
])
|
|
180
178
|
```
|
|
181
179
|
|
package/docs/rules/no-and.md
CHANGED
|
@@ -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')
|
|
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 ?
|
|
25
|
+
cy.get(condition ? '[data-cy=submit]' : '.btn-large')
|
|
26
26
|
|
|
27
|
-
const CLASS_SELECTOR =
|
|
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 ?
|
|
44
|
+
cy.get(condition ? '[data-cy=submit]' : '[data-QA=submit]')
|
|
45
45
|
|
|
46
|
-
const 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/lib/rules/no-and.js
CHANGED
|
@@ -7,7 +7,7 @@ module.exports = {
|
|
|
7
7
|
meta: {
|
|
8
8
|
type: 'suggestion',
|
|
9
9
|
docs: {
|
|
10
|
-
description: 'enforce
|
|
10
|
+
description: 'enforce `.should()` over `.and()` for starting assertion chains',
|
|
11
11
|
recommended: false,
|
|
12
12
|
url: 'https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-and.md',
|
|
13
13
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-cypress",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.4",
|
|
4
4
|
"description": "An ESLint plugin for projects using Cypress",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,21 +37,22 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"globals": "^17.
|
|
40
|
+
"globals": "^17.8.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.
|
|
46
|
-
"cypress": "^15.
|
|
47
|
-
"eslint": "^10.
|
|
48
|
-
"eslint-
|
|
45
|
+
"@typescript-eslint/rule-tester": "^8.65.0",
|
|
46
|
+
"cypress": "^15.19.0",
|
|
47
|
+
"eslint": "^10.7.0",
|
|
48
|
+
"eslint-doc-generator": "^3.7.0",
|
|
49
|
+
"eslint-plugin-eslint-plugin": "^7.5.0",
|
|
49
50
|
"eslint-plugin-mocha": "^11.3.0",
|
|
50
51
|
"husky": "^9.1.7",
|
|
51
|
-
"prettier": "^3.
|
|
52
|
-
"typescript": "^
|
|
53
|
-
"typescript-eslint": "^8.
|
|
54
|
-
"vitest": "^4.1.
|
|
52
|
+
"prettier": "^3.9.6",
|
|
53
|
+
"typescript": "^6.0.3",
|
|
54
|
+
"typescript-eslint": "^8.65.0",
|
|
55
|
+
"vitest": "^4.1.10"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"lint": "eslint",
|
|
@@ -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
|
}
|