Skip to content

Commit e9e8a77

Browse files
chore(docs): Explain how to temporarily disable rules (#81)
Co-authored-by: Chris Breiding <[email protected]>
1 parent 9bcf51e commit e9e8a77

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,51 @@ Use the recommended configuration and you can forego configuring _plugins_, _rul
6262
}
6363
```
6464

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+
65110
## Rules
66111

67112
These rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices).

tests/lib/rules/no-unnecessary-waiting.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ ruleTester.run('no-unnecessary-waiting', rule, {
2626
{ code: 'const customWait = (alias = "@someRequest") => { cy.wait(alias) }', parserOptions, errors },
2727
{ code: 'function customWait (ms) { cy.wait(ms) }', parserOptions, errors },
2828
{ 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+
},
2952
],
3053

3154
invalid: [

0 commit comments

Comments
 (0)