https://github.com/kcmr/vsce-remove-unused-imports
VS Code extension to remove unused ES6 imports inside JavaScript and TypeScript files
https://github.com/kcmr/vsce-remove-unused-imports
vscode-extension
Last synced: 3 days ago
JSON representation
VS Code extension to remove unused ES6 imports inside JavaScript and TypeScript files
- Host: GitHub
- URL: https://github.com/kcmr/vsce-remove-unused-imports
- Owner: kcmr
- License: mit
- Created: 2021-08-13T11:09:14.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-09T12:45:21.000Z (5 months ago)
- Last Synced: 2025-04-28T15:50:13.249Z (3 months ago)
- Topics: vscode-extension
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=kuscamara.remove-unused-imports
- Size: 5.27 MB
- Stars: 17
- Watchers: 2
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Remove Unused Imports
## Description
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.

## Usage
- **Open the Command Palette** (`Ctrl/Cmd + Shift + P`)
- Search for **Remove Unused Imports**### Run on save
The command can be executed every time a file is saved via Code Actions. To enable it, set `source.removeUnusedImports` to `always`, `explicit` or `never` inside `editor.codeActionsOnSave` in your VSCode settings:
```json
"editor.codeActionsOnSave": {
"source.removeUnusedImports": "explicit" // "always", "never"
}
```### Preserve specified import identifiers
The extension also supports preserving specified import identifiers, even if they are not used. To enable it, set `removeUnusedImports.preserve` to an array of import identifiers in your VSCode settings:
```json
"removeUnusedImports.preserve": ["React", "ReactDOM"]
```### Keybinding
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.
## Known issues
The format of the document may change after running this command. For instance, final semicolons are added to the modified imports.
## Acknowledgments
This extension is inspired by [vsc-sort-imports](https://github.com/amatiasq/vsc-sort-imports).
## Support me
## License
This project is licensed under the [MIT License](LICENSE).