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-shadow] False positive: export enum #2570

Closed
3 tasks done
theneverstill opened this issue Sep 16, 2020 · 6 comments
Closed
3 tasks done

[no-shadow] False positive: export enum #2570

theneverstill opened this issue Sep 16, 2020 · 6 comments
Labels
fix: out of date packages user was on an old version of our tooling or ESLint, updating fixed it package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@theneverstill
Copy link

theneverstill commented Sep 16, 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.

Repro

eslint config

{
  "rules": {
    "@typescript-eslint/no-unused-vars": "error"
  }
}

(with and without the args: 'none' option)

foo.vue

import type { Route } from "vue-router";

...

const foo: Promise<Route> = this.$router.push({...});

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": "./",
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext", "ScriptHost"],
    "module": "ESNext",
    "moduleResolution": "node",
    "outDir": "./dist",
    "paths": {
      "@/*": ["./src/*"]
    },
    "resolveJsonModule": true,
    "strict": true,
    "target": "ESNext",
    "types": ["jest", "node"]
  },
  "include": [
    "bin/**/*.ts",
    "src/**/*.ts",
    "src/**/*.vue"
  ]
}

Expected Result

Similar to #2453, the type is being used and therefore it should not be flagged as unused.

Actual Result

error    'Route' is defined but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars

Additional Info

This doesn't happen in "@typescript-eslint/eslint-plugin": "^3.10.1",

Versions

"@typescript-eslint/eslint-plugin": "^4.1.1",

@theneverstill theneverstill added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Sep 16, 2020
@bradzacher
Copy link
Member

I'm unable to repro this against master.
Likely you have old version of our tooling installed.

Could you please check the versions you have installed using one of the following?

$ npm list @typescript-eslint/eslint-plugin @typescript-eslint/parser
$ yarn list @typescript-eslint/eslint-plugin @typescript-eslint/parser

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Sep 16, 2020
@theneverstill
Copy link
Author

Thanks @bradzacher for the prompt and accurate response. npm neglected to inform me of the outdated peer dependency.

Nothing to see here, carry on. 👋

@bradzacher bradzacher added fix: out of date packages user was on an old version of our tooling or ESLint, updating fixed it and removed awaiting response Issues waiting for a reply from the OP or another party labels Sep 16, 2020
@theneverstill theneverstill reopened this Sep 16, 2020
@theneverstill
Copy link
Author

@bradzacher Let's update the title on this issue, but.. fixed one issue and broke another. Perhaps you can replicate this one:

export enum SignOutType {
  global = "GLOBAL",
  local = "LOCAL",
}

throws:

/src/enum/sign-out-type.ts
  1:13  error  'SignOutType' is already declared in the upper scope  no-shadow

Same version in initial description and previously it was working.

@theneverstill theneverstill changed the title [no-unused-vars] False positive: type import [no-shadow] False positive: export enum Sep 16, 2020
@theneverstill
Copy link
Author

🤦 Sorry. I'm done wasting your time. Carry on.

@KostkaBrukowa
Copy link

Hey! I've had the same problem today and this issue saved me probably a lot of time. Thanks

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix: out of date packages user was on an old version of our tooling or ESLint, updating fixed it package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants