Closed
Description
Describe the bug
Extending ESLint config not working.
Environment
System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Binaries:
Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm
Browsers:
Chrome: 76.0.3809.100
Firefox: 67.0
Safari: 12.1.2
npmPackages:
react: ^16.9.0 => 16.9.0
react-dom: ^16.9.0 => 16.9.0
react-scripts: 3.1.0 => 3.1.0
npmGlobalPackages:
create-react-app: Not Found
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
)- Add the following to
package.json
:
"eslintConfig": { "extends": [ "react-app", "airbnb"] }
EXTEND_ESLINT=true yarn start
( orEXTEND_ESLINT=true npm start
)
Expected behavior
eslint-config-airbnb
should be used- app should not compile
Actual behavior
eslint-config-airbnb
is not used- app compiles (it shouldn’t!)
Problem
webpack.config.js
checks thateslintConfig.extends
exists:
and – if it does – that it includes
'react-app'
:It seems that the property extends
never exists on eslintConfig
(??)
Deleting the above two lines yields the expected behavior (eslint-config-airbnb
is picked up and we see lint errors / Failed to compile
message)
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
- Fix ESLint 6 supportfacebook/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesjoseroubert08/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesmarcusrc/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesvasikarla-zz/create-react-app
- [Snyk] Security upgrade eslint from 3.16.1 to 4.7.0marcusrc/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesmedmeme/create-react-app
- [Snyk] Fix for 1 vulnerabilitiespickworth/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesadmmasters/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesdineshvgp/create-react-app
- [Snyk] Fix for 1 vulnerabilitiesxhad/create-react-app
Activity
HerbCaudill commentedon Aug 11, 2019
I was just coming to file this same issue.
The problem is that we're checking the
extends
property forreact-app
, but by this time the config object has been expanded so that it actually contains the contents ofeslint-config-react-app
and theextends
property is no longer present.This can be confirmed by logging
eslintConfig
as soon as it's been obtained.With this eslint config in
package.json
......log
eslintConfig
after line 348:create-react-app/packages/react-scripts/config/webpack.config.js
Lines 344 to 348 in c0b4173
... then run
yarn build
. I get something like this:As you can see, my override of
@typescript-eslint/no-unused-vars
was successful; but the config object no longer has anextends
property, so this checkcreate-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
eslint-config-react-app
.HerbCaudill commentedon Aug 11, 2019
I'm guessing that prior to version 6, ESLint included the
extends
property in the config output. This code, which is new in ESLint 6, explicitly omits it.https://github.com/eslint/eslint/blob/fbec99ea3e39316791685652c66e522d698f52d8/lib/cli-engine/config-array-factory.js#L559-L578
ianschmitz commentedon Aug 12, 2019
@mrmckeb I'm seeing
eslintCli.getConfigForFile(paths.appIndexJs)
returnundefined
when i have a.eslintrc.json
file.silverwind commentedon Aug 12, 2019
I'm not sure if the eslint API exposes a way to actually retrieve which
extends
a config uses. I did find a way to log out some potentially usable data inside eslint'sgetConfigForFile
, but this functionality looks to not be exposed in the API.Which logs this in my case:
Maybe cc: @not-an-aardvark
mrmckeb commentedon Aug 12, 2019
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.
conor-cafferkey-sociomantic commentedon Aug 12, 2019
How about checking for the
extends
inpackage.json
? Would that work?n1ru4l commentedon Aug 12, 2019
It would also be nice to print something to the console instead of swallowing the error if the
eslintCli.getConfigForFile(paths.appIndexJs);
fails for some reason (other than the file not existing).Temporary patch-package fix:
patches/react-scripts+3.1.0.patch
mrmckeb commentedon Aug 14, 2019
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.
removed tslintuse eslint onlyadd FB eslint override fix facebook/crea…