eslint-plugin-cypress 6.2.0 → 6.2.2
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.
|
@@ -10,6 +10,10 @@ Require `cy.get` to use only selectors that target `data-*` attributes.
|
|
|
10
10
|
|
|
11
11
|
## Rule Details
|
|
12
12
|
|
|
13
|
+
This rule checks the first parameter of each `cy.get`. It supports template literals, variable (re-)assignments and conditional expressions. For conditionals, all branches must conform to this rule.
|
|
14
|
+
|
|
15
|
+
Cypress aliases (as defined by `cy.as`) are always allowed.
|
|
16
|
+
|
|
13
17
|
Examples of **incorrect** code for this rule:
|
|
14
18
|
|
|
15
19
|
```js
|
|
@@ -18,6 +22,7 @@ cy.get('[daedta-cy=submit]').click()
|
|
|
18
22
|
cy.get('[d-cy=submit]')
|
|
19
23
|
cy.get('.btn-large').click()
|
|
20
24
|
cy.get('.btn-.large').click()
|
|
25
|
+
cy.get(condition ? "[data-cy=submit]" : ".btn-large")
|
|
21
26
|
|
|
22
27
|
const CLASS_SELECTOR = ".my-class";
|
|
23
28
|
cy.get(CLASS_SELECTOR)
|
|
@@ -36,6 +41,7 @@ Examples of **correct** code for this rule:
|
|
|
36
41
|
cy.get('[data-cy=submit]').click()
|
|
37
42
|
cy.get('[data-QA=submit]')
|
|
38
43
|
cy.get(`[data-QA=submit]`)
|
|
44
|
+
cy.get(condition ? "[data-cy=submit]" : "[data-QA=submit]")
|
|
39
45
|
|
|
40
46
|
const ASSESSMENT_SUBMIT = "[data-cy=assessment-submit]"
|
|
41
47
|
cy.get(ASSESSMENT_SUBMIT).click()
|
|
@@ -62,6 +62,11 @@ function isDataNode(firstArg, dataVariables) {
|
|
|
62
62
|
return dataVariables.has(firstArg.name)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
if (firstArg.type === 'ConditionalExpression') {
|
|
66
|
+
return isDataNode(firstArg.consequent, dataVariables)
|
|
67
|
+
&& isDataNode(firstArg.alternate, dataVariables)
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
return false
|
|
66
71
|
}
|
|
67
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-cypress",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "An ESLint plugin for projects using Cypress",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"eslint": ">=9"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"globals": "^17.
|
|
34
|
+
"globals": "^17.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@eslint/js": "^10.0.1",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"eslint-plugin-mocha": "^11.2.0",
|
|
42
42
|
"husky": "^9.1.7",
|
|
43
43
|
"prettier": "^3.8.1",
|
|
44
|
-
"semantic-release": "^25.0.3",
|
|
45
44
|
"typescript": "^5.9.3",
|
|
46
45
|
"typescript-eslint": "^8.56.1",
|
|
47
46
|
"vitest": "^4.0.18"
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
"lint-fix": "eslint --fix",
|
|
52
51
|
"format": "prettier --write .",
|
|
53
52
|
"format:check": "prettier --check .",
|
|
54
|
-
"semantic-release": "semantic-release",
|
|
55
53
|
"test": "vitest run",
|
|
56
54
|
"prepare": "husky"
|
|
57
55
|
}
|