chore: lint-versions to do semver satisfy check #1614
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sooo after we merged the last PR, in the release workflow we would run changeset version which bumps
@lion/core.lint-versions was ran afterwards on precommit and started complaining, because it decided 0.21.1 was not okay with ^0.21.0, however, this should be okay because we use caret.
I adjusted the script to do a
semver.satisfieswhich takes the version (0.21.1) and checks if it satisfies the range (^0.21.0).There is also a situation where two ranges are compared, e.g. when root package.json has a devDependency and a subpackage has that same dependency (but as a real dependency), e.g. semver ^7.1.3 and ^7.3.5.

I'm not sure if we're supposed to be comparing them, but I guess it's a good practice to have them aligned from semver perspective.
In this case, you can convert both ranges to full ranges with semver, and check if they sufficiently overlap: one range needs to fully contains the other. That makes them compatible, I think, meaning they would always resolve to the same installation which gets deduped. I tried to check it with a small manual test and it seemed ok: