Reputation: 405
I am working on a React application with webpack, when I run 'npm start' it takes a long time to build, but if there are lint errors it will fail at the end of the build with 'Exit status 1' and I will need to fix the error and then run 'npm start'.
The errors are things like 'un-used var', 'line too long' etc. so they shouldn't stop the app from running, and it wastes my time to wait for it to build again.
I still want to see the lint errors, but how can I stop them from causing the build to Exit?
Upvotes: 4
Views: 4864
Reputation: 80
I am working with Create-React-App and had this issue. I had to manually install eslint-webpack-plugin. Link: https://github.com/webpack-contrib/eslint-webpack-plugin
And then, in node modules, react scripts, config, webpack.config.js file, I looked for the ESLintPlugin, and added as an option:
failOnError: false
. Please take a look at the screenshot.
Upvotes: 1
Reputation: 405
I found several solutions at https://github.com/eslint/eslint/issues/7933 such as
npm run lint -s
or
eslint .; exit 0
Upvotes: -2
Reputation: 489
If the lint error/warning causes the exit, you may want to update your eslint loader configuration according to this https://github.com/webpack-contrib/eslint-loader#errors-and-warning
A simple instruction:
1.Go to your Webpack configuration file.
Find a loader called 'eslint-loader', you may exepect something like this:
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
/* this is the eslint-loader option */
failOnWarning: true
}
}
]
2.In the options
filed under the eslint-loader. you may want to update this field to something like:
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
/* this is the eslint-loader option */
failOnWarning: false,
failOnError: false
}
}
]
In this case, though your eslint-loader find error/warnings. The building won't crash. (though this is not recommended)
Upvotes: 2