question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Be more lax about peer dependencies in eslint-config-react-app

See original GitHub issue

When using CRA with an additional linter I hit problems with matching peer dependency versions with eslint-config-react-app. It has absolute requirements for its peer dependencies.

{
  "peerDependencies": {
    "babel-eslint": "7.0.0",
    "eslint": "3.8.1",
    "eslint-plugin-flowtype": "2.21.0",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1"
  }
}

(https://github.com/facebookincubator/create-react-app/blob/a5f760bab9b1876df13ac4345a4b42655fec46fa/packages/eslint-config-react-app/package.json)

Specifically babel-eslint, eslint, and eslint-plugin-react is hard not to clash with. I had another eslint-config that listed all three of them with incompatible versions. As an example it listed eslint as ^3.11.0.

Had eslint-config-react-app used the caret-style dependencies for it’s peer dependencies, it would have worked out fine.

In general, I understand why you might want to absolutify your linter dependencies - there’s nothing more annoying than lint errors showing up on CI that you didn’t catch locally. But in this case, where it’s very common to add another linter setup I think it might be worth it, to be more lax about the requirements.

For my case, pinning the versions listed in peerDeps of eslint-config-react-app got rid of the peer dependency warnings, after I had downgraded the requirements in the other eslint-config I used.

Would you be open to widen the peer dependency version ranges in eslint-config-react-app?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gustavnikolajcommented, Nov 29, 2016

@fson I completely understand your stance on this matter, and I agree wholeheartedly. But I think that it is better controlled from the projects themselves and not by third party library code. In my opinion, both CRA and eslint-config-react-app fall into the latter category.

As a user of CRA I’d expect that I could just run npm install --save-dev standard and add a lint script to my package.json and be up and running. That will not work without triggering peerDependency warnings if standard relies on a package that is too newer than one defined in eslint-config-react-app. As of writing, this will actually work, as the most recent version of eslint-config-standard has a peer dependency on eslint >=3.8.1. If that was changed to >=3.8.2 we would start seeing the issue I described.

Most of the sharable eslint configurations that I have seen are using peerDependencies with either caret or greater-than-or-equal to, to avoid dependency hell. A few examples:

Doing the same here will allow people to get off the ground easily, with no friction, but still allowing them to freeze packages using shrinkwrap / yarn or manually adding absolute versions for the important packages.

0reactions
gaearoncommented, Dec 7, 2016

Fixed in the latest version of the preset.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Peer Dependencies in JavaScript
Peer dependencies really come into play when you're developing code that will be used by others, such as plugins and packages. If you're...
Read more >
How to fix the peer dependencies Installation problem
But peer dependencies of eslint are not allowing me to install with arisal of following Error. I am Using Ubuntu 18.04 LTS OS....
Read more >
6. 예제 - 일정관리 - Web Developer
[3/4] Linking dependencies... warning "react-scripts > @typescript-eslint/eslint-plugin@1.6.0" has unmet peer dependency "typescript@*".
Read more >
How to solve peer dependencies error after updating ... - Reddit
I think it just might be handling these type of dependency issues better. First, delete the node_modules folder in your project. Yarn will ......
Read more >
npm Peer Dependencies - JavaScript inDepth
A Dependency is an npm package that our package depends on in order to be able to run. Some popular packages that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found