vibecleaner-cli
v1.0.1
Published
Safe, AST-based comment remover for JS, TS, JSX, and JSON
Downloads
14
Maintainers
Readme
VibeCleaner CLI 🧹
VibeCleaner is a powerful, safe, and AST-based command-line tool designed to strip comments from your JavaScript, TypeScript, JSX, and JSON files.
Unlike simple regex-based tools that often break your code by accidentally deleting parts of strings or regular expressions (e.g., https://...), VibeCleaner understands your code structure using Abstract Syntax Trees (AST).
🚀 Features
- AST-Based Parsing: Uses Babel to parse code into a tree structure. It only targets actual comment nodes.
- Safe by Design: Never touches strings, template literals, or regex patterns containing
//or/*. - Multi-Language Support: Works out-of-the-box with
.js,.ts,.jsx,.tsx, and.json. - Dry Run Mode: Preview how many comments will be removed without actually modifying any files.
- Glob Support: Easily target specific folders or file patterns.
- Statistics: Provides a detailed summary of removed comments and affected files.
📦 Installation
You can run it directly using npx:
npx vibecleaner-cli "src/**/*.ts"Or install it globally:
npm install -g vibecleaner-cli🛠 Usage
Basic Usage
Clean all files in the src directory:
vibecleaner "src/**/*.{js,ts,tsx}"Dry Run
See what would happen without making any changes:
vibecleaner "src/**/*.ts" --dryCustom Ignore Patterns
Ignore specific directories (default is node_modules and dist):
vibecleaner "**/*.js" --ignore "legacy/**" "tests/**"🛡 Why AST instead of Regex?
Most comment removers use Regular Expressions. Here is why that's dangerous:
❌ Regex Approach (Dangerous):
const url = "https://google.com"; // This might get broken
const regex = /\/\//; // This definitely gets broken✅ VibeCleaner (Safe):
Because VibeCleaner uses @babel/parser, it knows that "https://google.com" is a StringLiteral and /\/\// is a RegExpLiteral. It only touches CommentLine and CommentBlock nodes.
💡 Pro Tip: Prettier Integration
VibeCleaner tries to maintain your line count using retainLines: true. However, removing comments often leaves behind empty lines or slightly shifted formatting.
For the best "Vibe", we recommend running Prettier after cleaning:
vibecleaner "src/**/*.ts" && npx prettier --write "src/**/*.ts"📋 Commands & Options
| Option | Description | Default |
| :---------- | :----------------------------------- | :--------------------------- |
| patterns | Glob patterns for files to process | **/*.{js,ts,jsx,tsx,json} |
| --dry | Show summary without modifying files | false |
| --ignore | Patterns to exclude from search | node_modules/**, dist/** |
| --version | Show version number | - |
| --help | Show help | - |
📄 License
MIT © Steven Selcuk
Contributing
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
