erikbrannstrom / grunt-eslint

Validate files with ESLint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

grunt-eslint Build Status Built with Grunt

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: require('eslint-stylish')

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

Some formatters you might find useful: eslint-stylish (see screenshot), eslint-json, eslint-tap.

License

MIT © Sindre Sorhus

About

Validate files with ESLint