@@ -4,23 +4,38 @@ import { env } from 'node:process';
44
55const NODE_RELEASED_VERSIONS = env . NODE_RELEASED_VERSIONS ?. split ( ',' ) ;
66
7+ /**
8+ * Checks if the given version is "REPLACEME" and the array length is 1.
9+ *
10+ * @param {string } version - The version to check.
11+ * @param {number } length - Length of the version array.
12+ * @returns {boolean } True if conditions match, otherwise false.
13+ */
14+ const isValidReplaceMe = ( version , length ) =>
15+ length === 1 && version === 'REPLACEME' ;
16+
717/**
818 * Determines if a given version is invalid.
919 *
1020 * @param {string } version - The version to check.
11- * @returns {boolean } True if the version is invalid, false otherwise.
21+ * @param {unknown } _ - Unused parameter.
22+ * @param {{ length: number } } context - Array containing the length property.
23+ * @returns {boolean } True if the version is invalid, otherwise false.
1224 */
1325const isInvalid = NODE_RELEASED_VERSIONS
14- ? version =>
15- version !== 'REPLACEME' &&
16- ! NODE_RELEASED_VERSIONS . includes ( version . replace ( / ^ v / , '' ) )
17- : version => version !== 'REPLACEME' && ! valid ( version ) ;
26+ ? ( version , _ , { length } ) =>
27+ ! (
28+ isValidReplaceMe ( version , length ) ||
29+ NODE_RELEASED_VERSIONS . includes ( version . replace ( / ^ v / , '' ) )
30+ )
31+ : ( version , _ , { length } ) =>
32+ ! ( isValidReplaceMe ( version , length ) || valid ( version ) ) ;
1833
1934/**
20- * Checks if any change version is invalid .
35+ * Identifies invalid change versions from metadata entries .
2136 *
22- * @param {ApiDocMetadataEntry[] } entries - The metadata entries to check.
23- * @returns {Array< import('../types').LintIssue> } List of lint issues found .
37+ * @param {ApiDocMetadataEntry[] } entries - Metadata entries to check.
38+ * @returns {import('../types').LintIssue[] } List of detected lint issues.
2439 */
2540export const invalidChangeVersion = entries =>
2641 entries . flatMap ( ( { changes, api_doc_source, yaml_position } ) =>
0 commit comments