daidodo / format-imports-vscode

Format imports and exports for JavaScript and TypeScript in VS Code.
https://marketplace.visualstudio.com/items?itemName=dozerg.tsimportsorter
MIT License
62 stars 5 forks source link

keep imports for commented code #88

Closed andrei-zgirvaci closed 1 year ago

andrei-zgirvaci commented 1 year ago

Thank you @daidodo for this plugin, it's amazing and saves me a lot of time!

Is your feature request related to a problem? Please describe. However, I'm always getting frustrated when the plugin removes my imports when I am commenting some code in order to test something (e.g a component). Then, I have to either undo my changes or import the components/libraries for the commented code again which is frustrating and time-consuming.

Describe the solution you'd like It would be nice if keepUnused had the option to keep the imports of commented code.

Describe alternatives you've considered For the moment, I turned off keepUnused because it was costing me more time to fix my code than the benefit of it.

daidodo commented 1 year ago

Duplicate to https://github.com/daidodo/format-imports-vscode/issues/62

daidodo commented 1 year ago

Thanks for the feedback!

The plugin uses TS compiler to find unused imports. It won't tell if a name is used or not in comments.

So the question becomes: when to remove an import if it's unused?

I don't have a good idea for now but am very happy to take suggestions.

andrei-zgirvaci commented 1 year ago

I am sorry that I opened a duplicate issue, honestly didn't see it in the search...

As @mxmzb mentioned in https://github.com/daidodo/format-imports-vscode/issues/62, I think a good approach, for now, will be to run the import formater on demand with a key combination...

I will close this issue now, thanks!