Skip to content

Commit 3188ae7

Browse files
minbang930codex
andauthored
fix: accept loose peer ranges in peers check (#12150)
Run peer dependency range checks with semver loose parsing while preserving prerelease inclusion. This prevents pnpm peers check from reporting react-native-reanimated@4.4.0 as unmet for ranges like >=3.16.0 || >=4.0.0-. Add a lockfile regression fixture for #12149 and a patch changeset for the peer checker and pnpm CLI. Closes #12149. Co-authored-by: OpenAI Codex <codex@openai.com>
1 parent 13815ad commit 3188ae7

5 files changed

Lines changed: 62 additions & 1 deletion

File tree

.changeset/loose-peers-check.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pnpm/deps.inspection.peers-checker": patch
3+
"pnpm": patch
4+
---
5+
6+
Fixed `pnpm peers check` to accept loose peer dependency ranges such as `>=3.16.0 || >=4.0.0-` when the installed peer version satisfies the range [#12149](https://github.com/pnpm/pnpm/issues/12149).

deps/inspection/peers-checker/src/checkPeerDependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function extractVersion (ref: string, alias: string, packages: PackageSnapshots)
135135

136136
function satisfies (version: string, range: string): boolean {
137137
if (range === '*') return true
138-
return semver.satisfies(version, range, { includePrerelease: true })
138+
return semver.satisfies(version, range, { includePrerelease: true, loose: true })
139139
}
140140

141141
function filterPeerDependencyIssues (
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "with-loose-peer-range",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"@gorhom/bottom-sheet": "5.2.14",
6+
"react-native-reanimated": "4.4.0"
7+
}
8+
}

deps/inspection/peers-checker/test/__fixtures__/with-loose-peer-range/pnpm-lock.yaml

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/inspection/peers-checker/test/checkPeerDependencies.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ test('reports no issues for satisfied peer dependencies', async () => {
5858
expect(Object.keys(projectIssues.missing)).toHaveLength(0)
5959
})
6060

61+
test('reports no issues for satisfied loose peer dependency ranges', async () => {
62+
const fixture = f.find('with-loose-peer-range')
63+
const issues = await checkPeerDependencies([fixture], {
64+
lockfileDir: fixture,
65+
checkWantedLockfileOnly: true,
66+
})
67+
68+
const projectIssues = issues['.']
69+
expect(projectIssues).toBeDefined()
70+
expect(Object.keys(projectIssues.bad)).toHaveLength(0)
71+
expect(Object.keys(projectIssues.missing)).toHaveLength(0)
72+
})
73+
6174
test('respects peerDependencyRules.allowAny', async () => {
6275
const fixture = f.find('with-unmet-peers')
6376
const issues = await checkPeerDependencies([fixture], {

0 commit comments

Comments
 (0)