metalsmith-jslint
A JSLint plugin for Metalsmith.
Getting Started
If you haven't checked out Metalsmith before, head over to their
website and check out the documentation.
Installation
Metalsmith-jslint is available via npm. Simply install it and require it in your application.
npm install --save metalsmith-jslint
Usage
To use jslint inside your Metalsmith application, you just add the function to your build steps via
the use
method.
var Metalsmith = require('metalsmith'),
jslint = require('metalsmith-jslint');
Metalsmith(__dirname)
.use(jslint())
.build();
Notice that you need to actually invoke the function inside the .use
method. This is because you
can also pass options to JSLint to customize it!
Options
You can also pass a configuration object into the jslint
function to change it's behavior. A full
list of options is available below:
Metalsmith(__dirname)
.use(jslint({
failOnError: true
})
.build();
failOnError
Throw an exception if any lint is found. You can either have this halt your build process, or handle
the error more directly inside the Metalsmith's .build
callback.
Linter Options
The best way to control the linter settings for your project, is by adding a .jslintrc
file at the
root of your project. JSLint will automatically detect that file and parse the options when linting
your code.
For a list of options and command-line flags, check
JSLint.com.
Here is an example .jslintrc
file:
{
"color": true,
"indent": 2
}
You may also options via the command-line, when you run your Metalsmith file:
node --color --indent=2 ./build.js
Credits
Thanks to Segment.io for creating and open-sourcing
Metalsmith!
Also thanks to Reid Burke for his library,
node-jslint, on which this library is built.