Grunt task to find console.log statements

Get rid of all those console.log statements!

I've been working a lot on styleguides and coding style projects recently and one thing that really stuck out to me is a lack of tools to fix higher-level coding antipatterns. Committing console.log statements is frequently one of those antipatterns that slips through code reviews. So I created a Grunt plugin for preventing you from accidentally comitting a console.log statement into your project. This is particularly useful in node-based projects on the server side and AngularJS-based projects client-side. In node, console.log statements are evaluated synchronously and can severely affect an applications performance. In AngularJS-based projects, it's preferable to use angular's $log service instead of the console API so this plugin aids in keeping code style consistent.

Installation

Super easy with NPM:

npm install --save-dev grunt-console-log-test  

Usage

In your Grunt config just let it know which files you want to test. Make sure to exclude any vendor or node_modules files which you can't change yourself.

grunt.initConfig({  
  'console-log-test': {
    test: {
      src: [
        '**/*.{js,html}',
        '!node_modules/**/*'
      ]
    }
  }
});

Then just trigger it on the command line with grunt console-log-test or add it in a group of tests with the grunt.registerTask API.

Summary

I'm working on some really cool style and pattern stuff right now and looking forward to releasing more plugins like this as the opportunities roll in.

Clone the plugin at the github repo for grunt-console-log-test or just install it with NPM!