-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
📎 noUnusedImports should remove empty imports #3574
Comments
Is there a workaround for this? Perhaps another rule that would remove the empty imports? |
I think we can extend the behavior of this rule to remove such imports. What do you think? |
That sounds great to me! That would be amazing |
I would love to help ;-) |
Hi @h-a-n-a I already started a wider fix for several issues related to |
I don't think so because I only modified the rule implementation. |
Rule name
noUnusedImports
Playground link
https://codesandbox.io/p/devbox/biome-starter-cbs-rky6zq
Expected result
The fix for
noUnusedImports
should remove imports like:Context
A while ago, I noticed empty imports like above in in our codebase. I would expect Biome's
noUnusedImports
to remove this kind of imports, as the import is unused, and clearly not intended to be written that way.The interesting thing is, the empty imports are also caused by auto-fix of
noUnusedImports
. An unused import like this is successfully removed:But when there are one or more imports and all are unused, it generates an empty import.
This doesn't happen in CLI and only happens in IDE (VSCode). I noticed that when fixing this code, I can briefly see that code is converted to
import { A, } from 'module';
first. I think this happens because the fixer applies the fixes step-by-step as @Conaclos noted here.Note that
noUnusedImports
is known to cause some other related issues (#3383).Code of Conduct
The text was updated successfully, but these errors were encountered: