1.4.0 • Published 5 months ago

react-native-remove-console-logs v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

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-logs

Or, if you prefer Yarn:

yarn global add react-native-remove-console-logs

Usage

Basic Usage

Run the following command to remove console.log statements from the ./src directory:

remove-logs ./src

Dry Run Mode

To preview the changes without modifying any files, use the --dry-run flag:

remove-logs ./src --dry-run

Advanced 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=false

Ignore Specific Directories

Ignore specific directories (e.g., .git, dist, build):

remove-logs ./src --ignore-patterns .git,dist,build

Specify File Extensions

Process files with specific extensions (default: .js, .jsx, .ts, .tsx):

remove-logs ./src --extensions .js,.jsx

Options

OptionDescription
./srcThe target directory to clean (default: ./src).
--dry-runPreview changes without modifying files.
--skip-node-modulesSkip the node_modules directory (enabled by default).
--ignore-patternsComma-separated list of directories to ignore (e.g., .git,dist,build).
--extensionsComma-separated list of file extensions to process (default: .js,.jsx,.ts,.tsx).

Examples

Clean console.log Statements

remove-logs ./src

Dry Run Mode

remove-logs ./src --dry-run

Ignore Specific Directories

remove-logs ./src --ignore-patterns .git,dist,build

Process Specific File Extensions

remove-logs ./src --extensions .js,.jsx

License

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

Sunil Kumar


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: 12


Why 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, or build.
  • 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 ./src

Notes

  • 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.
1.4.0

5 months ago

1.2.0

5 months ago

1.1.0

5 months ago

1.0.0

5 months ago