Skip to content

Commit ef8d5d3

Browse files
committed
Add opt-out for eslint-webpack-plugin
1 parent 282c03f commit ef8d5d3

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

docusaurus/docs/advanced-configuration.md

Lines changed: 1 addition & 0 deletions
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. This works by treating all ESLint errors as warnings. |
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-dev-utils/eslintFormatter.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const table = require('text-table');
1414

1515
const cwd = process.cwd();
1616

17+
const emitErrorsAsWarnings = process.env.ESLINT_BUILD_ON_ERROR === 'true';
18+
1719
function isError(message) {
1820
if (message.fatal || message.severity === 2) {
1921
return true;
@@ -69,7 +71,10 @@ function formatter(results) {
6971

7072
// add color to rule keywords
7173
messages.forEach(m => {
72-
m[4] = m[2] === 'error' ? chalk.red(m[4]) : chalk.yellow(m[4]);
74+
m[4] =
75+
m[2] === 'error' && !emitErrorsAsWarnings
76+
? chalk.red(m[4])
77+
: chalk.yellow(m[4]);
7378
m.splice(2, 1);
7479
});
7580

@@ -87,7 +92,7 @@ function formatter(results) {
8792
output += `${outputTable}\n\n`;
8893
});
8994

90-
if (reportContainsErrorRuleIDs) {
95+
if (reportContainsErrorRuleIDs && !emitErrorsAsWarnings) {
9196
// Unlike with warnings, we have to do it here.
9297
// We have similar code in react-scripts for warnings,
9398
// but warnings can appear in multiple files so we only

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

Lines changed: 3 additions & 0 deletions
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 emitErrorsAsWarnings = process.env.ESLINT_BUILD_ON_ERROR === 'true';
59+
5860
const imageInlineSizeLimit = parseInt(
5961
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
6062
);
@@ -755,6 +757,7 @@ module.exports = function (webpackEnv) {
755757
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
756758
formatter: require.resolve('react-dev-utils/eslintFormatter'),
757759
eslintPath: require.resolve('eslint'),
760+
emitWarning: emitErrorsAsWarnings,
758761
context: paths.appSrc,
759762
cache: true,
760763
cacheLocation: path.resolve(

0 commit comments

Comments
 (0)