diff --git a/.changeset/palette-jsdoc-fix.md b/.changeset/palette-jsdoc-fix.md new file mode 100644 index 00000000..c013e557 --- /dev/null +++ b/.changeset/palette-jsdoc-fix.md @@ -0,0 +1,5 @@ +--- +"node-version": patch +--- + +Improve JSDoc for version comparison methods to clarify input validation and return values. diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 00000000..2bc5a05c --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2026-01-03 - API Consistency and Documentation +**Learning:** In this library, the `is()` comparison method performs strict equality checks (expecting exact matches) while other methods like `isAtLeast()` normalize inputs (handling 'v' prefixes). This inconsistency is a potential "gotcha" for developers consuming the API. +**Action:** When designing or maintaining API surfaces with comparison logic, ensure consistent input handling across all methods, or explicitly document deviations in JSDoc to prevent developer confusion. diff --git a/src/types.ts b/src/types.ts index 4de06674..af3246a3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,13 +35,17 @@ export interface NodeVersion { /** * Check if the current Node version is at least the specified version. * @param version The version to compare against (e.g., '20.0.0'). - * @returns {boolean} True if current version >= target version. + * @returns {boolean} True if current version >= target version. Returns false for invalid version strings. * @example * version.isAtLeast('18.0.0'); // true if current is 20.0.0 */ isAtLeast(version: string): boolean; /** * Check if the current Node version matches the specified version. + * + * @note This method performs a strict string comparison and does not normalize the input + * (e.g., it does not strip 'v' prefixes). + * * @param version The version to compare against (e.g., '20.0.0'). * @returns {boolean} True if current version === target version. * @example @@ -51,7 +55,7 @@ export interface NodeVersion { /** * Check if the current Node version is strictly greater than the specified version. * @param version The version to compare against (e.g., '20.0.0'). - * @returns {boolean} True if current version > target version. + * @returns {boolean} True if current version > target version. Returns false for invalid version strings. * @example * version.isAbove('18.0.0'); // true if current is 20.0.0 */ @@ -59,7 +63,7 @@ export interface NodeVersion { /** * Check if the current Node version is strictly less than the specified version. * @param version The version to compare against (e.g., '20.0.0'). - * @returns {boolean} True if current version < target version. + * @returns {boolean} True if current version < target version. Returns false for invalid version strings. * @example * version.isBelow('22.0.0'); // true if current is 20.0.0 */ @@ -67,7 +71,7 @@ export interface NodeVersion { /** * Check if the current Node version is at most the specified version. * @param version The version to compare against (e.g., '20.0.0'). - * @returns {boolean} True if current version <= target version. + * @returns {boolean} True if current version <= target version. Returns false for invalid version strings. * @example * version.isAtMost('22.0.0'); // true if current is 20.0.0 */