Skip to content

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

Closed as duplicate of#9435
@LukeAbby

Description

@LukeAbby

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already existslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy