microsoft / microsoft/tsdoc

`eslint-plugin-tsdoc`: Rule to mark types referenced through `{@link}` and `{@inheritDoc}` as used

Open
#348 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5k
Forks
162
Avg merge
17h 24m
Merged PRs (30d)
8

Description

When writing tsdoc strings, it's powerful to be able to reference types from an inline link tag.
It would however be great if the eslint plugin would mark these as used and avoid the @typescript-eslint/no-unused-vars rule reporting types that are only referenced from tsdoc comments as unused.

As an example, the following code

class MyClass {}
/** This comment reference {@link MyClass} but it's still "never used" */
const foo = null;

yields

  1:7  warning  'MyClass' is defined but never used       @typescript-eslint/no-unused-vars
  3:7  warning  'foo' is assigned a value but never used  @typescript-eslint/no-unused-vars

and I would love for that first line to go away.

This is already supported for plain (non inline tags) by the jsdoc plugin, through the use of the eslint SourceCode#markVariableAsUsed API, but it doesn't yet support inline tags and it would be great to have this supported in the eslint-plugin-tsdoc directly.

I'd be interested in submitting a PR for this, if this is interesting for the maintainers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in eslint-plugin-tsdoc's handling of inline {@link} and {@inheritDoc} tags, using the referenced SourceCode#markVariableAsUsed API as the integration point. Done means types referenced only through those tags no longer trigger @typescript-eslint/no-unused-vars, while unrelated unused variables such as foo still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
documentation, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.