8000 `@typescript-eslint/no-unused-vars` Complains when import is only used in jsdoc · Issue #9435 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
@typescript-eslint/no-unused-vars Complains when import is only used in jsdoc #9435
Closed as not planned
@ej612

Description

@ej612

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.

Repro Code

Hi there!

I have the following code:

/**
 * Bla bla {@link MyClass}
 */
export interface MyInterface {
}

I want my jsdoc to include a reference to the class in question, which means I have to import it:

import type { MyClass } from './MyClass';

/**
 * Bla bla {@link MyClass}
 */
export interface MyInterface {
}

This works, meaning the link is now properly resolved. Also, tsc understands that I'm using the import and doesn't complain. If I remove the link but keep the import, I get the following error (as expected):

'MyClass' is declared but its value is never read. ts(6133)

So everything's fine on the tsc front. However, no-unused-vars doesn't realize I'm using the import in a jsdoc comment, and complains:

'MyClass' is defined but never used. eslint(@typescript-eslint/no-unused-vars)

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': ['error', {
        args: 'after-used',
        argsIgnorePattern: '^_',
        destructuredArrayIgnorePattern: '^_'
    }],
  },
};

Expected Result

I would expect no-unused-vars to realize that I'm using the import - albeit only in a jsdoc comment - like tsc does.

Actual Result

no-unused-vars sees that I'm not using the import in the code and complains.

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

      0