Powerful CLI for any lint (JSLint/JSHint +) solution.

npm install xlint
2 downloads in the last week
8 downloads in the last month

XLint – Powerful CLI for any lint solution


$ xlint [options] <linter> [<paths>]

for example:

$ xlint path/to/jslint.js project/path

Interested in live console?

$ xlint --watch path/to/jslint.js project/path


$ npm install -g xlint


  • cache bool - Whether to cache generated reports. Very useful if we rerun the script on large projects. Cached reports are saved into .lintcache file in your project main directory [default: true]
  • color bool - Colorize console output [default: true]
  • depth number - How deeply to recurse into subdirectories [default: Infinity]
  • ignoreRules string - Whether to obey rules found in ignore files (Currently just git for .giitignore rules is supported). It's backed by fs2.isIgnored [default: git]
  • stream bool - Whether to generate reports on the go (as soon as first filenames are obtained) [default: true]
  • watch bool - Output reports in live console which updates after code or configuration files are updated [default: false]

Ignoring specific files and directories

Apart of support for .gitignore rules, XLint also looks for rules in .lintignore files. Syntax rules for those files is same as for .gitignore files.

Configuration files

XLint supports external .lint configuration files, through which we may setup options that are passed to linter. There can be many.lint files placed in any directory within project

File format is similar to conf files as we know them from *nix systems:

# This is a comment, any of this are ignored by the parser

@root                     # Root of a project, means that any rules found in upper directories won't have effect

plusplus                  # Regular boolean option
indent 2                  # Numeric option
predef console, window    # Array of strings

./foo.js                  # Options that would only address foo.js file
!plusplus                 # Overridden boolean option (set to false)
predef+ XMLHttpRequest    # Add token to array option
predef- console           # Remove token from array option

./some-dir                # Options that address only files within given directory
predef foo, bar           # Override array option
otherarr one,             # Other array option, if we set just one token, we need to post-fix it with comma

JSHint case

XLint doesn't support options defined in jshintrc files.
JSHint separates global variable settings from other options, but in XLint configuration files, global should be defined same as other options (as e.g. predef for JSLint), it will be passed to JSHint as expected.

Support for other linters

Internal architecture of XLint is well modularized. Other linters can be handled by XLint, by introdiif report procesor module that translates output report into XLint supported format is provided:

// Custom linter handler

module.exports = function (src, options) {
    var rawReport, xlintReport
    rawReport = linter(src, options); // Get report from linter we want to use
    // Translate it into XLint friendly format, which is an array of warnings with it's meta data, e.g.:
    // xlintReport = [
    //   { line: 12, character: 43, message: 'Warning message' }
    //   { line: 16, character: 3, message: 'Other warning message' }
    // ];
    // If there are no errors, empty array should be returned
    // It's good to stamp our report with unique linter id (cache functionality distinguish linters by this):
    // xlintReport.xlintId = 'MYCUSTOM_LINTER@0.2';
    return xlintReport;

When we got that, we should just pass path to our module to xlint process

TODO (v0.1.1 milestone)

  • Possibility to lint using more than one linter with one process
  • Provide simple plain text based read/write stream, so it can be easily plugged into external tools
  • Fix live console for Windows

Tests Build Status

$ npm test
npm loves you