Skip to content

Commit

Permalink
chore(constraints): allow execeptions for dependency-range consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 9, 2024
1 parent e0d921a commit 8be8f73
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,24 @@ function expectControllerDependenciesListedAsPeerDependencies(
}
}

function getInconsistentDependenciesAndDevDependencies(dependencyIdent, dependenciesByRange) {

Check failure on line 717 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Missing JSDoc comment

Check failure on line 717 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Replace `dependencyIdent,·dependenciesByRange` with `⏎··dependencyIdent,⏎··dependenciesByRange,⏎`
const ALLOWED_INCONSISTENT_DEPENDENCIES = Object.entries({
// '@metamask/foo': ['^1.0.0'],
});
for (const [allowedPackage, ignoredRange] of ALLOWED_INCONSISTENT_DEPENDENCIES) {

Check failure on line 721 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Replace `allowedPackage,·ignoredRange` with `⏎····allowedPackage,⏎····ignoredRange,⏎··`
if (allowedPackage === dependencyIdent) {
return new Map(
Object.entries(

Check failure on line 724 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Replace `⏎··········dependenciesByRange⏎········` with `dependenciesByRange`
dependenciesByRange
).filter(
([range]) => !ignoredRange.includes(range)

Check failure on line 727 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Insert `,`
)

Check failure on line 728 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Insert `,`
)

Check failure on line 729 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Insert `;`
}
}
return dependenciesByRange;
}

/**
* Expect that all version ranges in `dependencies` and `devDependencies` for
* the same dependency across the entire monorepo are the same. As it is
Expand All @@ -732,9 +750,11 @@ function expectConsistentDependenciesAndDevDependencies(Yarn) {
dependencyIdent,
dependenciesByRange,
] of nonPeerDependenciesByIdent.entries()) {
const dependencyRanges = [...dependenciesByRange.keys()].sort();
const dependenciesToConsider =
getInconsistentDependenciesAndDevDependencies(dependencyIdent, dependenciesByRange);

Check failure on line 754 in yarn.config.cjs

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Replace `dependencyIdent,·dependenciesByRange` with `⏎········dependencyIdent,⏎········dependenciesByRange,⏎······`
const dependencyRanges = [...dependenciesToConsider.keys()].sort();
if (dependenciesByRange.size > 1) {
for (const dependencies of dependenciesByRange.values()) {
for (const dependencies of dependenciesToConsider.values()) {
for (const dependency of dependencies) {
dependency.error(
`Expected version range for ${dependencyIdent} (in ${
Expand Down

0 comments on commit 8be8f73

Please sign in to comment.