Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

v6: lerna, deps, react fix #75

Merged
merged 6 commits into from
Dec 21, 2017
Merged

v6: lerna, deps, react fix #75

merged 6 commits into from
Dec 21, 2017

Conversation

nosilleg
Copy link
Contributor

Not separate commits, sorry.

Fixed eslint-config-schibsted-react because I borked the SPT merge and missed a dependency.
Update some dependencies including unicorn major bump to V3.
Add Lerna to resolve #44

@@ -0,0 +1,6 @@
{
"lerna": "2.5.1",
"version": "6.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use independent versioning, but not biggie

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was intentional to not use independent. 😄

If you have some good reading on why independent is preferable, I'm happy to read and reevaluate on the next release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short of it is that even though you make a breaking change in the react config, there's no need to make a breaking change in all of the other packages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. That was a consideration when choosing but my preference is fixed versions. Inspecting a package.json it's easy to tell when you have compatible versions. This isn't an issue if you're on the latest versions, but if you're a few behind you have more effort to look up which package goes with which.

@nosilleg
Copy link
Contributor Author

@SimenB I've updated the dependencies as we discussed, but I've removed all peerDependencies in favour of pure dependency usage.

package.json Outdated
@@ -25,7 +21,8 @@
},
"devDependencies": {
"eslint-config-schibsted": "file:./packages/eslint-config-schibsted",
"eslint-config-schibsted-node": "file:./packages/eslint-config-schibsted-node"
"eslint-config-schibsted-node": "file:./packages/eslint-config-schibsted-node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't need these as yarn hoists them up automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, with the workspaces. Patch incoming.

@@ -12,15 +12,15 @@ acorn@^3.0.4:
version "3.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete nested yarn lockfiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected that to be cleaned up automatically.

Done.

Copy link
Contributor

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm packages/*/yarn.lock, then we should be gtg

},
"peerDependencies": {
"eslint": "^4.10.0"
"eslint": "^4.13.1",
Copy link
Contributor

@SimenB SimenB Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if eslint itself should be a peer, but not the configs and plugins?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would gain is a warning when installing, but I don't think it improves the resolution process. As we discussed originally my plan was to leave eslint as the only peer, but then I thought maybe it didn't deserve to be special cased since any package version conflicts will give unpredictable outcomes.

This method also means that eslint doesn't have to be specified at the root. How likely that is I'm unsure since I don't know how others will mix this with other linting packages.

When you go to update the proxy config for Finn, will the peer warning for just eslint be sufficiently beneficial?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about allowing consumers to control the version of eslint independently from the configs

any package version conflicts will give unpredictable outcomes.

how so?

When you go to update the proxy config for Finn, will the peer warning for just eslint be sufficiently beneficial?

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct my understanding where it's wrong.

Consumers can control the version of any package by using the resolutions section of package.json.

If a eslint config/plugin has multiple versions installed, the version at the root will be the version used when eslint executes. The version in the root might not be the version that we wanted. I believe this would be the reasoning for AirBnB to make all eslint plugins/configs peerDependencies.

You said yes to the warning about eslint, and only eslint, would provide benefit. Given the above, can you please clarify why? I would have assumed that warnings for all or warnings for none would be the preferable approach.

I could go either way.

I originally had a lot more in here about how peerDependency installs could go wrong, but that just lead me to thinking that specifying peerDependencies is the better option. Packages like ESLint that require a CLI to read from the root node_modules seem like the poster package for peerDependencies. It doesn't stop version conflicts, but it does expose the warnings.

But...

The warnings shortcut debugging, but I'm getting more blind to them with the recent bug(s) with false positives. And there will be situations where not all of you dependencies have updated to the latest eslint/config/plugin. So you'll either have to choose to not update or see the error and get unexpected outcomes anyway.

Plus not having to install things in the root that I'm not actually using myself is nice.

In the case of eslint-config-finn, you're going to have a dependency that is 3 levels removed from the root package.json. Do we really want a peerDependency chain so far removed from its use?

eslint-config-finn -> eslint-config-schibsted -> eslint-config-airbnb -> eslint-plugin-import

These will need to be installed at the root, with some appearing unused:
eslint
eslint-plugin-import
eslint-plugin-jsx-a11y
eslint-plugin-react
eslint-plugin-chai-friendly
eslint-plugin-flowtype
eslint-config-airbnb-base
eslint-config-airbnb
eslint-config-prettier
eslint-plugin-prettier
eslint-plugin-unicorn
prettier

... and then...

I've just spotted some >= versioning, so even if we get rid of all the unmet peerDependency messages, we might still be getting unexpected behavior because of changes in major versions.

After all that I'm actually leaning towards making them all peerDependencies. Hopefully I've gotten something wrong and you can talk me out of it. 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example of how having it as dependencies is a potential footgun, and why peer deps might be preferred: eslint/eslint#8547

Because of semver, the only way to ensure a single version is really to use peer deps, but it's annoying. See eslint/eslint#3458

I think maybe plugins should be peer deps, while config can be deps. (in practice)

Eslint itself should be peer. And prettier should be peer.

Agreed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the leg work finding those threads. It's a shame people discovered these issues 2 years ago and it still isn't resolved.

After reading those threads and a lot of tangents is confirmed my assertions above that the benefit of using peerDependencies is the warning message on install. It doesn't prevent version conflicts.

Anyway, I've updated the code to use peerDependencies, and corrected the use of configs so that they are at least the correct version. This can't be done nicely for configs that come from plugins, so I have just given in that there may be plugin/config mismatches as well as plugin mismatches.

There was at least one extra peerDependency that was required, but want listed as a peer in the dependency. Hopefully I've covered the lot.

READMEs updated to reflect the requirements.

@nosilleg
Copy link
Contributor Author

Please give another review with the latest changes. I'll squash on merge.

@@ -4,5 +4,5 @@ module.exports = {
env: {
node: true
},
extends: ["./chai.js"].map(require.resolve)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then eslint will just see ./chai.js and will have to figure out the path. simpler and clearer to give absolute path IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main benefit of using the require.resolve is that it forces resolution to the packages specified in this packages package.json instead of the package that eslint finds in the root node_modules. This isn't a concern for the relative path since it's relative to this package. (Although this wasn't one of the tests I did.)

I also made the call that having less code here was better. I don't know the speed differences of resolving the path here, versus it being resolved somewhere later, but I'm presume it's negligible in this use case.

Happy to revisit, but will merge as-is since I have your approval.

Copy link
Contributor

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, this LGTM!

@nosilleg nosilleg merged commit 4b189b6 into master Dec 21, 2017
@nosilleg nosilleg deleted the v6 branch December 21, 2017 11:02
@nosilleg nosilleg mentioned this pull request Jan 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Lerna
2 participants