-
-
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 removes any comments above the import #3401
Comments
This was an intended behavior introduced in 4f1e9cd Part of the reason of this behavior was to fix the unstable code actions that PR #2237 was trying to fix. However that fix turned out to be not complete and we may address it with another approach (#3383). So we can revert that change if the new approach turns out to work. Another reason is that some directive comments like But I agree that removing copyright/banner comments seems a little disruptive, especially for code actions that happen to the |
Interesting, perhaps a quick fix to this issue would be to mark the fix as "unsafe" if it would remove a comment, to encourage manual review. |
Yeah but that would be a breaking change so it won't be very quick. As a workaround, you can override the safety of the code actions: https://biomejs.dev/linter/#configure-the-rule-fix |
We could only remove leading comments that are not separated by a blank line from the import. // Comment to keep
- // Commnet to remove
- import { Unused } from "" |
Encountered this. We have comments like |
Environment information
Rule name
lint/correctness/noUnusedImport
Playground link
https://biomejs.dev/playground/?lintRules=all&importSortingEnabled=false&code=LwAqACAAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMgA0ACAAKgAvAAoACgBpAG0AcABvAHIAdAAgAHsAIAB0AGgAaQBuAGcAIAB9ACAAZgByAG8AbQAgACcAbQB5AHAAYQBjAGsAYQBnAGUAJwA7AA%3D%3D
Expected result
Click the console tab to view the suggested fix. It removes the copyright comment in addition to the import. I would expect it to leave any comments intact.
Code of Conduct
The text was updated successfully, but these errors were encountered: