How do you use JSHint and Browserify together?

browserify, javascript, jshint

Solution

As of version 2.5.3 JSHint supports the `browserify` flag.

Like all flags you can use it directly in a source file:

/*jshint browserify: true */
// browserify code here

Or add it to a `.jshintrc` file:

{
   "browserify": true
}

Problem

I'm attempting to build a project using Angular and Browserify. My `controllers.js` file looks like this... ``` 'use strict'; module.exports.testController = function($scope){ $scope.message = 'Controller 1'; console.log( 'hello' ); }; ``` As you may expect, that generates three linting errors. - Use the function form of Strict - 'module' is not defined - 'console' is not defined I did find a bit of a solution here that enables JSHint to process Node.js files by putting `jslint node: true` at the top of the file like this ``` /*jslint node: true */ 'use strict'; module.exports.testController = function($scope){ $scope.message = 'Controller 1'; console.log( 'hello' ); }; ``` However, that obviously fixes too much; 'console.log(...)' should still be undefined. Does anyone know how to use JSHint with Browserify?

Original source