
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
gruntfileGetting Started as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
```bash
$ 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:
```js
grunt.loadNpmTasks("grunt-contrib-eslint");
```
Documentation
See the grunt
docs on how to
configure tasks and more advanced usage.
Example
```js
grunt.initConfig({
eslint: {
src: ["app.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-eslint");
grunt.registerTask("default",
"eslint");
```
Example with custom config and rules
```js
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
```js
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
```js
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
```js
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