codemod-clean
v2.2.1
Published
A codemod tool to clean up console and unused variables and unused imports in JavaScript code.
Maintainers
Readme
codemod-clean
A codemod tool that automatically removes console statements, unused variables, and unused imports in JavaScript, TypeScript, and Vue codebases.
Features
- 🧹 Remove console statements (console.log, console.error, etc.)
- 🗑️ Remove unused variables
- 📦 Remove unused imports
- 🎯 Supports JS / TS / Vue files
- 🔍 Dry-run mode for safe preview
- 📊 Structured report output (stylish / JSON)
Installation
npm install -g codemod-cleanOptions
| Option | Description | Default |
| ----------- | ------------------------------------------------- | ------- |
| --dry | Preview changes without modifying files (default) | true |
| --fix | Automatically apply fixes to the code | false |
| --json | Output results in JSON format | false |
| --stylish | Output human-readable report (default) | true |
Rules
--fixand--drycannot be used together.--jsonand--stylishcannot be used together.- Default behavior:
dry + stylish
Usage
codemod-clean run <path> [options]
# or use npx directly
npx codemod-clean run <path> [options]Examples
# Preview changes (safe mode)
codemod-clean run ./src
# Apply fixes
codemod-clean run ./src --fix
# JSON output
codemod-clean run ./src/index.js --json