8000 [no-shadow] False positive for enum's · Issue #2552 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

[no-shadow] False positive for enum's #2552

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
prdatur opened this issue Sep 13, 2020 · 3 comments
Closed
3 tasks done

[no-shadow] False positive for enum's #2552

prdatur opened this issue Sep 13, 2020 · 3 comments
Labels
duplicate This issue or pull request already exists fix: user error issue was fixed by correcting the configuration / correcting the code package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@prdatur
Copy link
prdatur commented Sep 13, 2020
  • 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.

Version:

"@typescript-eslint/eslint-plugin": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.1.0.tgz",
      "integrity": "sha512-U+nRJx8XDUqJxYF0FCXbpmD9nWt/xHDDG0zsw1vrVYAmEAuD/r49iowfurjSL2uTA2JsgtpsyG7mjO7PHf2dYw==",
      "dev": true,
      "requires": {
        "@typescript-eslint/experimental-utils": "4.1.0",
        "@typescript-eslint/scope-manager": "4.1.0",
        "debug": "^4.1.1",
        "functional-red-black-tree": "^1.0.1",
        "regexpp": "^3.0.0",
        "semver": "^7.3.2",
        "tsutils": "^3.17.1"
      }
    },

Repro

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
    ],
    "parser": "@typescript-eslint/parser",
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
        "no-shadow": ["error", { "builtinGlobals": false, "hoist": "functions", "allow": [] }]
    }
}
export enum TESTSHADOW {
    H
}

tsconfig

{
  "compilerOptions": {
    "module"   : "commonjs",
    "target"   : "ESNext",
    "sourceMap": false,
    "lib": [ "ESNext" ]
  },
  "exclude"        : [
    "node_modules",
    "vuejs/components",
    "vuejs/mixins",
    "vuejs/src"
  ]
}

Expected Result

The linting does not throw any error about no-shadow rule.

Actual Result

ESLint claims about that TESTSHADOW is already declaed in the upper scope.

Additional Info

Debug output: **eslint --debug vuejs/library/TEST_SHADOW.ts **

#  eslint:cli CLI args: [ '--debug', 'vuejs/library/TEST_SHADOW.ts' ] +0ms
  eslint:cli Running on file
