Skip to content

Commit

Permalink
chore: fix the linter check to be aware of prerelease (#27419)
Browse files Browse the repository at this point in the history
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Oct 5, 2023
1 parent 52eee85 commit 495dafa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/@aws-cdk/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,16 +1043,16 @@ export class RegularDependenciesMustSatisfyPeerDependencies extends ValidationRu
public readonly name = 'dependencies/peer-dependencies-satisfied';

public validate(pkg: PackageJson): void {
for (const [depName, peerVersion] of Object.entries(pkg.peerDependencies)) {
const depVersion = pkg.dependencies[depName];
if (depVersion === undefined) { continue; }
for (const [depName, peerRange] of Object.entries(pkg.peerDependencies)) {
const depRange = pkg.dependencies[depName];
if (depRange === undefined) { continue; }

// Make sure that depVersion satisfies peerVersion.
if (!semver.intersects(depVersion, peerVersion)) {
if (!semver.intersects(depRange, peerRange, { includePrerelease: true })) {
pkg.report({
ruleName: this.name,
message: `dependency ${depName}: concrete version ${depVersion} does not match peer version '${peerVersion}'`,
fix: () => pkg.addPeerDependency(depName, depVersion),
message: `dependency ${depName}: concrete version ${depRange} does not match peer version '${peerRange}'`,
fix: () => pkg.addPeerDependency(depName, depRange),
});
}
}
Expand Down

0 comments on commit 495dafa

Please sign in to comment.