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

[@typescript-eslint/no-unused-vars] Unused import. #3092

Closed
3 tasks done
infacto opened this issue Feb 22, 2021 · 1 comment
Closed
3 tasks done

[@typescript-eslint/no-unused-vars] Unused import. #3092

infacto opened this issue Feb 22, 2021 · 1 comment
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@infacto
Copy link

infacto commented Feb 22, 2021

  • 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

{
  "rules": {
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
  }
}
import { Component, Inject } from '@angular/core';
import { appRoutes } from 'src/routes'; // <-- appRoutes is underlined. 

@Component(/*...*/)
export class MyPage {
  constructor(
    @Inject(appRoutes) public readonly appRoutes: string[]
  ) {}
}

'appRoutes' is defined but never used. (eslint@typescript-eslint/no-unused-vars)

Expected Result

appRoutes is used in @Inject(...).

Actual Result

Claims appRoutes (on import) as unused.

Additional Info

Note: The variable in import is not grayed out (indicator for unused in vscode). TypeScript detects it as in-use.
Generally unused imports are grayed out (opacity about 0.5) and marked as unused, even from TypeScript. So this should be reported from the linter. Or is there something wrong?

Current workaround:

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { appRoutes } from 'src/routes'; 

Versions

Updated to the latest version for this issue. (Initial version was ^4.2.0)

package version
@typescript-eslint/eslint-plugin 4.15.1
@typescript-eslint/parser 4.15.1
TypeScript 4.0.5
ESLint 7.20.0
node 14.15.1
@infacto infacto added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Feb 22, 2021
@infacto infacto changed the title [@typescript-eslint/no-unused-vars] [@typescript-eslint/no-unused-vars] Unused import. Feb 22, 2021
@bradzacher
Copy link
Member

bradzacher commented Feb 22, 2021

duplicate of #2994

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Feb 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2021
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 package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants