Skip to content

Commit 3f07e31

Browse files
committed
fix(lint): hardcode ignored invalid change versions
1 parent 9be11fd commit 3f07e31

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/linter/rules/invalid-change-version.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LINT_MESSAGES } from '../constants.mjs';
2-
import { valid } from 'semver';
2+
import { valid, parse } from 'semver';
33
import { env } from 'node:process';
44

55
const NODE_RELEASED_VERSIONS = env.NODE_RELEASED_VERSIONS?.split(',');
@@ -14,6 +14,19 @@ const NODE_RELEASED_VERSIONS = env.NODE_RELEASED_VERSIONS?.split(',');
1414
const isValidReplaceMe = (version, length) =>
1515
length === 1 && version === 'REPLACEME';
1616

17+
/**
18+
* Checks if a given semantic version should be ignored.
19+
* A version is considered ignored if its major version is 0 and minor version is less than 2.
20+
*
21+
* @param {string} version - The version to check.
22+
* @returns {boolean|undefined} Returns true if the version is ignored, false otherwise.
23+
*/
24+
const isIgnoredVersion = version => {
25+
if (version === 'v0.11.15') return true;
26+
const { major, minor } = parse(version) || {};
27+
return major === 0 && minor < 2;
28+
};
29+
1730
/**
1831
* Determines if a given version is invalid.
1932
*
@@ -26,6 +39,7 @@ const isInvalid = NODE_RELEASED_VERSIONS
2639
? (version, _, { length }) =>
2740
!(
2841
isValidReplaceMe(version, length) ||
42+
isIgnoredVersion(version) ||
2943
NODE_RELEASED_VERSIONS.includes(version.replace(/^v/, ''))
3044
)
3145
: (version, _, { length }) =>

src/linter/tests/fixtures/invalidChangeVersion-environment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const issues = invalidChangeVersion([
77
...assertEntry,
88
changes: [
99
...assertEntry.changes,
10-
{ version: ['SOME_OTHER_RELEASED_VERSION'] },
10+
{ version: ['SOME_OTHER_RELEASED_VERSION', 'v0.11.15', 'v0.1.2'] },
1111
],
1212
},
1313
]);

0 commit comments

Comments
 (0)