8000
s +3ms
  eslint:config-array-factory Loading JSON config file: /opt/dev/portal-ng/portal3/package.json +0ms
  eslint:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: '/opt/dev/portal-ng/portal3', loose: false } ] +0ms
  eslint:ignore-pattern   processed: { basePath: '/opt/dev/portal-ng/portal3', patterns: [ '/**/node_modules/*' ] } +1ms
  eslint:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: '/opt/dev/portal-ng/portal3', loose: false } ] +1ms
  eslint:ignore-pattern   processed: { basePath: '/opt/dev/portal-ng/portal3', patterns: [ '/**/node_modules/*' ] } +0ms
  eslint:file-enumerator Start to iterate files: [ 'vuejs/library/TEST_SHADOW.ts' ] +0ms
  eslint:file-enumerator File: /opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts +0ms
  eslint:cascading-config-array-factory Load config files for /opt/dev/portal-ng/portal3/vuejs/library. +0ms
  eslint:cascading-config-array-factory No cache found: /opt/dev/portal-ng/portal3/vuejs/library. +0ms
  eslint:config-array-factory Config file not found on /opt/dev/portal-ng/portal3/vuejs/library +5ms
  eslint:cascading-config-array-factory No cache found: /opt/dev/portal-ng/portal3/vuejs. +1ms
  eslint:config-array-factory Config file not found on /opt/dev/portal-ng/portal3/vuejs +0ms
  eslint:cascading-config-array-factory No cache found: /opt/dev/portal-ng/portal3. +0ms
  eslint:config-array-factory Loading JSON config file: /opt/dev/portal-ng/portal3/.eslintrc.json +2ms
  eslint:config-array-factory Config file found: /opt/dev/portal-ng/portal3/.eslintrc.json +0ms
  eslint:config-array-factory Loading parser "@typescript-eslint/parser" from /opt/dev/portal-ng/portal3/.eslintrc.json +0ms
  eslint:config-array-factory Loaded: @typescript-eslint/parser@4.1.0 (/opt/dev/portal-ng/portal3/node_modules/@typescript-eslint/parser/dist/index.js) +1ms
  eslint:config-array-factory Loading plugin "@typescript-eslint" from /opt/dev/portal-ng/portal3/.eslintrc.json +173ms
  eslint:config-array-factory Loaded: @typescript-eslint/eslint-plugin@4.1.0 (/opt/dev/portal-ng/portal3/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +1ms
  eslint:config-array-factory Plugin /opt/dev/portal-ng/portal3/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 154ms +154ms
  eslint:cascading-config-array-factory No cache found: /opt/dev/portal-ng. +331ms
  eslint:config-array-factory Config file not found on /opt/dev/portal-ng +0ms
  eslint:cascading-config-array-factory No cache found: /opt/dev. +0ms
  eslint:config-array-factory Config file not found on /opt/dev +0ms
  eslint:cascading-config-array-factory No cache found: /opt. +1ms
  eslint:config-array-factory Config file not found on /opt +1ms
  eslint:cascading-config-array-factory No cache found: /. +0ms
  eslint:config-array-factory Config file not found on / +0ms
  eslint:rules Loading rule 'no-shadow' (remaining=281) +0ms
  eslint:cascading-config-array-factory Configuration was determined: ConfigArray [ { type: 'config', name: 'DefaultIgnorePattern', filePath: '', criteria: null, env: undefined, globals: undefined, ignorePattern: IgnorePattern { patterns: [Array], basePath: '/opt/dev/portal-ng/portal3', loose: false }, noInlineConfig: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined }, { type: 'config', name: '.eslintrc.json', filePath: '/opt/dev/portal-ng/portal3/.eslintrc.json', criteria: null, env: { browser: true, es2021: true, node: true }, globals: undefined, ignorePattern: undefined, noInlineConfig: undefined, parser: { error: null, filePath: '/opt/dev/portal-ng/portal3/node_modules/@typescript-eslint/parser/dist/index.js', id: '@typescript-eslint/parser', importerName: '.eslintrc.json', importerPath: '/opt/dev/portal-ng/portal3/.eslintrc.json' }, parserOptions: undefined, plugins: { '@typescript-eslint': [Object] }, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: { 'no-shadow': [Array] }, settings: undefined } ] on /opt/dev/portal-ng/portal3/vuejs/library +3ms
  eslint:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: '/opt/dev/portal-ng/portal3', loose: false } ] +338ms
  eslint:ignore-pattern   processed: { basePath: '/opt/dev/portal-ng/portal3', patterns: [ '/**/node_modules/*' ] } +0ms
  eslint:ignore-pattern Check {
  filePath: '/opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts',
  dot: false,
  relativePath: 'vuejs/library/TEST_SHADOW.ts',
  result: false
} +1ms
  eslint:cli-engine Lint /opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts +0ms
  eslint:linter Linting code for /opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts (pass 1) +0ms
  eslint:linter Verify +0ms
  eslint:linter With ConfigArray: /opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts +0ms
  eslint:linter Generating fixed text for /opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts (pass 1) +20ms
  eslint:source-code-fixer Applying fixes +0ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms
  eslint:file-enumerator Complete iterating files: ["vuejs/library/TEST_SHADOW.ts"] +358ms
  eslint:cli-engine Linting complete in: 358ms +20ms

/opt/dev/portal-ng/portal3/vuejs/library/TEST_SHADOW.ts
  1:13  error  'TESTSHADOW' is already declared in the upper scope  no-shadow

✖ 1 problem (1 error, 0 warnings)

Versions

package version
@typescript-eslint/eslint-plugin 4.1.0
@typescript-eslint/parser 4.1.0
TypeScript 4.0.2
ESLint v7.9.0
node v12.1.0
@prdatur prdatur added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 13, 2020
@bradzacher
Copy link
Member
bradzacher commented Sep 13, 2020

you need to update your config

Finally, please use the search next time.
Duplicate of #2466, #2483 and #2484

@bradzacher bradzacher added duplicate This issue or pull request already exists fix: user error issue was fixed by correcting the configuration / correcting the code and removed triage Waiting for team members to take a look labels Sep 13, 2020
@prdatur
A7FB
Copy link
Author
prdatur commented Sep 14, 2020

Thx, with the last link i got it working, I have searched with google and I only got the github issue were it reports no-shadow while using a prior defined variable as an enum key. Sorry that I didn't saw the other tickets.

Btw. If you use a "template" for this answer (As I saw mosttly the same on the other Tickets), I recommend to update the first link, it includes a dot after the tag and it will forward to a 404 page.

@bradzacher
Copy link
Member

Do not rely on Google search to find github issues. Google does not understand things like this well.

Always use the github issue search within the repo.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists 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

2 participants
0