Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/linter/rules/invalid-change-version.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LINT_MESSAGES } from '../constants.mjs';
import { valid } from 'semver';
import { valid, parse } from 'semver';
import { env } from 'node:process';

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

/**
* Checks if a given semantic version should be ignored.
* A version is considered ignored if its major version is 0 and minor version is less than 2.
*
* @param {string} version - The version to check.
* @returns {boolean|undefined} Returns true if the version is ignored, false otherwise.
*/
const isIgnoredVersion = version => {
if (version === 'v0.11.15') return true;
const { major, minor } = parse(version) || {};
Comment thread
avivkeller marked this conversation as resolved.
return major === 0 && minor < 2;
};

/**
* Determines if a given version is invalid.
*
Expand All @@ -26,6 +39,7 @@ const isInvalid = NODE_RELEASED_VERSIONS
? (version, _, { length }) =>
!(
isValidReplaceMe(version, length) ||
isIgnoredVersion(version) ||
NODE_RELEASED_VERSIONS.includes(version.replace(/^v/, ''))
)
: (version, _, { length }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const issues = invalidChangeVersion([
...assertEntry,
changes: [
...assertEntry.changes,
{ version: ['SOME_OTHER_RELEASED_VERSION'] },
{ version: ['SOME_OTHER_RELEASED_VERSION', 'v0.11.15', 'v0.1.2'] },
],
},
]);
Expand Down
Loading