Allow star version qualifier in semver loose mode
MODIFY
packages/@romejs/codec-semver/parse.test.md
packages/@romejs/codec-semver/parse.test.md
@@ -437,6 +437,359 @@ AbsoluteVersion {
### `15`
+```javascript
+LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 0
+ index: 0
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 6
+ index: 6
+ line: 1
+ }
+ start: Object {
+ column: 0
+ index: 0
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 4
+ minor: 0
+ patch: 0
+ prerelease: Array []
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 6
+ index: 6
+ line: 1
+ }
+ start: Object {
+ column: 1
+ index: 1
+ line: 1
+ }
+ }
+ }
+ }
+ right: LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 10
+ index: 10
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 23
+ index: 23
+ line: 1
+ }
+ start: Object {
+ column: 10
+ index: 10
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 4
+ minor: 0
+ patch: 0
+ prerelease: Array [
+ "beta"
+ "*"
+ ]
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 23
+ index: 23
+ line: 1
+ }
+ start: Object {
+ column: 11
+ index: 11
+ line: 1
+ }
+ }
+ }
+ }
+ right: LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 27
+ index: 27
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 33
+ index: 33
+ line: 1
+ }
+ start: Object {
+ column: 27
+ index: 27
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 3
+ minor: 8
+ patch: 1
+ prerelease: Array []
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 33
+ index: 33
+ line: 1
+ }
+ start: Object {
+ column: 28
+ index: 28
+ line: 1
+ }
+ }
+ }
+ }
+ right: LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 37
+ index: 37
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 43
+ index: 43
+ line: 1
+ }
+ start: Object {
+ column: 37
+ index: 37
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 3
+ minor: 0
+ patch: 0
+ prerelease: Array []
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 43
+ index: 43
+ line: 1
+ }
+ start: Object {
+ column: 38
+ index: 38
+ line: 1
+ }
+ }
+ }
+ }
+ right: LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 47
+ index: 47
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 58
+ index: 58
+ line: 1
+ }
+ start: Object {
+ column: 47
+ index: 47
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 3
+ minor: 0
+ patch: 0
+ prerelease: Array [
+ "rc"
+ 0
+ ]
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 58
+ index: 58
+ line: 1
+ }
+ start: Object {
+ column: 48
+ index: 48
+ line: 1
+ }
+ }
+ }
+ }
+ right: LogicalOr {
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 62
+ index: 62
+ line: 1
+ }
+ }
+ left: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 68
+ index: 68
+ line: 1
+ }
+ start: Object {
+ column: 62
+ index: 62
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 2
+ minor: 1
+ patch: 0
+ prerelease: Array []
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 68
+ index: 68
+ line: 1
+ }
+ start: Object {
+ column: 63
+ index: 63
+ line: 1
+ }
+ }
+ }
+ }
+ right: Comparator {
+ operator: "^"
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 72
+ index: 72
+ line: 1
+ }
+ }
+ version: AbsoluteVersion {
+ build: Array []
+ major: 1
+ minor: 13
+ patch: 1
+ prerelease: Array []
+ loc: Object {
+ filename: undefined
+ end: Object {
+ column: 78
+ index: 78
+ line: 1
+ }
+ start: Object {
+ column: 73
+ index: 73
+ line: 1
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+```
+
+### `16`
+
```javascript
WildcardVersion {
build: Array []
@@ -460,7 +813,7 @@ WildcardVersion {
}
```
-### `16`
+### `17`
```javascript
WildcardVersion {
@@ -485,7 +838,7 @@ WildcardVersion {
}
```
-### `17`
+### `18`
```javascript
WildcardVersion {
@@ -510,7 +863,7 @@ WildcardVersion {
}
```
-### `18`
+### `19`
```javascript
WildcardVersion {
@@ -535,7 +888,7 @@ WildcardVersion {
}
```
-### `19`
+### `20`
```javascript
WildcardVersion {
@@ -560,7 +913,7 @@ WildcardVersion {
}
```
-### `20`
+### `21`
```javascript
WildcardVersion {
@@ -585,7 +938,7 @@ WildcardVersion {
}
```
-### `21`
+### `22`
```javascript
WildcardVersion {
@@ -610,7 +963,7 @@ WildcardVersion {
}
```
-### `22`
+### `23`
```javascript
WildcardVersion {
@@ -635,7 +988,7 @@ WildcardVersion {
}
```
-### `23`
+### `24`
```javascript
WildcardVersion {
@@ -660,7 +1013,7 @@ WildcardVersion {
}
```
-### `24`
+### `25`
```javascript
WildcardVersion {
@@ -685,7 +1038,7 @@ WildcardVersion {
}
```
-### `25`
+### `26`
```javascript
WildcardVersion {
@@ -710,7 +1063,7 @@ WildcardVersion {
}
```
-### `26`
+### `27`
```javascript
VersionRange {
@@ -770,7 +1123,7 @@ VersionRange {
}
```
-### `27`
+### `28`
```javascript
LogicalOr {
@@ -830,7 +1183,7 @@ LogicalOr {
}
```
-### `28`
+### `29`
```javascript
LogicalOr {
@@ -925,7 +1278,7 @@ LogicalOr {
}
```
-### `29`
+### `30`
```javascript
Comparator {
@@ -966,7 +1319,7 @@ Comparator {
}
```
-### `30`
+### `31`
```javascript
LogicalAnd {
@@ -1058,7 +1411,7 @@ LogicalAnd {
}
```
-### `31`
+### `32`
```javascript
Comparator {
@@ -1099,7 +1452,7 @@ Comparator {
}
```
-### `32`
+### `33`
```javascript
LogicalAnd {
@@ -1191,7 +1544,7 @@ LogicalAnd {
}
```
-### `33`
+### `34`
```javascript
Comparator {
@@ -1232,7 +1585,7 @@ Comparator {
}
```
-### `34`
+### `35`
```javascript
LogicalAnd {
@@ -1324,7 +1677,7 @@ LogicalAnd {
}
```
-### `35`
+### `36`
```javascript
Comparator {
@@ -1365,7 +1718,7 @@ Comparator {
}
```
-### `36`
+### `37`
```javascript
LogicalAnd {
@@ -1457,7 +1810,7 @@ LogicalAnd {
}
```
-### `37`
+### `38`
```javascript
Comparator {
@@ -1498,7 +1851,7 @@ Comparator {
}
```
-### `38`
+### `39`
```javascript
LogicalAnd {
@@ -1590,7 +1943,7 @@ LogicalAnd {
}
```
-### `39`
+### `40`
```javascript
Comparator {
@@ -1631,7 +1984,7 @@ Comparator {
}
```
-### `40`
+### `41`
```javascript
LogicalAnd {
@@ -1723,7 +2076,7 @@ LogicalAnd {
}
```
-### `41`
+### `42`
```javascript
Comparator {
@@ -1764,7 +2117,7 @@ Comparator {
}
```
-### `42`
+### `43`
```javascript
LogicalAnd {
@@ -1856,7 +2209,7 @@ LogicalAnd {
}
```
-### `43`
+### `44`
```javascript
Comparator {
@@ -1897,7 +2250,7 @@ Comparator {
}
```
-### `44`
+### `45`
```javascript
LogicalAnd {
@@ -1989,7 +2342,7 @@ LogicalAnd {
}
```
-### `45`
+### `46`
```javascript
Comparator {
@@ -2030,7 +2383,7 @@ Comparator {
}
```
-### `46`
+### `47`
```javascript
LogicalAnd {
@@ -2122,7 +2475,7 @@ LogicalAnd {
}
```
-### `47`
+### `48`
```javascript
Comparator {
@@ -2163,7 +2516,7 @@ Comparator {
}
```
-### `48`
+### `49`
```javascript
LogicalAnd {
@@ -2255,7 +2608,7 @@ LogicalAnd {
}
```
-### `49`
+### `50`
```javascript
Comparator {
@@ -2296,7 +2649,7 @@ Comparator {
}
```
-### `50`
+### `51`
```javascript
LogicalAnd {
@@ -2388,7 +2741,7 @@ LogicalAnd {
}
```
-### `51`
+### `52`
```javascript
Comparator {
@@ -2429,7 +2782,7 @@ Comparator {
}
```
-### `52`
+### `53`
```javascript
LogicalAnd {
@@ -2521,7 +2874,7 @@ LogicalAnd {
}
```
-### `53`
+### `54`
```javascript
Comparator {
@@ -2562,7 +2915,7 @@ Comparator {
}
```
-### `54`
+### `55`
```javascript
LogicalAnd {
@@ -2654,7 +3007,7 @@ LogicalAnd {
}
```
-### `55`
+### `56`
```javascript
Comparator {
@@ -2695,7 +3048,7 @@ Comparator {
}
```
-### `56`
+### `57`
```javascript
LogicalAnd {
@@ -2787,7 +3140,7 @@ LogicalAnd {
}
```
-### `57`
+### `58`
```javascript
Comparator {
@@ -2828,7 +3181,7 @@ Comparator {
}
```
-### `58`
+### `59`
```javascript
LogicalAnd {
@@ -2920,7 +3273,7 @@ LogicalAnd {
}
```
-### `59`
+### `60`
```javascript
Comparator {
@@ -2961,7 +3314,7 @@ Comparator {
}
```
-### `60`
+### `61`
```javascript
LogicalAnd {
@@ -3053,7 +3406,7 @@ LogicalAnd {
}
```
-### `61`
+### `62`
```javascript
Comparator {
@@ -3094,7 +3447,7 @@ Comparator {
}
```
-### `62`
+### `63`
```javascript
LogicalAnd {
@@ -3186,7 +3539,7 @@ LogicalAnd {
}
```
-### `63`
+### `64`
```javascript
Comparator {
@@ -3227,7 +3580,7 @@ Comparator {
}
```
-### `64`
+### `65`
```javascript
LogicalAnd {

MODIFY
packages/@romejs/codec-semver/parse.test.ts
packages/@romejs/codec-semver/parse.test.ts
@@ -12,7 +12,7 @@ import {test} from "rome";
test(
"parse",
async (t) => {
- // versions in version mode
+ // Versions in version mode
const versionTests = [
"1.2.3",
"1.2.3-prerelease",
@@ -29,8 +29,15 @@ test(
t.snapshot(parseSemverVersion({input: str}));
}
- // loose mode
- const looseRangeTests = ["* - 1.2.3", "v1.2.3", "||", "", "1.2.3prerelease"];
+ // Loose mode ranges only
+ const looseRangeTests = [
+ "* - 1.2.3",
+ "v1.2.3",
+ "||",
+ "",
+ "1.2.3prerelease",
+ "^4.0.0 || ^4.0.0-beta.* || ^3.8.1 || ^3.0.0 || ^3.0.0-rc.0 || ^2.1.0 || ^1.13.1",
+ ];
for (const str of looseRangeTests) {
t.snapshot(parseSemverRange({input: str, loose: true}));
@@ -87,12 +94,12 @@ test(
rangeTests.push(`${op} ${op}`);
}
- // run range tests
+ // Run range tests
for (const str of rangeTests) {
t.snapshot(parseSemverRange({input: str}));
}
- // ensure ranges throw in version mode
+ // Ensure ranges throw in version mode
for (const str of rangeTests) {
t.throws(() => {
parseSemverVersion({input: str});

MODIFY
packages/@romejs/codec-semver/parse.ts
packages/@romejs/codec-semver/parse.ts
@@ -236,6 +236,10 @@ const createSemverParser = createParser((ParserCore) =>
} else if (token.type === "Dash") {
this.nextToken();
parts.push("-");
+ } else if (this.loose && token.type === "Star") {
+ // https://github.com/romejs/rome/issues/295
+ this.nextToken();
+ parts.push("*");
} else {
throw this.unexpected({
description: descriptions.SEMVER.INVALID_QUANTIFIER_PART,

Allow star version qualifier in semver loose mode (#705)