react-native-remove-console-logs
v1.4.0
Published
A CLI tool to remove console.log statements from React Native projects.
Maintainers
Readme
React Native Remove Console Logs 🧹
A powerful CLI tool to remove console.log statements from your React Native projects. Keep your codebase clean and production-ready with ease!
Install Globally
To use the tool globally on your system, run:
npm install -g react-native-remove-console-logsOr, if you prefer Yarn:
yarn global add react-native-remove-console-logsUsage
Basic Usage
Run the following command to remove console.log statements from the ./src directory:
remove-logs ./srcDry Run Mode
To preview the changes without modifying any files, use the --dry-run flag:
remove-logs ./src --dry-runAdvanced Usage
Skip node_modules
By default, the node_modules directory is skipped. You can explicitly enable or disable this behavior:
remove-logs ./src --skip-node-modules=falseIgnore Specific Directories
Ignore specific directories (e.g., .git, dist, build):
remove-logs ./src --ignore-patterns .git,dist,buildSpecify File Extensions
Process files with specific extensions (default: .js, .jsx, .ts, .tsx):
remove-logs ./src --extensions .js,.jsxOptions
| Option | Description |
|-------------------------|-----------------------------------------------------------------------------|
| ./src | The target directory to clean (default: ./src). |
| --dry-run | Preview changes without modifying files. |
| --skip-node-modules | Skip the node_modules directory (enabled by default). |
| --ignore-patterns | Comma-separated list of directories to ignore (e.g., .git,dist,build). |
| --extensions | Comma-separated list of file extensions to process (default: .js,.jsx,.ts,.tsx). |
Examples
Clean console.log Statements
remove-logs ./srcDry Run Mode
remove-logs ./src --dry-runIgnore Specific Directories
remove-logs ./src --ignore-patterns .git,dist,buildProcess Specific File Extensions
remove-logs ./src --extensions .js,.jsxLicense
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
1. Will this tool modify my files?
By default, the tool will modify your files to remove console.log statements. Use the --dry-run flag to preview changes without modifying files.
2. Can I use this tool for non-React Native projects?
Yes! This tool works for any JavaScript or TypeScript project, not just React Native.
3. How do I skip specific directories?
Use the --ignore-patterns option to specify directories to ignore (e.g., --ignore-patterns .git,dist,build).
4. What file extensions are supported?
By default, the tool processes .js, .jsx, .ts, and .tsx files. You can customize this using the --extensions option.
Author
Support
If you find this tool useful, consider giving it a ⭐️ on GitHub!
Example Output
When you run the tool, you’ll see output like this:
Cleaning console.log statements in ./src...
Cleaned ./src/App.js
Cleaned ./src/components/Header.js
Cleaning complete!
Files processed: 5
Console.log statements removed: 12Why Use This Tool?
🚀 Prepare for Production
Before deploying your app, it’s essential to remove unnecessary console.log statements. These statements can:
- Expose sensitive information in production logs.
- Slow down your app by clogging up the JavaScript thread.
- Make debugging harder by polluting the console with irrelevant logs.
This tool helps you clean up your codebase quickly and efficiently.
🧼 Clean Code
console.log statements are great for debugging during development, but they have no place in production code. Leaving them in can:
- Make your code look unprofessional.
- Confuse other developers who might think the logs are intentional.
- Increase the size of your bundle unnecessarily.
This tool ensures your code is clean, professional, and ready for production.
⚙️ Customizable
This tool is highly customizable:
- Skip specific directories like
node_modules,.git,dist, orbuild. - Process only specific file extensions (e.g.,
.js,.jsx,.ts,.tsx). - Use dry-run mode to preview changes without modifying files.
📦 Easy to Use
No complex setup or configuration is required. Just install the tool globally and run it with a single command:
remove-logs ./srcNotes
- Always test your code after removing
console.logstatements to ensure no critical functionality is affected. - Use the
--dry-runflag to preview changes before applying them.
