Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

This repository has been archived and is now read-only. Please contact one of the fluid-project maintainers if you’d like to request it be unarchived for further development. https://wiki.fluidproject.org/display/fluid/Get+Involved Validate files with ESLint

License

Notifications You must be signed in to change notification settings

fluid-project/fluid-grunt-eslint

 
 

Repository files navigation

This repository has been archived and is now read-only. Please contact one of the fluid-project maintainers if you’d like to request it be unarchived for further development. https://wiki.fluidproject.org/display/fluid/Get+Involved

grunt-eslint - Fluid Community Edition

This differs from the upstream version of grunt-eslint in that

  • It binds to fluid-eslint rather than ESLint, in order to include a fully working fix for issue 4931
  • It includes a fix for issue 19, outputting the number of linted files, which the grunt-eslint maintainer has refused a fix for

Validate files with ESLint

Install

$ npm install --save-dev grunt-eslint

Usage

require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

grunt.initConfig({
	eslint: {
		target: ['file.js']
	}
});

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

Examples

Custom config and rules

grunt.initConfig({
	eslint: {
		options: {
			configFile: 'conf/eslint.json',
			rulePaths: ['conf/rules']
		},
		target: ['file.js']
	}
});

Custom formatter

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

Two Common Configuration Needs

ESLint has [many configuration options available](ESLint options); two common ones that are sometimes gotchas:

Specifying valid globals in an individual Javascript file

This prevents ESLint from raising an error when a global expected to be included from another file (such as fluid or jqUnit) is not defined, as in this example error message:

 122:9   error  'fluid' is not defined  no-undef

Valid globals can be defined in comments at the top of an individual JS file:

/* global fluid, jqUnit */

Specifying node as the environment in an individual Javascript file

There are fulsome details on configuring the environment, but a common need is to specify that a file should be linted for a node environment. Again, this can be done in comments at the top of an individual JS file:

/* eslint-env node, mocha */

Options

See the ESLint options.

In addition the following options are supported:

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.

outputFile

Type: string
Default: ''

Output the report to a file.

quiet

Type: boolean
Default: false

Report errors only.

maxWarnings

Type: number
Default: -1 (means no limit)

Number of warnings to trigger non-zero exit code.

License

MIT © Sindre Sorhus

About

This repository has been archived and is now read-only. Please contact one of the fluid-project maintainers if you’d like to request it be unarchived for further development. https://wiki.fluidproject.org/display/fluid/Get+Involved Validate files with ESLint

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 100.0%