A jslint for Node.js that actually gets updated.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
lib
.gitignore
.gitmodules
Makefile
README.markdown
package.json

README.markdown

node-jslint

A version of node-jslint that pulls from Crockford's JSLint every time you install it.

The options for node, strict, and es5, are selected by default.

/*jslint node: true, strict: true, es5: true */
/*global provide: true */

There's no reason to not be using "use strict"; in your node code.

Installation

Install with npm (always the latest version)

npm uninstall -g jslint-strict
npm install -g jslint-strict

Usage

CLI

jslint-strict ./examples/my-module.js

JSLint Options in your code

my-module.js:

/*global provide: true */
(function () {
  "use strict";
  /*jslint onevar: true, undef: true, newcap: true, nomen: true, regexp: true, plusplus: true, bitwise: true */

  function stringToInt() {
    /*jslint bitwise:false */
    return "hello" >> 0;
  }

  module.exports = stringToInt;
}());

JS

var jslint = require('jslint-strict')
  , fs = require('fs')
  , file = fs.readFileSync('/path/to/file')
  , options = { strict: true, es5: true, node: true };

jslint(file, options)

Note: There are no modifications to Crockford's JSLint when used this way. You must add the options yourself.

Rants

  • Don't ever actually use bit-shifting to convert strings to ints.
  • Use arr.forEach, not for (var i = 0; i < arr.length; i += 1)
  • Use Object.keys(obj).forEach, not for (var k in obj)

TODO

  • Strip #!/usr/bin/env node before linting
  • Use node's httpClient or abstract-http-request rather than curl
  • Be more generic and provide options for Browser, rhino, node