-
Notifications
You must be signed in to change notification settings - Fork 29
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
Move eslint to a peer dependency #52
Conversation
Users will need to install eslint at some point anyway, and in reality this tool might be used more often by those who have installed eslint, and then realized that they have tons of linting errors. Instead of bundling our own version of eslint, let’s just use the version they already have installed.
@@ -37,7 +37,6 @@ | |||
}, | |||
"dependencies": { | |||
"chalk": "^2.4.1", | |||
"eslint": "^4.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you can make it both a dep and a peer dep, and it’s still easy for users, but the peer dep will prevent conflicts with a higher level eslint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for commenting. Honestly, it feels weird for it to be both. Is there any documentation for how exactly the resolution is determined in such a case? Is it simply that eslint
will be conditionally installed depending on whether or not an eslint
which satisfies the version in peerDependencies is found at the time of eslint-nibble
installation? If so, does that work in both yarn and npm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be installed if it’s not already in the tree and requireable; if it results in a duplicate, the one up the tree will fail the peer dep requirement.
I’m not sure how it works in yarn, but how it works in npm is the standard, so if it doesn’t work in yarn, yarn is broken :-)
package.json
Outdated
@@ -37,7 +37,7 @@ | |||
}, | |||
"dependencies": { | |||
"chalk": "^2.4.1", | |||
"eslint": "^4.2.0", | |||
"eslint": "^5.7.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’ll want the dep and peer dep range to be identical - as is, eslint 4 users will always get a conflict.
cb9f058
to
53adabb
Compare
I took eslint back out of
Hopefully the readme is clear enough for people to know they need eslint to be installed. And if they try to install and run All that to say, I'm going to stick with just |
If no arguments are provided, recent versions of npm will automatically save the package to `dependencies`, which we don’t want.
Up to you; we do it in almost every package we author at airbnb - it works perfectly, as long as any peerDep range always has an identical range in either deps, or devDeps. If yarn doesn't work with it, I'd file a bug on yarn, but it's fair not to do it if yarn is something that matters to you for some reason. |
Thanks for the feedback. Do you have any particular reasons that you think including The fact that it doesn't work well on yarn is a bummer, but isn't a showstopper on its own. And I could open an issue with them, but it seems similar to yarnpkg/yarn#3951, and I'd wager my issue would be a Aside from all that, using plain peer dependency has an advantage in simplicity. I'll be able to say, "'eslint-nibble' uses the version of eslint you have already installed in your project." without the complexity of figuring out whether this package installed its own version or not. |
npm already handles that complexity - by adding it as a dep, someone without eslint installed at all can use your package without any additional work, but for someone who already has a compatible eslint installed, eslint-nibble will happily use that one. In the event of someone having eslint 3, or eslint 6, |
That's true, but they'd also need to create an eslint config file for this tool to do any good, and for that, they'd need to know what version of eslint would be used, since config files have changed between many of the major versions. Yes they could use I'm sure that using the hybrid approach you suggested works great in a lot of cases. I'm just not convinced it's the right thing for this project. But thanks again for the suggestion and discussion! |
Fixes #40
Closes #50
This package has always bundled eslint as a dependency because I wanted it to be easy to get up and running. The more-proper thing to do is to specify eslint as a peer dependency. Even though peer dependencies can be a bit confusing, I think it's likely that users of this package will generally already have eslint installed, and it makes a lot of sense to use their version, instead of bundling our own.