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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
8000 4 tasks done
ej612 opened this issue Jun 26, 2024 · 1 comment
Closed
4 tasks done
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

Comments

@ej612
Copy link
ej612 commented Jun 26, 2024

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.

@ej612 ej612 added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jun 26, 2024
@bradzacher
Copy link
Member

Duplicate of #8902, #5017, #6967, #7944, #8258

Please use the search.

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Jun 26, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jul 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2024
@Josh-Cena Josh-Cena marked this as a duplicate of #10873 Feb 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

2 participants
0