create-react-app: Installing eslint in a fresh app should give an error

Is this a bug report?

I think so, but I’m not sure.

Did you try recovering your dependencies?

Yes, I did.

$ npm --version
6.4.1

Which terms did you search for in User Guide?

eslint

Environment

Environment:
  OS:  Windows 10
  Node:  10.10.0

  Yarn:
  npm:  6.4.1
  Watchman:  Not Found
  Xcode:  N/A
  Android Studio:  Not Found

Packages: (wanted => installed)
  react: ^16.5.2 => 16.5.2
  react-dom: ^16.5.2 => 16.5.2
  react-scripts: 1.1.5 => 1.1.5

Steps to Reproduce

  1. npm init react-app my-app
  2. cd my-app
  3. npm install eslint --save-dev

Expected Behavior

Eslint should install with the lastest version (currently 5.6.1) without problems and it should show no warnings during installation.

Actual Behavior

Several npm warnings are shown stating that an older version of eslint should be installed by me as it is a peer dependency of several packages which were automatically installed with eslint.

$ npm install eslint --save-dev
npm WARN eslint-config-react-app@2.1.0 requires a peer of eslint@^4.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@1.9.0 requires a peer of eslint@>=1.6.0 <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-import@2.8.0 requires a peer of eslint@2.x - 4.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jsx-a11y@5.1.1 requires a peer of eslint@^2.10.2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.4.0 requires a peer of eslint@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ eslint@5.6.1
added 30 packages from 33 contributors, updated 6 packages, moved 1 package and audited 14759 packages in 10.093s
found 0 vulnerabilities

Reproducible Demo

Not available.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

FYI, npm start works without problems after installing an older version of ESLint by my own and using the snippet above in my .eslintrc.

Anyway, I understand from your comments @gaearon and @bugzpodder that the preferred route in my case would be to keep using the ESLint version that comes with create-react-app (now that I know that!) and have the plugin simply be upgraded to support it.

Thanks for your comments.

The only real issue here would be then a documentation one to make more clear:

  1. Which packages are already managed by create-react-app
  2. That you cannot install those packages by your own without going into problems…

I’d also add we don’t really have a supported way to add linter plugins right now.

Well, supposing that I managed to have the ESLint plugin [^1] to work with the last version of ESLint, I understand that these two steps would suffice:

  1. npm install eslint-config-techchange --save-dev
  2. Add the following to my .eslintrc:
{
  "extends": ["techchange/react"]
}

I’ll try it and I’ll let you know.

[^1]: To be more specific, in my case this is a Shareable ESLint Config, not an plugin.