-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending ESLint config not working #7510
Extending ESLint config not working #7510
Comments
I was just coming to file this same issue. The problem is that we're checking the This can be confirmed by logging With this eslint config in "eslintConfig": {
"extends": [
"react-app"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
} ...log create-react-app/packages/react-scripts/config/webpack.config.js Lines 344 to 348 in c0b4173
console.log(eslintConfig) // 🡐 ... then run {
env: { browser: true, commonjs: true, es6: true, jest: true, node: true },
globals: {},
parser: 'C:\\git\\herbcaudill\\screentimebank\\node_modules\\@typescript-eslint\\parser\\dist\\parser.js',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: { jsx: true },
warnOnUnsupportedTypeScriptVersion: true
},
plugins: [
'react-hooks',
'react',//
'jsx-a11y',
'flowtype',
'import',
'@typescript-eslint'
],
rules: {
'@typescript-eslint/no-unused-vars': [ 'off', [Object] ],
'default-case': [ 'off', [Object] ],
'no-dupe-class-members': [ 'off' ],
'no-undef': [ 'off' ],
'@typescript-eslint/no-angle-bracket-type-assertion': [ 'warn' ],
// ...
'flowtype/require-valid-file-annotation': [ 'warn' ],
'flowtype/use-flow-type': [ 'warn' ]
},
settings: { react: { version: 'detect' } }
} As you can see, my override of create-react-app/packages/react-scripts/config/webpack.config.js Lines 352 to 356 in c0b4173
will fail and we'll fall back on the standard |
I'm guessing that prior to version 6, ESLint included the |
@mrmckeb I'm seeing |
I'm not sure if the eslint API exposes a way to actually retrieve which console.log(configArrayFactory.getConfigArrayForFile(absolutePath).map(e => e.name)); Which logs this in my case: ConfigArray [
'.eslintrc » eslint-config-react-app',
'.eslintrc » eslint-config-react-app#overrides[0]',
'.eslintrc » eslint-config-silverwind',
'.eslintrc',
'.eslintrc#overrides[0]',
'.eslintrc#overrides[1]'
] Maybe cc: @not-an-aardvark |
Hi all, I'm currently on a business trip and will be on a plane for the next few hours. It seems that this may have been broken by the ESLint 6 upgrade, which came after this config change - unfortunately we didn't have a test for that and we obviously needed one. Maybe @not-an-aardvark can have a look, otherwise I can probably investigate this in the evening today (it'll be London time). Of course if anyone else can have a look and raise a PR, we'll be very grateful. @ianschmitz, one option is to remove the requirement to extend our config - but that could introduce risk. |
How about checking for the |
It would also be nice to print something to the console instead of swallowing the error if the Temporary patch-package fix:patches/react-scripts+3.1.0.patch diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index dad50a3..12fad03 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -339,22 +339,16 @@ module.exports = function(webpackEnv) {
resolvePluginsRelativeTo: __dirname,
// @remove-on-eject-begin
baseConfig: (() => {
- const eslintCli = new eslint.CLIEngine();
- let eslintConfig;
- try {
- eslintConfig = eslintCli.getConfigForFile(paths.appIndexJs);
- } catch (e) {
- // A config couldn't be found.
- }
+ if (process.env.EXTEND_ESLINT) {
+ const eslintCli = new eslint.CLIEngine();
+ let eslintConfig;
+ try {
+ eslintConfig = eslintCli.getConfigForFile(paths.appIndexJs);
+ } catch (e) {
+ console.error(e);
+ process.exit(1);
+ }
- // We allow overriding the config, only if it extends our config
- // (`extends` can be a string or array of strings).
- if (
- process.env.EXTEND_ESLINT &&
- eslintConfig &&
- eslintConfig.extends &&
- eslintConfig.extends.includes('react-app')
- ) {
return eslintConfig;
} else {
return {
|
Hi all, apologies for the botched release here - this was entirely my fault. Unfortunately there was a change in ESLint 6 that broke this, as discussed, and I hadn't added a test for this before upgrading us to ESLint 6. Thanks to @ianschmitz and @iansu for getting a fix out while I was travelling. |
Describe the bug
Extending ESLint config not working.
Environment
Steps to reproduce
yarn create react-app testapp
(ornpx create-react-app testapp
)cd testapp
yarn add eslint-config-airbnb
(ornpm install eslint-config-airbnb
)package.json
:EXTEND_ESLINT=true yarn start
( orEXTEND_ESLINT=true npm start
)Expected behavior
eslint-config-airbnb
should be usedActual behavior
eslint-config-airbnb
is not usedProblem
webpack.config.js
checks thateslintConfig.extends
exists:create-react-app/packages/react-scripts/config/webpack.config.js
Line 355 in c0b4173
and – if it does – that it includes
'react-app'
:create-react-app/packages/react-scripts/config/webpack.config.js
Line 356 in c0b4173
It seems that the property
extends
never exists oneslintConfig
(??)Deleting the above two lines yields the expected behavior (
eslint-config-airbnb
is picked up and we see lint errors /Failed to compile
message)The text was updated successfully, but these errors were encountered: