A CLI tool to remove console.log statements from React Native projects.
npm install react-native-remove-console-logsA powerful CLI tool to remove console.log statements from your React Native projects. Keep your codebase clean and production-ready with ease!
To use the tool globally on your system, run:
``bash`
npm install -g react-native-remove-console-logs
Or, if you prefer Yarn:
`bash`
yarn global add react-native-remove-console-logs
---
Run the following command to remove console.log statements from the ./src directory:
`bash`
remove-logs ./src
To preview the changes without modifying any files, use the --dry-run flag:
`bash`
remove-logs ./src --dry-run
#### Skip node_modules
By default, the node_modules directory is skipped. You can explicitly enable or disable this behavior:
`bash`
remove-logs ./src --skip-node-modules=false
#### Ignore Specific Directories
Ignore specific directories (e.g., .git, dist, build):
`bash`
remove-logs ./src --ignore-patterns .git,dist,build
#### Specify File Extensions
Process files with specific extensions (default: .js, .jsx, .ts, .tsx):
`bash`
remove-logs ./src --extensions .js,.jsx
---
| 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). |
---
`bash`
remove-logs ./src
`bash`
remove-logs ./src --dry-run
`bash`
remove-logs ./src --ignore-patterns .git,dist,build
`bash`
remove-logs ./src --extensions .js,.jsx
---
This project is licensed under the MIT License. See the LICENSE file for details.
---
By default, the tool will modify your files to remove console.log statements. Use the --dry-run flag to preview changes without modifying files.
Yes! This tool works for any JavaScript or TypeScript project, not just React Native.
Use the --ignore-patterns option to specify directories to ignore (e.g., --ignore-patterns .git,dist,build).
By default, the tool processes .js, .jsx, .ts, and .tsx files. You can customize this using the --extensions option.
---
---
If you find this tool useful, consider giving it a ⭐️ on GitHub!
---
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: 12
`
---
---
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.
---
$3
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.
---
$3
This tool is highly customizable:
- Skip specific directories like node_modules, .git, dist, or build.
- Process only specific file extensions (e.g., .js, .jsx, .ts, .tsx).
- Use dry-run mode to preview changes without modifying files.---
$3
No complex setup or configuration is required. Just install the tool globally and run it with a single command:`bash
remove-logs ./src
`---
$3
- Always test your code after removing
console.log statements to ensure no critical functionality is affected.
- Use the --dry-run` flag to preview changes before applying them.