I've written before about how to use ESLint with Gulp. I'm using Gulp less and webpack and npm scripts more these days. Here's how I use ESLint with webpack:
module.exports = env => {
…
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
exclude: /(node_modules)/,
loader: "eslint-loader",
options: {
cache: false,
fix: false,
emitWarning: true,
emitError: true,
failOnWarning: true,
failOnError: true
}
},
…
Here, I'm using the eslint-loader to run ESLint rules. I'm using enforce: "pre"
to force running ESLint before other rules.
Inside the options
setting, you can pass in standard ESLint options combined with eslint-loader options, like emitError
and failOnError
, which will fail the build if there are any linting errors.