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

[import/no-unused-modules] Add an option to ignore typescript types #2694

Open
demedos opened this issue Jan 25, 2023 · 5 comments · May be fixed by #3011
Open

[import/no-unused-modules] Add an option to ignore typescript types #2694

demedos opened this issue Jan 25, 2023 · 5 comments · May be fixed by #3011

Comments

@demedos
Copy link

demedos commented Jan 25, 2023

Hi, when using typescript it might be useful to add an option to ignore exported but unused types (including interfaces and enumerators) since it is common to export a component along with its props and let the consumer create derivative types for example.

This is something that has been implemented in ts-unused-exports via the allowUnusedEnums and allowUnusedTypes options.

Looking through the code I found out that typescript types are being handled already, see src/rules/no-unused-modules.js#L89.

@ljharb
Copy link
Member

ljharb commented Jan 25, 2023

Is this something that @typescript-eslint/plugin might already cover?

@demedos demedos changed the title Allow TypeScript declarations option [import/no-unused-modules] Add an option to ignore typescript types Jan 26, 2023
@demedos
Copy link
Author

demedos commented Jan 26, 2023

Nope, there's nothing such as unused exports

@ciiqr
Copy link

ciiqr commented Feb 21, 2023

Might be a bit more effort than just ignoring types entirely, but it would be cool if this could mark types referenced from used exports as used (ie. in the component/props example, the props type could be marked as used if the component itself is used). Might still want an option to enable this, though it seems like it would allow us to preserve some of the safety of this rule.

@silverwind
Copy link
Contributor

silverwind commented May 24, 2024

I think adding a unusedTypeExports to no-unused-modules which defaults to true should be able to solve it, at least for me.

silverwind added a commit to silverwind/eslint-plugin-import that referenced this issue May 28, 2024
@silverwind
Copy link
Contributor

#3011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants