Skip to content

Instantly share code, notes, and snippets.

@voxpelli
Created June 25, 2014 13:32
Show Gist options
  • Save voxpelli/9357ace4e0ff2b89f05c to your computer and use it in GitHub Desktop.
Save voxpelli/9357ace4e0ff2b89f05c to your computer and use it in GitHub Desktop.
My initial take on a JSHint .jshintrc config

If it is mainly a Node.js project that should be linted, then I would switch the "browser" setting for a "node" setting, but no matter if the default is that the javascript files are meant for a Node.js environment or a browser environment one can always override it in a specific file by adding the JSLint-compatible settings:

/*jslint node: true */

Or:

/*jslint browser: true */

The first one I would eg. add to the Gruntfile.js of an otherwise browser only setup so that I can ensure that also the Gruntfile conforms to the correct coding style.

Another good thing one can add to a file is:

/*global jQuery: true, foobar: true */

That tells JSHint (and JSLint) that those globals are available and that it shouldn't complain of them being undefined. A good way to explicitly point out the expected globals from other files at the top of a JS-file.

{
"bitwise": true,
"camelcase": false,
"freeze": true,
"indent": 2,
"noempty": true,
"nonbsp": true,
"nonew": true,
"unused": true,
"strict": true,
"trailing": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"undef": true,
"browser": true,
"laxcomma": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment