I have some JavaScript files that should be linted assuming a Node environment and others that should be linted assuming a browser environment. How do I lint these files with different JSHint options? Here’s my starting point:
module.exports = function (grunt) {
grunt.initConfig({
lint: {
files: [
"grunt.js", // Node environment
"lib/**/*.js", // browser environment
],
},
jshint: {
options: {
browser: true, // define globals exposed by modern browsers?
es5: true, // code uses ECMAScript 5 features?
node: false, // define globals in Node runtime?
},
globals: {},
},
});
grunt.registerTask("default", "lint");
};
Actually, it’s pretty easy: https://github.com/gruntjs/grunt/blob/master/docs/task_lint.md#per-target-jshint-options-and-globals