Swerve - #898
Open
jrin0340-420 wants to merge 12 commits into
Open
Conversation
## Summary - Fix `subset()` so prerelease lower and upper bounds are checked against individual comparators without reapplying full range prerelease gating. - Add coverage for `^10.2.0-beta.2` being a subset of `^10.2.0-beta.1`. ## Tests - `npx tap test/ranges/subset.js` - `npm test` - `git diff --check` Fixes npm#757 Co-authored-by: Puneet Dixit <rvit23bcs086.rvitm@rvei.edu.in>
🤖 I have created a release *beep* *boop* --- ## [7.8.1](npm/node-semver@v7.8.0...v7.8.1) (2026-05-21) ### Bug Fixes * [`17aa702`](npm@17aa702) [npm#869](npm#869) strip build metadata before comparator trimming (npm#869) (@owlstronaut) * [`5f3ca13`](npm@5f3ca13) [npm#867](npm#867) handle prerelease bounds in subset (npm#867) (@puneetdixit200, Puneet Dixit) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fixes npm#226. ## Summary - treat a dotted prerelease identifier as a prefix when deciding whether to continue incrementing the existing prerelease sequence - keep replacing the prerelease when the matched prefix is followed by a non-numeric segment - add fixtures for dotted identifiers such as `alpha.beta` and `alpha.beta.5` ## Testing - `npm test` Co-authored-by: Sheldon <neooosky@gmail.com>
🤖 I have created a release *beep* *boop* --- ## [7.8.2](npm/node-semver@v7.8.1...v7.8.2) (2026-06-04) ### Bug Fixes * [`bea6028`](npm@bea6028) [npm#870](npm#870) increment dotted prerelease identifiers (npm#870) (@liuzemei, @SheldonNeo) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
## Summary
- keep exact caret lower bounds at the release version when
`includePrerelease` is enabled
- add regression fixtures for `^0.0.3` and `^0.2.3` prerelease versions
matching the existing `^1.0.0` behavior
## Root Cause
For exact `0.x` caret ranges without an explicit prerelease,
`replaceCaret` appended `-0` to the lower bound when `includePrerelease`
was enabled. That turned `^0.0.3` into `>=0.0.3-0 <0.0.4-0`, allowing
`0.0.3-alpha` while exact `1.x` caret ranges kept `>=1.2.3` and rejected
`1.2.3-alpha`.
## Test Plan
- RED: Node assert script confirmed `satisfies('0.0.3-alpha', '^0.0.3',
{ includePrerelease: true })` returned `true` before the fix
- GREEN: Node assert script for `0.0.3-alpha`, `0.2.3-alpha`, and
`1.2.3-alpha` all returning `false`
- `node` fixture script covering range include/exclude fixtures: 121
include and 98 exclude cases
- broader `node` range verification script: 1348 checks across range
parsing, intersects, outside/gtr/ltr, min/max satisfying, and
toComparators
- `git diff --check HEAD^ HEAD`
Fixes npm#557
Bumps [@npmcli/eslint-config](https://github.com/npm/eslint-config) from 6.0.1 to 7.0.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/npm/eslint-config/releases">@npmcli/eslint-config's releases</a>.</em></p> <blockquote> <h2>v7.0.0</h2> <h2><a href="https://github.com/npm/eslint-config/compare/v6.0.1...v7.0.0">7.0.0</a> (2026-05-15)</h2> <h3>⚠️ BREAKING CHANGES</h3> <ul> <li><code>@npmcli/eslint-config</code> now supports node <code>^22.22.2 || ^24.15.0 || >=26.0.0</code></li> <li>template-oss-apply</li> </ul> <h3>Features</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/cff17a77ceefd23fbd31f8a756e0904326b9a54c"><code>cff17a7</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> bump to new node engine range (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/2c974ce55bfc053bb0c2dee1cb58666b85aee188"><code>2c974ce</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> template-oss-apply (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> </ul> <h3>Dependencies</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/4acc61fd15df03794fbd9074bb46083f945954ee"><code>4acc61f</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> <code>which@7.0.0</code></li> </ul> <h3>Chores</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/766a45179996de0a9663d3adc62bffbe95cc3ea4"><code>766a451</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> template-oss-apply (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/05b3ee3068c27a0e3047e5e0e53c32a840263a26"><code>05b3ee3</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> bumping <code>@npmcli/template-oss</code> from 4.30.0 to 5.1.0 (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/966721205dc8433fd40ae1007356cb4b11c2950f"><code>9667212</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/149">#149</a> bump <code>@npmcli/template-oss</code> from 4.29.0 to 4.30.0 (<a href="https://redirect.github.com/npm/eslint-config/issues/149">#149</a>) (<a href="https://github.com/dependabot"><code>@dependabot</code></a>[bot], <a href="https://github.com/npm-cli-bot"><code>@npm-cli-bot</code></a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/npm/eslint-config/blob/main/CHANGELOG.md">@npmcli/eslint-config's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/npm/eslint-config/compare/v6.0.1...v7.0.0">7.0.0</a> (2026-05-15)</h2> <h3>⚠️ BREAKING CHANGES</h3> <ul> <li><code>@npmcli/eslint-config</code> now supports node <code>^22.22.2 || ^24.15.0 || >=26.0.0</code></li> <li>template-oss-apply</li> </ul> <h3>Features</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/cff17a77ceefd23fbd31f8a756e0904326b9a54c"><code>cff17a7</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> bump to new node engine range (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/2c974ce55bfc053bb0c2dee1cb58666b85aee188"><code>2c974ce</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> template-oss-apply (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> </ul> <h3>Dependencies</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/4acc61fd15df03794fbd9074bb46083f945954ee"><code>4acc61f</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> <code>which@7.0.0</code></li> </ul> <h3>Chores</h3> <ul> <li><a href="https://github.com/npm/eslint-config/commit/766a45179996de0a9663d3adc62bffbe95cc3ea4"><code>766a451</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> template-oss-apply (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/05b3ee3068c27a0e3047e5e0e53c32a840263a26"><code>05b3ee3</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/154">#154</a> bumping <code>@npmcli/template-oss</code> from 4.30.0 to 5.1.0 (<a href="https://github.com/owlstronaut"><code>@owlstronaut</code></a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/966721205dc8433fd40ae1007356cb4b11c2950f"><code>9667212</code></a> <a href="https://redirect.github.com/npm/eslint-config/pull/149">#149</a> bump <code>@npmcli/template-oss</code> from 4.29.0 to 4.30.0 (<a href="https://redirect.github.com/npm/eslint-config/issues/149">#149</a>) (<a href="https://github.com/dependabot"><code>@dependabot</code></a>[bot], <a href="https://github.com/npm-cli-bot"><code>@npm-cli-bot</code></a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/npm/eslint-config/commit/3c3fd4feab0b33f978166c79dfc98eb4407453ed"><code>3c3fd4f</code></a> chore: release 7.0.0 (<a href="https://redirect.github.com/npm/eslint-config/issues/155">#155</a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/4acc61fd15df03794fbd9074bb46083f945954ee"><code>4acc61f</code></a> deps: which@7.0.0</li> <li><a href="https://github.com/npm/eslint-config/commit/766a45179996de0a9663d3adc62bffbe95cc3ea4"><code>766a451</code></a> chore: template-oss-apply</li> <li><a href="https://github.com/npm/eslint-config/commit/cff17a77ceefd23fbd31f8a756e0904326b9a54c"><code>cff17a7</code></a> feat!: bump to new node engine range</li> <li><a href="https://github.com/npm/eslint-config/commit/2c974ce55bfc053bb0c2dee1cb58666b85aee188"><code>2c974ce</code></a> feat!: template-oss-apply</li> <li><a href="https://github.com/npm/eslint-config/commit/05b3ee3068c27a0e3047e5e0e53c32a840263a26"><code>05b3ee3</code></a> chore: bumping <code>@npmcli/template-oss</code> from 4.30.0 to 5.1.0</li> <li><a href="https://github.com/npm/eslint-config/commit/966721205dc8433fd40ae1007356cb4b11c2950f"><code>9667212</code></a> chore: bump <code>@npmcli/template-oss</code> from 4.29.0 to 4.30.0 (<a href="https://redirect.github.com/npm/eslint-config/issues/149">#149</a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/9cea692ba1fa5c8fb2c343f8debf64996ba5c6e1"><code>9cea692</code></a> chore: bump <code>@npmcli/template-oss</code> from 4.28.1 to 4.29.0 (<a href="https://redirect.github.com/npm/eslint-config/issues/148">#148</a>)</li> <li><a href="https://github.com/npm/eslint-config/commit/44b21f1e071512316825e9dc2aa0de935d5eab52"><code>44b21f1</code></a> chore: bump <code>@npmcli/template-oss</code> from 4.28.0 to 4.28.1 (<a href="https://redirect.github.com/npm/eslint-config/issues/146">#146</a>)</li> <li>See full diff in <a href="https://github.com/npm/eslint-config/compare/v6.0.1...v7.0.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [7.8.3](npm/node-semver@v7.8.2...v7.8.3) (2026-06-08) ### Bug Fixes * [`046da7f`](npm@046da7f) [npm#872](npm#872) align caret includePrerelease lower bounds (npm#872) (@wayyoungboy) ### Chores * [`3485dda`](npm@3485dda) [npm#866](npm#866) bump @npmcli/eslint-config from 6.0.1 to 7.0.0 (npm#866) (@dependabot[bot]) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [7.8.4](npm/node-semver@v7.8.3...v7.8.4) (2026-06-09) ### Bug Fixes * [`e583226`](npm@e583226) [npm#874](npm#874) reject numeric segments after x-ranges (@pupuking723) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…lease (npm#878) Closes npm#512 ## Problem A tilde range like \`~1.2\` is documented in the README as equivalent to the \`1.2.x\` x-range: > \`~1.2\` := \`>=1.2.0 <1.(2+1).0\` := \`>=1.2.0 <1.3.0-0\` (**Same as \`1.2.x\`**) With \`{ includePrerelease: true }\`, both the x-range and the caret operator lower-bound their open forms at \`-0\` (the lowest possible prerelease) so that prereleases like \`1.2.0-rc\` match. The tilde operator did **not**, leaving its lower bound at \`>=1.2.0\`: ```js const semver = require("semver") const opts = { includePrerelease: true } semver.satisfies("1.2.0-rc", "1.2.*", opts) // true semver.satisfies("1.2.0-rc", "^1.2.*", opts) // true semver.satisfies("1.2.0-rc", "~1.2.*", opts) // false <-- bug new semver.Range("1.2.*", opts).range // ">=1.2.0-0 <1.3.0-0" new semver.Range("^1.2.*", opts).range // ">=1.2.0-0 <2.0.0-0" new semver.Range("~1.2.*", opts).range // ">=1.2.0 <1.3.0-0" <-- lower bound missing -0 ``` This makes \`~1.2.*\` inconsistent with both its documented x-range equivalent and the caret operator. Reported in npm#512 (and the same root cause as npm#510 / npm#736 discussion around tilde + prerelease). ## Fix \`replaceCaret\` and \`replaceXRange\` already compute a lower-bound suffix: ```js const z = options.includePrerelease ? "-0" : "" ``` and apply it to their open forms. \`replaceTilde\` was the only one of the three that did not. This change applies the same suffix to the open tilde forms (\`~1\`, \`~1.x\`, \`~1.2\`, \`~1.2.x\`). After the fix, \`~1.2.*\` desugars to \`>=1.2.0-0 <1.3.0-0\` — identical to the \`1.2.*\` x-range it is documented to equal. ### Scope / what is intentionally unchanged - **Default behavior (no \`includePrerelease\`) is untouched** — no \`-0\` is added, so \`~1.2.*\` stays \`>=1.2.0 <1.3.0-0\`. - **Fully-specified tildes keep their exact lower bound**, matching the caret operator: \`~1.2.3\` with \`includePrerelease\` stays \`>=1.2.3 <1.3.0-0\` (so \`1.2.3-rc\`, which sorts *before* the \`1.2.3\` release, correctly does **not** match — same as \`^1.2.3\`). - **Explicit-prerelease tildes** (\`~1.2.3-beta\`) are preserved as-is. ## Tests Added failing-then-passing fixtures: - \`test/fixtures/range-parse.js\` — desugaring of \`~1\`, \`~1.x\`, \`~1.2\`, \`~1.2.x\`, \`~0.0\` under \`includePrerelease\`, plus \`~1.2.3\` / \`~1.2.3-beta.4\` to lock in that they do *not* change. - \`test/fixtures/range-include.js\` — \`~1.1\` / \`~1.1.x\` / \`~2\` / \`~2.x\` now satisfy the same prereleases as the equivalent x-ranges. Full suite (\`npm test\`) and \`eslint\` pass.
🤖 I have created a release *beep* *boop* --- ## [7.8.5](npm/node-semver@v7.8.4...v7.8.5) (2026-06-19) ### Bug Fixes * [`9c8692a`](npm@9c8692a) [npm#878](npm#878) include prereleases in tilde range lower bound with includePrerelease (npm#878) (@chatman-media) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References