From 495dafa2a1f4d7efc6aaddd217df3535dd940d52 Mon Sep 17 00:00:00 2001 From: Rico Hermans Date: Thu, 5 Oct 2023 19:23:55 +0200 Subject: [PATCH] chore: fix the linter check to be aware of prerelease (#27419) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- tools/@aws-cdk/pkglint/lib/rules.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/@aws-cdk/pkglint/lib/rules.ts b/tools/@aws-cdk/pkglint/lib/rules.ts index d480d9817eaad..2ee767709a248 100644 --- a/tools/@aws-cdk/pkglint/lib/rules.ts +++ b/tools/@aws-cdk/pkglint/lib/rules.ts @@ -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), }); } }