Bug: no-unused-vars should not be flagged on imports used in @link
etc.
#10873
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
Before You File a Bug Report Please Confirm You Have Done The Following...
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
ESLint Config
tsconfig
Expected Result
I expected no error because while the import is unused outside of
@link
s 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 fileSomeUnusedThing
is defined it could mask the fact thatSomeUnusedThing
is, well, unused.The text was updated successfully, but these errors were encountered: