Skip to content

Commit 4d26208

Browse files
authored
Use native ESLint behaviour when extending (#8276)
1 parent 8ba0ccb commit 4d26208

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

docusaurus/docs/advanced-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ You can adjust various development and production settings by setting environmen
2525
| NODE_PATH | ✅ Used | ✅ Used | Same as [`NODE_PATH` in Node.js](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders), but only relative folders are allowed. Can be handy for emulating a monorepo setup by setting `NODE_PATH=src`. |
2626
| INLINE_RUNTIME_CHUNK | 🚫 Ignored | ✅ Used | By default, Create React App will embed the runtime script into `index.html` during the production build. When set to `false`, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP. |
2727
| 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. |
28-
| EXTEND_ESLINT | ✅ Used | ✅ Used | When set to `true`, ESLint configs that extend `eslint-config-react-app` will be used by `eslint-loader`. Any rules that are set to `"error"` will stop the application from building. |
28+
| EXTEND_ESLINT | ✅ Used | ✅ Used | When set to `true`, user provided ESLint configs will be used by `eslint-loader`. Note that any rules set to `"error"` will stop the application from building. |
2929
| 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. |

docusaurus/docs/setting-up-your-editor.md

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Note that any rules set to `"error"` will stop the project from building.
3535
There are a few things to remember:
3636

3737
1. We highly recommend extending the base config, as removing it could introduce hard-to-find issues.
38-
1. `.eslintignore` files will be respected
3938
1. When working with TypeScript, you'll need to provide an `overrides` object for rules that should _only_ target TypeScript files.
4039

4140
In the below example:

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

+8-22
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
3333
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
3434
const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
3535
// @remove-on-eject-begin
36-
const eslint = require('eslint');
3736
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
3837
// @remove-on-eject-end
3938
const postcssNormalize = require('postcss-normalize');
@@ -46,6 +45,8 @@ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
4645
// makes for a smoother build process.
4746
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
4847

48+
const isExtendingEslintConfig = process.env.EXTEND_ESLINT === 'true';
49+
4950
const imageInlineSizeLimit = parseInt(
5051
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
5152
);
@@ -346,28 +347,13 @@ module.exports = function(webpackEnv) {
346347
eslintPath: require.resolve('eslint'),
347348
resolvePluginsRelativeTo: __dirname,
348349
// @remove-on-eject-begin
349-
ignore: process.env.EXTEND_ESLINT === 'true',
350-
baseConfig: (() => {
351-
// We allow overriding the config only if the env variable is set
352-
if (process.env.EXTEND_ESLINT === 'true') {
353-
const eslintCli = new eslint.CLIEngine();
354-
let eslintConfig;
355-
try {
356-
eslintConfig = eslintCli.getConfigForFile(
357-
paths.appIndexJs
358-
);
359-
} catch (e) {
360-
console.error(e);
361-
process.exit(1);
362-
}
363-
return eslintConfig;
364-
} else {
365-
return {
350+
ignore: isExtendingEslintConfig,
351+
baseConfig: isExtendingEslintConfig
352+
? undefined
353+
: {
366354
extends: [require.resolve('eslint-config-react-app')],
367-
};
368-
}
369-
})(),
370-
useEslintrc: false,
355+
},
356+
useEslintrc: isExtendingEslintConfig,
371357
// @remove-on-eject-end
372358
},
373359
loader: require.resolve('eslint-loader'),

0 commit comments

Comments
 (0)