8000 Bug: no-unused-vars should not be flagged on imports used in `@link` etc. · Issue #10873 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: no-unused-vars should not be flagged on imports used in @link etc. #10873

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
4 tasks done
LukeAbby opened this issue Feb 23, 2025 · 1 comment
Closed
4 tasks done
Labels
bug Something isn't working duplicate This issue or pull request already exists locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@LukeAbby
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.7.2&fileType=.tsx&code=KYDwDg9gTgLgBDAnmYcCiICGBbMAbVAXjgEYAmAZgG4BYAKHoEtdp4kU4BvdLXAuTAGc4AGUYA7ANbAAJgBVkqAL5wAZlAjY4AIgB0AeglgArjG316%2BgFRX6cK1wACeCZNGvZClCtXQ4M4BhMRjxBXTsrfSA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tidmUQAmtAG4BDaKgyRE0aB2iRwYAL4hlQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3QAacDQD00qPFgATDugBK6ErFRsCxClCJL0RdAA88kKQF8QVoA&tokens=false

Repro Code

import { LinkedType } from "./someFile"

/**
 * {@link LinkedType}
 */

ESLint Config

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

tsconfig

Expected Result

I expected no error because while the import is unused outside of @links I consider this a valid usage of the import. Notably tsc itself recognizes this pattern and does not give an unused variable warning. Switching all links to the much less elegant {@link import("./someFile").LinkedType | LinkedType} seems unideal when it's done many times and introducing a helper type just reintroduces the no-unused-vars error.

Actual Result

The error 'LinkedType' is defined but never used. appears.

Additional Info

In TSDoc I believe the applicable tags are @link, @inheritDoc, and @see. In JSDoc as a whole it applies to any tags that could include a type. I believe that would be @type, @param, @typedef, @returns, @property, @this, @throws, @yields, and synonyms.

Important note: I strongly believe this should only apply to imports. This is because if you happen to write {@link SomeUnusedThing} in the same file SomeUnusedThing is defined it could mask the fact that SomeUnusedThing is, well, unused.

@LukeAbby LukeAbby added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 23, 2025
@Josh-Cena Josh-Cena added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Feb 23, 2025
@bradzacher
Copy link
Member

We do not support JSDoc comments.

Duplicate of #9435, #8902, #5017, #6967, #7944, #8258

Please use the search.

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Mar 3, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants
0