eslint-plugin-cypress 2.11.2 → 2.11.3
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/README.md
CHANGED
|
@@ -62,6 +62,51 @@ Use the recommended configuration and you can forego configuring _plugins_, _rul
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Disable rules
|
|
66
|
+
|
|
67
|
+
You can disable specific rules per file, for a portion of a file, or for a single line.
|
|
68
|
+
|
|
69
|
+
Disable the `cypress/no-unnecessary-waiting` rule for the entire file by placing this at the start of the file:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Disable the `cypress/no-unnecessary-waiting` rule for a portion of the file:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
it('waits for a second', () => {
|
|
79
|
+
...
|
|
80
|
+
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
81
|
+
cy.wait(1000)
|
|
82
|
+
/* eslint-enable cypress/no-unnecessary-waiting */
|
|
83
|
+
...
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Disable the `cypress/no-unnecessary-waiting` rule for a specific line:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
it('waits for a second', () => {
|
|
91
|
+
...
|
|
92
|
+
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting
|
|
93
|
+
...
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
You can also disable a rule for the next line:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
it('waits for a second', () => {
|
|
101
|
+
...
|
|
102
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
103
|
+
cy.wait(1000)
|
|
104
|
+
...
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
For more, see the [ESLint rules](https://eslint.org/docs/user-guide/configuring/rules) documentation.
|
|
109
|
+
|
|
65
110
|
## Rules
|
|
66
111
|
|
|
67
112
|
These rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices).
|
package/lib/rules/no-force.js
CHANGED
|
@@ -42,7 +42,7 @@ module.exports = {
|
|
|
42
42
|
|
|
43
43
|
return node.arguments && node.arguments.length &&
|
|
44
44
|
node.arguments.some((arg) => {
|
|
45
|
-
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key.name === 'force')
|
|
45
|
+
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key && propNode.key.name === 'force')
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
48
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ const rule = require('../../../lib/rules/no-force')
|
|
|
9
9
|
const RuleTester = require('eslint').RuleTester
|
|
10
10
|
|
|
11
11
|
const errors = [{ messageId: 'unexpected' }]
|
|
12
|
-
const parserOptions = { ecmaVersion:
|
|
12
|
+
const parserOptions = { ecmaVersion: 2018 }
|
|
13
13
|
|
|
14
14
|
//------------------------------------------------------------------------------
|
|
15
15
|
// Tests
|
|
@@ -24,12 +24,13 @@ ruleTester.run('no-force', rule, {
|
|
|
24
24
|
{ code: `cy.get('button').click({multiple: true})`, parserOptions },
|
|
25
25
|
{ code: `cy.get('button').dblclick()`, parserOptions },
|
|
26
26
|
{ code: `cy.get('input').type('somth')`, parserOptions },
|
|
27
|
-
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions
|
|
28
|
-
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions
|
|
29
|
-
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions
|
|
30
|
-
{ code: `cy.get('input').check()`, parserOptions
|
|
31
|
-
{ code: `cy.get('input').select()`, parserOptions
|
|
32
|
-
{ code: `cy.get('input').focus()`, parserOptions
|
|
27
|
+
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions },
|
|
28
|
+
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions },
|
|
29
|
+
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions },
|
|
30
|
+
{ code: `cy.get('input').check()`, parserOptions },
|
|
31
|
+
{ code: `cy.get('input').select()`, parserOptions },
|
|
32
|
+
{ code: `cy.get('input').focus()`, parserOptions },
|
|
33
|
+
{ code: `cy.document().trigger("keydown", { ...event })`, parserOptions },
|
|
33
34
|
],
|
|
34
35
|
|
|
35
36
|
invalid: [
|
|
@@ -26,6 +26,29 @@ ruleTester.run('no-unnecessary-waiting', rule, {
|
|
|
26
26
|
{ code: 'const customWait = (alias = "@someRequest") => { cy.wait(alias) }', parserOptions, errors },
|
|
27
27
|
{ code: 'function customWait (ms) { cy.wait(ms) }', parserOptions, errors },
|
|
28
28
|
{ code: 'const customWait = (ms) => { cy.wait(ms) }', parserOptions, errors },
|
|
29
|
+
|
|
30
|
+
// disable the eslint rule
|
|
31
|
+
{
|
|
32
|
+
code: `
|
|
33
|
+
cy.wait(100); // eslint-disable-line no-unnecessary-waiting
|
|
34
|
+
`,
|
|
35
|
+
parserOptions,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
code: `
|
|
39
|
+
/* eslint-disable-next-line no-unnecessary-waiting */
|
|
40
|
+
cy.wait(100)
|
|
41
|
+
`,
|
|
42
|
+
parserOptions,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: `
|
|
46
|
+
/* eslint-disable no-unnecessary-waiting */
|
|
47
|
+
cy.wait(100)
|
|
48
|
+
/* eslint-enable no-unnecessary-waiting */
|
|
49
|
+
`,
|
|
50
|
+
parserOptions,
|
|
51
|
+
},
|
|
29
52
|
],
|
|
30
53
|
|
|
31
54
|
invalid: [
|