Skip to content

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

Open
@kraenhansen

Description

@kraenhansen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions