1. grunt-eslint
Validate files with ESLint
grunt-eslint
Package: grunt-eslint
Created by: sindresorhus
Last modified: Thu, 11 Apr 2024 11:20:18 GMT
Version: 25.0.0
License: MIT
Downloads: 372,210
Repository: https://github.com/sindresorhus/grunt-eslint

Install

npm install grunt-eslint
yarn add grunt-eslint

grunt-eslint

Validate files with ESLint

Install

 npm install --save-dev grunt-eslint

Usage

 require('load-grunt-tasks')(grunt);

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

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

Examples

Custom config and rules

 const noAlertRule = require('./conf/rules/no-alert');

grunt.initConfig({
	eslint: {
		options: {
			overrideConfigFile: 'conf/eslint.js',
			plugins: {
				noAlertRule
			}
		},
		target: ['file.js']
	}
});

Custom formatter

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

Options

See the ESLint options.

In addition the following options are supported:

format

Type: string
Default: 'stylish'

The 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)

The nmber of warnings to trigger non-zero exit code.

failOnError

Type: boolean
Default: true

Fail the build if ESLint found any errors.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin