grunt-contrib-eslint
Grunt plugin for Eslint
Getting Started
If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
$ npm install --save-dev grunt-contrib-eslint
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks("grunt-contrib-eslint");
Documentation
See the grunt docs on how to configure tasks and more advanced usage.
Example
grunt.initConfig({
eslint: {
src: ["app.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default", ["eslint"]);
Example with custom config and rules
grunt.initConfig({
eslint: {
options: {
config: "conf/eslint.json",
rulesdir: ["conf/rules"]
},
src: ["app.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default", ["eslint"]);
Example with custom formatter
grunt.initConfig({
eslint: {
options: {
format: "./formatter/htmlTable"
},
src: ["app.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default", ["eslint"]);
Example with custom rules for node and browser files
grunt.config.init({
eslint: {
nodeFiles: {
src: ["server/**/*.js"],
options: {
config: "conf/eslint-node.json"
}
},
browserFiles: {
src: ["client/**/*.js"]
options: {
config: "conf/eslint-browser.json"
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default", ["eslint"]);
Example with silent option
grunt.initConfig({
eslint: {
options: {
format: "./formatter/htmlTable",
silent: true
},
src: ["app.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default", ["eslint"]);
Options
config
Type: path::String
rulesdir
Type: [path::String]
Default: built-in rules directory
format
Type: String
Default: 'stylish'
Name of a built-in formatter or path to a custom one.
silent
Type: Boolean
Whether the grunt task would fail on error or will it alwways pass irrespective of the results.
i.e. to supress the failure.
This option is not passed to the eslint api.
** More information about options: Eslint options