8000 Enhancement: [no-unused-vars] False-positive when referencing imported value in a TSDoc · Issue #5017 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Enhancement: [no-unused-vars] False-positive when referencing imported value in a TSDoc #5017

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
4 tasks done
anton-johansson opened this issue May 19, 2022 · 5 comments
Closed
4 tasks done
Labels
external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on

Comments

@anton-johansson
Copy link

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/no-unused-vars

Description

I propose that the rule should not give a warning if the imported type is being referenced in a TSDoc. It's very useful, specially in combination with @deprecated Use {@link myOtherType} instead..

Fail

import myNotDeprecatedFunction from "./other-file.ts";

/**
 * @deprecated Use myNotDeprecatedFunction instead.
 */
export const myDeprecatedFunction = () => {
    console.log("Hello world");
};

Pass

import myNotDeprecatedFunction from "./other-file.ts";

/**
 * @deprecated Use {@link myNotDeprecatedFunction} instead.
 */
export const myDeprecatedFunction = () => {
    console.log("Hello world");
};

Additional Info

TypeScript has a similar check, and I've created a similar issue for that too:
microsoft/TypeScript#49173

@anton-johansson anton-johansson added enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 19, 2022
@Josh-Cena
Copy link
Member

I've already created an FR here: gajus/eslint-plugin-jsdoc#858

I think this belongs better to JSDoc because AFAIK TS-ESLint never handles JSDoc.

@anton-johansson
Copy link
Author

I've already created an FR here: gajus/eslint-plugin-jsdoc#858

I think this belongs better to JSDoc because AFAIK TS-ESLint never handles JSDoc.

Cool, thanks for that link! I'm not sure where it best belongs, I'm assuming the rule in this project needs to be tweaked as well?

@Josh-Cena
Copy link
Member

If that one got implemented as I proposed—no. markVariableAsUsed will propagate to every other plugin. This is also how eslint-plugin-vue is able to mark variables used in the template as used, IIRC.

@anton-johansson
Copy link
Author

If that one got implemented as I proposed—no. markVariableAsUsed will propagate to every other plugin. This is also how eslint-plugin-vue is able to mark variables used in the template as used, IIRC.

Aha, I understand. That's great, I think we can close this issue then.

@bradzacher
Copy link
Member

Yup - we do not support code within JSDoc comments because it is not real code.

Josh is correct. Any other plugin can mark a variable as used if it desires and our rule will respect it.

@bradzacher bradzacher added external This issue is with another package, not typescript-eslint itself wontfix This will not be worked on and removed triage Waiting for team members to take a look enhancement: plugin rule option New rule option for an existing eslint-plugin rule labels May 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants
0