Skip to content

Commit

Permalink
chore(docs): Explain how to temporarily disable rules (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Breiding <[email protected]>
  • Loading branch information
bahmutov and chrisbreiding authored Apr 27, 2021
1 parent 9bcf51e commit e9e8a77
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,51 @@ Use the recommended configuration and you can forego configuring _plugins_, _rul
}
```

## Disable rules

You can disable specific rules per file, for a portion of a file, or for a single line.

Disable the `cypress/no-unnecessary-waiting` rule for the entire file by placing this at the start of the file:

```js
/* eslint-disable cypress/no-unnecessary-waiting */
```

Disable the `cypress/no-unnecessary-waiting` rule for a portion of the file:

```js
it('waits for a second', () => {
...
/* eslint-disable cypress/no-unnecessary-waiting */
cy.wait(1000)
/* eslint-enable cypress/no-unnecessary-waiting */
...
})
```

Disable the `cypress/no-unnecessary-waiting` rule for a specific line:

```js
it('waits for a second', () => {
...
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting
...
})
```

You can also disable a rule for the next line:

```js
it('waits for a second', () => {
...
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000)
...
})
```

For more, see the [ESLint rules](https://eslint.org/docs/user-guide/configuring/rules) documentation.

## Rules

These rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices).
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/rules/no-unnecessary-waiting.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ ruleTester.run('no-unnecessary-waiting', rule, {
{ code: 'const customWait = (alias = "@someRequest") => { cy.wait(alias) }', parserOptions, errors },
{ code: 'function customWait (ms) { cy.wait(ms) }', parserOptions, errors },
{ code: 'const customWait = (ms) => { cy.wait(ms) }', parserOptions, errors },

// disable the eslint rule
{
code: `
cy.wait(100); // eslint-disable-line no-unnecessary-waiting
`,
parserOptions,
},
{
code: `
/* eslint-disable-next-line no-unnecessary-waiting */
cy.wait(100)
`,
parserOptions,
},
{
code: `
/* eslint-disable no-unnecessary-waiting */
cy.wait(100)
/* eslint-enable no-unnecessary-waiting */
`,
parserOptions,
},
],

invalid: [
Expand Down

0 comments on commit e9e8a77

Please sign in to comment.