ehynds / grunt-remove-logging

Grunt.js task for removing console logging statements
MIT License
192 stars 33 forks source link

Common (enough?) inline semicolon usage to warrant a RegExp fix? #22

Open eckdanny opened 10 years ago

eckdanny commented 10 years ago

I too was getting burned with not semicolon matching ([^;]). Turns out there are a few things that the devs on my team like to do that cause problems with the RegExp matching solution which may or may not be representative of all users of the plugin.

I started a new issue because I wanted to provide some "feedback from the field" on #18 but the title didn't really capture my concerns. Thanks for this great plugin btw!

Getting cute with colored output:

console.log('%c Look at me!', 'background: #222; color: #bada55');

Inline commenting:

console.log('hello world'); // Logs a hello msg

I had a crack at mixing up the regex... (exploding by string delimiters and parens) but because braceless conditionals is also a big problem for us I think going down the path of #19 is best.

For now, I'm keeping grunt-remove-logging in place as it solves 95% of the console.log problems we have, and just using grep/manual methods to replace the rest. It'd be great if this was a single routine tho.

ehynds commented 10 years ago

Take a look at grunt-groundskeeper which uses esprima instead of a simple regex. It'll probably address these use cases.