If I’ve install JSLint through NPM globally, is there a way to disable certain rules either within the current scope of my application or globally on my system?
The main issue is the dangling underscore problem. I mean, the main place this comes up is in node.js when i use __dirname, but I am sure it will come up for underscorejs as well. I’ve ignored it with a jslint directive, but I think it is a little annoying to need to do that on every file I use underscore.
For that matter do I need to place ‘use strict’; at the top of every single file?
Consider using a build tool for lint configuration and automation. When your project grows, you will need one anyway.
For node.js projects, I recommend using grunt. Install grunt into your project:
Grunt has a built-in task for lint (https://github.com/cowboy/grunt/blob/master/docs/task_lint.md).
Now create a
grunt.jsfile and configure linting there:Note how you can add easily multiple files and file patterns and apply options globally to all of these.
Now you can just run grunt by invoking:
Note that if you use jshint,
nomenis off by default (http://www.jshint.com/options/).