Ignore or prevent ESLint errors from breaking the build in a React project (create-react-project)
If you want to force ESLint to always emit warnings (that will not stop you build) instead of errors, you need to set emitWarning: true
:
{ enforce: 'pre', include: paths.appSrc, test: /\.(js|jsx|mjs)$/, use: [{ loader: require.resolve('eslint-loader'), options: { formatter: eslintFormatter, eslintPath: require.resolve('eslint'), emitWarning: true, 👈 HERE }, }],},
Errors and Warning
By default the loader will auto adjust error reporting depending on eslint errors/warnings counts. You can still force this behavior by using
emitError
oremitWarning
options:
emitError
(default:false
)Loader will always return errors if this option is set to true.
emitWarning
(default:false
)Loader will always return warnings if option is set to
true
. If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error....
since eslint-loader
is now deprecated and eslint-webpack-plugin
is now used in create-react-app
check the docs, I was able to solve a similar issue by adding two option to the eslint-webpack-plugin
after ejecting your react app, add these options to the ESLintPlugin
options:
new ESLintPlugin({ // Plugin options extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'], formatter: require.resolve('react-dev-utils/eslintFormatter'), eslintPath: require.resolve('eslint'), context: paths.appSrc, failOnError: false, <== `This one` emitWarning: true, <== `And this one` // ESLint class options cwd: paths.appPath, resolvePluginsRelativeTo: __dirname, baseConfig: { extends: [require.resolve('eslint-config-react-app/base')], rules: { ...(!hasJsxRuntime && { 'react/react-in-jsx-scope': 'error' }) } } })