question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add no-duplicate-case documentation note about ignoring side effects

See original GitHub issue

Environment

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?

@typescript-eslint/parser

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:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Jan 31, 2022

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?

1reaction
mdjermanoviccommented, Feb 1, 2022

I marked this as an accepted issue to update the docs, and prepared PR https://github.com/eslint/eslint/pull/15563

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found