Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add 'when not to use it' section in no-duplicate-case docs #15563

Merged
merged 1 commit into from Feb 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/rules/no-duplicate-case.md
Expand Up @@ -91,3 +91,18 @@ switch (a) {
break;
}
```

## When Not To Use It

In rare cases where identical test expressions in `case` clauses produce different values, which necessarily means that the expressions are causing and relying on side effects, you will have to disable this rule.

```js
switch (a) {
case i++:
foo();
break;
case i++: // eslint-disable-line no-duplicate-case
bar();
break;
}
```