Add no-duplicate-case documentation note about ignoring side effects
See original GitHub issueEnvironment
Node version: v16.13.1 npm version: 7.13.0 Local ESLint version: v8.7.0 Global ESLint version: N/A Operating System: Windows 10 Home
What parser are you using?
What did you do?
Configuration
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"jsx": true,
"useJSXTextNode": true,
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["eslint:recommended"],
"rules": {}
}
let x = 0;
switch (1) {
case x++: {
break;
}
case x++: {
break;
}
}
What did you expect to happen?
Since the code has side effects, the cases being checked are not identical/duplicate, so no error should be generated.
What actually happened?
The code generated a false-positive error on cases that are not duplicate.
Participation
- I am willing to submit a pull request for this issue.
Additional comments
I realise this is a very niche case, I found this while enabling eslint on unit tests for a compiler, hence the code testing special edge case behaviours.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Eslint ignore - Caritas Castellaneta
NOTE : For my situation, I had to add the // eslint-disable-next-line to each of ... If you encountered the "Bug: no-duplicate-case ignores...
Read more >gitignore Documentation - Git
DESCRIPTION. A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES...
Read more >eslint/CHANGELOG.md at main - GitHub
6814922 fix: escaping for square brackets in ignore patterns (#15666) (Milos Djermanovic); c481cec docs: add fast-eslint-8 to atom integrations (userguide) ...
Read more >Ignore Definition & Meaning - Merriam-Webster
neglect implies giving insufficient attention to something that merits one's attention. disregard suggests voluntary inattention.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Dionysusnu, thanks for the issue!
I can reproduce this with the default parser as well: online demo.
This is indeed not a duplicate, but I think it’s a good case for
eslint-disable
comments. We could add “When Not To Use It” section in the docs for this rule, mentioning side effects like in no-dupe-else-if rule docs. @eslint/eslint-tsc thoughts?I marked this as an accepted issue to update the docs, and prepared PR https://github.com/eslint/eslint/pull/15563