Closed regalstreak closed 1 year ago
This plugin currently does not look at any of the code other than imports, so determining whether imports are used would be a big change. I won't immediately say "no" right now, but it would require a lot of upvotes on this request for me to seriously consider it, I'm afraid.
In the meantime, maybe there is an ESLint plugin or custom that can remove unused imports?
We use eslint
to detect unused code, and I found this plugin: https://www.npmjs.com/package/eslint-plugin-unused-imports — it has an auto-fix too! Maybe that will work for your needs?
I concur with @IanVS that I don’t think it’s appropriate behavior for this prettier-plugin. IDEs often call prettier every time they auto-save, and it would be irritating if you add an import, and then scroll down to the function where you want to use the import, and the IDE chooses to save then, and the import has already vanished before you can start using it!
https://www.npmjs.com/package/prettier-plugin-organize-imports already does this (through the typescript language service) but can't sort imports like we can as with the trivago plugin.
I get that it's a 'prettier' plugin and this action might probably change the AST, but it could be opt-in and be a major differentiator from the trivago one