racker/nodelint

Name: nodelint

Owner: racker

Description: Run JSLint from the command line under NodeJS

Created: 2012-01-13 21:49:34.0

Updated: 2013-01-05 20:31:44.0

Pushed: 2016-06-18 02:26:59.0

Homepage:

Size: 247

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

nodelint
installation

npm:

$ npm install nodelint

If you clone nodelint from Github, you should init JSLint submodule:

$ git submodule update --init
usage

You can use nodelint directly if you have node in your $PATH, or if you installed it using npm -g:

$ nodelint path/to/your/file.js

Otherwise, you need to run it with node:

$ node path/to/nodelint path/to/your/file.js

You can also specify a directory param and nodelint will find all .js files under that directory and its subdirectories:

$ node path/to/nodelint dir1/ dir2/

Enjoy!

configuration

You can override default JSLint options by passing config file with the optional --config parameter:

$ nodelint file1 file2 dir1 dir2 --config path/to/your/config/file.js

For example, if the default config.js has:

var options = {
    adsafe       : false,
    bitwise      : true,
    ...
    error_prefix : "\u001b[1m",
    error_suffix : ":\u001b[0m "
};

And your own path/to/your/config/file.js looks like:

var options = {
    bitwise      : false,
    browser      : false
};

Then the final options used will be:

var options = {
    adsafe       : false,
    bitwise      : false,
    browser      : false,
    ...
    error_prefix : "\u001b[1m",
    error_suffix : ":\u001b[0m "
};

Take a look at JSLint's options to see what to put in the options variable.

You can also add your configuration inside the JS files itself: JSLint will use this one instead of the global one.

Simply add some comments at the beginning of the file. Note that there is no space between / and global and between / and jslint:

// define your global objects:
/*global YUI, JQuery */

// define your jslint-options:
/*jslint white: true, onevar: true, undef: true, nomen: true */
reporters

By default nodelint uses an internal reporter function to output it's results to the console. For basic use it's possible to alter the error_prefix and error_suffix colors within your config.js file. This will prepend or append coloring information to the results when JSLint complains about your code. There may be times when a more customizable reporting system might be needed (i.e. IDE/Text Editor integrations or customized console outputs).

nodelint allows you to designate a custom reporter for outputting the results from JSLint's run. This reporter function will override the default function built into nodelint. To utilize a custom reporter first create a js file that has a function in it named reporter:

example-reporter.js:

var util = require('util');

function reporter(results) {
    var len = results.length;
    util.puts(len + ' error' + ((len === 1) ? '' : 's'));
}

Then when you run nodelint from the command line, pass in the customized reporter:

$ ./nodelint path/to/file.js --reporter path/to/file/example-reporter.js

For brevity sake, this is a fairly simple reporter.

Nodelint includes some build-in reportes for VIM, Textmate and JetBrains IDEA integration.

Also it include XML reporter, that produces reports which can also be integrated with a Continuous Integration server like Hudson using the Violations Plugin.

Please see the [wiki][wiki] for integration with various editors.

contribute

To contribute any patches, simply fork this repository using GitHub and send a pull request to me «http://github.com/tav». Thanks!

credits

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.