Skip to content

Commit 7e2983e

Browse files
committed
Add opt-out for eslint-webpack-plugin
1 parent 9b08e3c commit 7e2983e

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

docusaurus/docs/advanced-configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ You can adjust various development and production settings by setting environmen
2626
| IMAGE_INLINE_SIZE_LIMIT | 🚫 Ignored | ✅ Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to 0 will disable the inlining of images. |
2727
| FAST_REFRESH | ✅ Used | 🚫 Ignored | When set to `false`, disables experimental support for Fast Refresh to allow you to tweak your components in real time without reloading the page. |
2828
| TSC_COMPILE_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and properly build TypeScript projects even if there are TypeScript type check errors. These errors are printed as warnings in the terminal and/or browser console. |
29+
| ESLINT_BUILD_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and build projects even if there are ESLint errors. You will no longer see any ESLint warnings or errors in the console or terminal. |
2930
| DISABLE_NEW_JSX_TRANSFORM | ✅ Used | ✅ Used | When set to `true`, disables the [new JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) introduced in React 17 and backported to React 16.14.0, 15.7.0, and 0.14.10. New projects will use a version of React that supports this by default but you may need to disable it in existing projects if you can't upgrade React. |

packages/react-scripts/config/webpack.config.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const reactRefreshOverlayEntry = require.resolve(
5555
// makes for a smoother build process.
5656
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
5757

58+
const shouldUseESLintPlugin = process.env.ESLINT_BUILD_ON_ERROR !== 'true';
59+
5860
const imageInlineSizeLimit = parseInt(
5961
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
6062
);
@@ -750,25 +752,26 @@ module.exports = function (webpackEnv) {
750752
// The formatter is invoked directly in WebpackDevServerUtils during development
751753
formatter: isEnvProduction ? typescriptFormatter : undefined,
752754
}),
753-
new ESLintPlugin({
754-
// Plugin options
755-
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
756-
formatter: require.resolve('react-dev-utils/eslintFormatter'),
757-
eslintPath: require.resolve('eslint'),
758-
context: paths.appSrc,
759-
cache: true,
760-
// ESLint class options
761-
cwd: paths.appPath,
762-
resolvePluginsRelativeTo: __dirname,
763-
baseConfig: {
764-
extends: [require.resolve('eslint-config-react-app/base')],
765-
rules: {
766-
...(!hasJsxRuntime && {
767-
'react/react-in-jsx-scope': 'error',
768-
}),
755+
shouldUseESLintPlugin &&
756+
new ESLintPlugin({
757+
// Plugin options
758+
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
759+
formatter: require.resolve('react-dev-utils/eslintFormatter'),
760+
eslintPath: require.resolve('eslint'),
761+
context: paths.appSrc,
762+
cache: true,
763+
// ESLint class options
764+
cwd: paths.appPath,
765+
resolvePluginsRelativeTo: __dirname,
766+
baseConfig: {
767+
extends: [require.resolve('eslint-config-react-app/base')],
768+
rules: {
769+
...(!hasJsxRuntime && {
770+
'react/react-in-jsx-scope': 'error',
771+
}),
772+
},
769773
},
770-
},
771-
}),
774+
}),
772775
].filter(Boolean),
773776
// Some libraries import Node modules but don't use them in the browser.
774777
// Tell webpack to provide empty mocks for them so importing them works.

packages/react-scripts/scripts/build.js

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ checkBrowsers(paths.appPath, isInteractive)
126126
);
127127
},
128128
err => {
129+
// NOTE: This means builds won't exit on ESLint errors too.
129130
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
130131
if (tscCompileOnError) {
131132
console.log(

0 commit comments

Comments
 (0)