sweep-unused
A CLI tool that analyzes your codebase for unused dependencies and automatically removes them. Ideal for keeping package.json and node_modules clutter-free.
Features
- Code Analysis: Uses depcheck to find unused imports
- Two Modes:
- Interactive: Prompts for confirmation before removing
- Auto: Removes dependencies without asking
- Local or CI usage: Can be run in a pre-install hook or as part of a CI pipeline
Installation
Install globally using npm:
npm install -g sweep-unused
Usage
Run sweep-unused from any project directory:
Interactive Mode
sweep-unused
This scans your project for unused dependencies, lists them, and asks if you want to remove them.
Auto Mode
sweep-unused --auto
No prompt; it immediately removes all detected unused dependencies.
Package Scripts
Add a script in your package.json:
{
"scripts": {
"sweep": "sweep-unused --auto"
}
}
Then run:
npm run sweep
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on our GitHub repository:
https://github.com/sohei1l/sweep-unused
License
MIT