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

[no-unreachable] and [no-unused-label] are handled inconsistently #4819

Open
3 tasks done
amayer42 opened this issue Apr 12, 2022 · 4 comments
Open
3 tasks done

[no-unreachable] and [no-unused-label] are handled inconsistently #4819

amayer42 opened this issue Apr 12, 2022 · 4 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@amayer42
Copy link

amayer42 commented Apr 12, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ]
}
function test() {
  return 'test';
  const a = 'a';
}

Label: {
  test();
}

Expected Result

The unreachable code and the unused label should both be handled by either TypeScript or by the eslint: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.

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 of v5.19.0, the rules in question still 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
@amayer42 amayer42 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Apr 12, 2022
@JoshuaKGoldberg JoshuaKGoldberg added documentation Documentation ("docs") that needs adding/updating accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Apr 17, 2022
@JoshuaKGoldberg
Copy link
Member

Once #4706 is added with overhauled preset config docs, it'd be good to document this a bit more. +1

@tylerlaprade

This comment was marked as outdated.

@bradzacher

This comment was marked as outdated.

@tylerlaprade

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
No open projects
Status: Todo
Development

No branches or pull requests

4 participants