jslint-strict

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i jslint-strict

Weekly Downloads

0

Version

1.0.1

License

none

Last publish

Collaborators

  • coolaj86