
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
grunt-eslint
Advanced tools
grunt-eslint is a Grunt plugin for running ESLint, a tool for identifying and fixing problems in JavaScript code. It allows developers to integrate ESLint into their Grunt-based build processes, enabling automated linting of JavaScript files.
Linting JavaScript files
This feature allows you to lint JavaScript files using ESLint through Grunt. The code sample demonstrates how to configure grunt-eslint to lint all JavaScript files in the 'src' directory and its subdirectories.
module.exports = function(grunt) {
grunt.initConfig({
eslint: {
target: ['src/**/*.js']
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);
};
Custom ESLint configuration
This feature allows you to specify a custom ESLint configuration file. The code sample shows how to use a specific '.eslintrc.json' file for linting configuration.
module.exports = function(grunt) {
grunt.initConfig({
eslint: {
options: {
configFile: '.eslintrc.json'
},
target: ['src/**/*.js']
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);
};
Fixing linting errors automatically
This feature enables automatic fixing of linting errors where possible. The code sample demonstrates how to configure grunt-eslint to automatically fix issues in the JavaScript files.
module.exports = function(grunt) {
grunt.initConfig({
eslint: {
options: {
fix: true
},
target: ['src/**/*.js']
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);
};
ESLint is the core tool for linting JavaScript code. It can be used independently of Grunt and provides a command-line interface for linting. While grunt-eslint integrates ESLint into Grunt workflows, ESLint itself is more flexible and can be used in various environments, including direct integration into editors and other build tools.
gulp-eslint is a similar tool to grunt-eslint but is designed for use with Gulp, another JavaScript task runner. It provides similar functionality for integrating ESLint into Gulp-based build processes, offering an alternative for developers who prefer Gulp over Grunt.
eslint-loader is a loader for Webpack that allows ESLint to be run as part of the Webpack build process. It is similar to grunt-eslint in that it integrates ESLint into a build tool, but it is specific to Webpack, providing linting capabilities during the module bundling process.
Validate files with ESLint
npm install --save-dev grunt-eslint
require('load-grunt-tasks')(grunt);
grunt.initConfig({
eslint: {
target: ['file.js']
}
});
grunt.registerTask('default', ['eslint']);
const noAlertRule = require('./conf/rules/no-alert');
grunt.initConfig({
eslint: {
options: {
overrideConfigFile: 'conf/eslint.js',
plugins: {
noAlertRule
}
},
target: ['file.js']
}
});
grunt.initConfig({
eslint: {
options: {
format: './node_modules/eslint-tap/index.js'
},
target: ['file.js']
}
});
See the ESLint options.
In addition the following options are supported:
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.
Type: string
Default: ''
Output the report to a file.
Type: boolean
Default: false
Report errors only.
Type: number
Default: -1
(Means no limit)
The nmber of warnings to trigger non-zero exit code.
Type: boolean
Default: true
Fail the build if ESLint found any errors.
FAQs
Validate files with ESLint
The npm package grunt-eslint receives a total of 164,096 weekly downloads. As such, grunt-eslint popularity was classified as popular.
We found that grunt-eslint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.