Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
{"extends": ["eslint:recommended","plugin:@typescript-eslint/eslint-recommended","plugin:@typescript-eslint/recommended" ]}
functiontest(){return'test';consta='a';}Label:{test();}
Expected Result
The unreachable code and the unused label should both be handled by either TypeScript or by theeslint:recommended
rules.
Actual Result
With default settings, the unused label is flagged as invalid both by VSCode (dims the text and provides the reason: "Unused label.ts(7028)") and when linting ("'Label:' is defined but never used.eslint(no-unused-labels)"). The unreachable code is only flagged as invalid by VSCode (dims the text and provides the reason: "Unreachable code detected.ts(7027)").
Additional Info
Based upon my understanding of the eslint-recommended, any rule that is handled by the TypeScript compiler by default should be disabled by this config. I'm curious if this stance holds even for the rules above that are not considered errors in TypeScript by default.
- https://www.typescriptlang.org/tsconfig/#allowUnreachableCode
- https://www.typescriptlang.org/tsconfig/#allowUnusedLabels
It might be good to document that stance a bit better. That seems like the decision from#1041, though it seems that nothing was ever done to enhance the documentation.
Documentation aside, I think that it at least makes sense to be as consistent as possible with how the eslint-recommended config handles rules that overlap with TypeScript.
Versions
It's worth pointing out along with these versions that as ofv5.19.0
, the rules in questionstill have the same settings as in my local versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 4.3.0 |
@typescript-eslint/parser | 4.3.0 |
TypeScript | 4.0.5 |
ESLint | 7.31.0 |
node | 14.19.0 |