grunt-jslint
Validates JavaScript files with JSLint as a grunt task.
Installation
Install this grunt plugin next to your project's Gruntfile with: npm install grunt-jslint
Then add this line to your project's gruntfile:
grunt.loadNpmTasks('grunt-jslint');
Documentation
A multi-task to validate your JavaScript files with JSLint.
Supports the following options:
- files An array of files or wildcards which you want to be validated by JSLint
- exclude An array of files or wildcards which you do not want to be validated by JSLint
- directives Configuration options/settings to pre-define in JSLint. Pre-defined globals are included within this object as
predef: ['myglobal']
- options
- errorsOnly A Boolean option which tells the plugin to only display errors when set to
true
- log A String/filepath option which, when provided, tells the plugin where to write a verbose log to
- junit A String/filepath option which, when provided, tells the plugin where to write a JUnit-style XML file to
- failOnError A Boolean option - defaults to
true
; when set to false
, grunt will not fail if JSLint detects an error - checkstyle A String/filepath option which, when provided, tells the plugin where to write a CheckStyle-XML file to
- shebang Ignore shebang lines (
#!/usr/bin/whatever
) from files
Example Usage
module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('grunt-jslint');
grunt.initConfig({
jslint: {
server: {
src: [
'server/lib/*.js',
'server/routes/*.js',
'server/*.js',
'server/test/*.js'
],
exclude: [
'server/config.js'
],
directives: {
node: true,
todo: true
},
options: {
junit: 'out/server-junit.xml',
log: 'out/server-lint.log',
jslintXml: 'out/server-jslint.xml',
errorsOnly: true,
failOnError: false,
checkstyle: 'out/server-checkstyle.xml'
}
},
client: {
src: [
'client/**/*.js'
],
directives: {
browser: true,
predef: [
'jQuery'
]
},
options: {
junit: 'out/client-junit.xml'
}
}
}
});
grunt.registerTask('default', 'jslint');
};
Contributing
All files should be validated with JSLint. Bug fixes and/or new features must be accompanied by a passing test. Tests are written with vows.
Validating coding style
Run grunt jslint
in the root of your repository.
Running the tests
Run make test
in the root of your repository.
License
Copyright (c) 2013 Stephen Mathieson
Licensed under the WTFPL license.