* Enforces consistent dependency versions across all workspaces in the project. * * This rule ensures that all workspaces use the same version of a given dependency. * * @param {Context} context - The Yarn constraint context.
({ Yarn })
| 66 | * @param {Context} context - The Yarn constraint context. |
| 67 | */ |
| 68 | function enforceConsistentDependenciesAcrossTheProject({ Yarn }) { |
| 69 | const workspaceIdents = new Set( |
| 70 | Yarn.workspaces().map((workspace) => workspace.ident), |
| 71 | ); |
| 72 | |
| 73 | for (const dependency of Yarn.dependencies()) { |
| 74 | if (shouldIgnoreDependencyForConsistency(dependency)) { |
| 75 | continue; |
| 76 | } |
| 77 | |
| 78 | // Skip workspace dependencies; enforceProtocols handles them via workspace:* |
| 79 | if (workspaceIdents.has(dependency.ident)) { |
| 80 | continue; |
| 81 | } |
| 82 | |
| 83 | for (const otherDependency of Yarn.dependencies({ |
| 84 | ident: dependency.ident, |
| 85 | })) { |
| 86 | if (shouldIgnoreDependencyForConsistency(otherDependency)) { |
| 87 | continue; |
| 88 | } |
| 89 | |
| 90 | dependency.update(otherDependency.range); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Enforces no dual-type dependencies across workspaces. |
no test coverage detected