Skip to content
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

An equivalent rule for unused imported @typedef similar to no-unused-vars #1165

Open
leekahung opened this issue Oct 21, 2023 · 2 comments
Open

Comments

@leekahung
Copy link

Motivation

Hey everyone, been digging around the issues with regards to rules that relates to @typedef, but I don't see one so far or I might have missed it. If there is an issue already resolved or closed, would be happy to be linked to that. For now, I would like to open a feature request for the following.

At the moment, there's no way to check if an imported @typedef is no longer in use from existing rules in the plugin that's similar to an unused declared variable or unused library/package. ESLint does not produces no warnings or errors for @typedefs. Thus it up to the developer to manually spot and remove code that's no longer in use.

Current behavior

Currently, there are no warnings/errors for unused @typedefs from ESLint.

Desired behavior

With this new feature, it'll produce a warning or error for unused @typedefs from ESLint.

Alternatives considered

Creating a custom rule (no-unused-typedefs) specifically for @typedef

@leekahung
Copy link
Author

Oh, never mind. Looks like it's possible to import JSDoc typedefs now.

Screen Shot 2023-10-21 at 15 40 43

Sorry for the inconvinence, I'll close this issue.

@leekahung
Copy link
Author

leekahung commented Oct 22, 2023

Actually, it would seem like the problem would still persist if I were to import it instead with JavaScript since importing just JSDoc types wouldn't be supported.

For example, if I were to have:

// typedefs.js
/**
 * @exports foo
 * @typedef {object} foo
 * @property {string} bar
 */

exports.unused = {};

And import { foo } from "typedefs.js" in a different file to use it, the editor would pick it up, but would the browser would complain when starting a dev/production server since it's not exactly a "module" and you're not really importing "foo". The original idea from the description might still be better.

@leekahung leekahung reopened this Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant