Skip to content

False positive of no-shadow rule with ENUMs #2483

@DuncanWilder

Description

@DuncanWilder
  • 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"]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix: user errorissue was fixed by correcting the configuration / correcting the codepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions