8000 False positive of no-shadow rule with ENUMs · Issue #2483 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

False positive of no-shadow rule with ENUMs #2483

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

Closed
3 tasks done
DuncanWilder opened this issue Sep 4, 2020 · 2 comments
Closed
3 tasks done

False positive of no-shadow rule with ENUMs #2483

DuncanWilder opened this issue Sep 4, 2020 · 2 comments
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@DuncanWilder
Copy link
  • 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

{
  "parser": "@typescript-eslint/parser",
  "rules": {
    "no-shadow": ["error"]
  }
}
// This is the entire file - there is nothing else in it apart from these 4 lines
enum Direction {
    Up = 1,
    Down = -1
}

Expected Result

The ENUM should not state that it is declared in the upper scope

Actual Result

The following error message is received;

error 'Direction' is already declared in the upper scope no-shadow

Additional Info

Versions

package version
@typescript-eslint/parser 4.0.1
TypeScript 4.0.2
ESLint 7.8.1
node 12.16.3

Basically, it looks like the latest version of the parser fails to read ENUMs properly.

Downgrading @typescript-eslint/parser to v3.10.1 with the following .eslintrc file works and does not report ENUMs being declared in the upper scope.

{
  "parserOptions": {
    "sourceType": "module"
  },
  "parser": "@typescript-eslint/parser",
  "rules": {
    "no-shadow": ["error"]
  }
}
@DuncanWilder DuncanWilder added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Sep 4, 2020
@glen-84
Copy link
Contributor
glen-84 commented Sep 4, 2020

You need to use @typescript-eslint/no-shadow.

@DuncanWilder
Copy link
Author

Confirmed, disabling no-shadow and enabling @typescript-eslint/no-shadow works. Thanks

"rules": {
    "no-shadow": "off",
    "@typescript-eslint/no-shadow": "error"
}

@bradzacher bradzacher added fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin and removed package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Sep 4, 2020
trylovetom added a commit to AllJointTW/AllJointTool that referenced this issue Sep 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants
0