grunt-eslint

Validate files with ESLint - A tool for identifying and reporting on patterns in JavaScript

npm install grunt-eslint
200 downloads in the last day
1 371 downloads in the last week
4 361 downloads in the last month

grunt-eslint Build Status

Validate files with ESLint

screenshot

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-eslint

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-eslint');

Tip: the load-grunt-tasks module makes it easier to load multiple grunt tasks.

Documentation

See the grunt docs on how to configure tasks and more advanced usage.

Example

grunt.initConfig({
    eslint: {                    // task
        target: ['file.js']        // array of files
    }
});

grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);

Example with custom config and rules

grunt.initConfig({
    eslint: {                                // task
        options: {
            config: 'conf/eslint.json',        // custom config
            rulesdir: 'conf/rules'            // custom rules
        },
        target: ['file.js']                    // array of files
    }
});

grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);

Example with custom formatter

grunt.initConfig({
    eslint: {                                // task
        options: {
            format: require('eslint-tap')
        },
        target: ['file.js']                    // array of files
    }
});

grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);

Options

config

Type: String
Default: built-in eslint.json

Path to your ESLint config file (eslint.json).

rulesdir

Type: String
Default: built-in rules directory

Path to a directory with custom rules. Your custom rules will be used in addition to the built-in ones.

Recommended read: Working with Rules

format

Type: String
Default: 'stylish'

Name of a built-in formatter or path to a custom one.

Some formatters you might find useful: eslint-json, eslint-tap.

License

MIT © Sindre Sorhus

npm loves you