The Unused extension for Visual Studio Code is a powerful tool designed to help developers maintain clean and efficient codebases. It specializes in identifying and removing unused code within TypeScript and JavaScript projects. This includes detecting unused files, unused exports, and commented-out code blocks that can clutter your project and potentially lead to confusion or maintenance issues.
Simply open the 'Unused' panel from the Activity Bar in VS Code. Click the refresh button to analyze your workspace. Results are presented in a tree view, allowing you to click on any item to navigate directly to the relevant line in your code. You can also analyze specific folders by right-clicking on them in the Explorer.
All settings are accessible under unused.* in VS Code Settings. You can configure include and ignore patterns for analysis, as well as enable or disable specific rules for detecting unused files, unused exports, and commented-out code.
The extension recognizes various import styles, including ES Module static and dynamic imports, CommonJS require, and re-exports. It also understands framework conventions for entry points (e.g., Next.js, Remix) and automatically resolves path aliases defined in your tsconfig.json.
Analysis is scoped to the open workspace. Decorator-based usage and cross-package analysis in monorepos are not yet supported. Dynamic require(variable) calls may not be resolved.
Built with