VS Code extension to remove unused ES6 imports inside JavaScript and TypeScript files (.js
, .jsx
, .ts
and .tsx
extensions) without changing the current order, as opposed to the built-in VS Code "Organize Imports" functionality.
- Open the Command Palette (
Ctrl/Cmd + Shift + P
) - Search for Remove Unused Imports
The command can be executed every time a file is saved via Code Actions. To enable it, set source.removeUnusedImports
to true
inside editor.codeActionsOnSave
in your VSCode settings:
"editor.codeActionsOnSave": {
"source.removeUnusedImports": true
}
This extension does not provide any keybinding for the command. You can assign your own custom keybinding for it by pressing the cog icon that appears to the right of the command name in the Command Palette.
The format of the document may change after running this command. For instance, final semicolons are added to the modified imports.
This extension is inspired by vsc-sort-imports.
This project is licensed under the MIT License.