From d5d0baaf1d5d82ffde26a3f00323592813199598 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 18:49:36 +0000 Subject: [PATCH] docs: improve JSDoc for version comparison methods - Update `isAtLeast`, `isAbove`, `isBelow`, `isAtMost` JSDoc to explicitly mention they return `false` for invalid version strings. - Update `is` JSDoc to explicitly mention it uses strict string equality and does not normalize inputs (e.g. `v` prefix). - Create `.jules/palette.md` to track UX/DX learnings. --- .changeset/palette-jsdoc-fix.md | 5 +++++ .jules/palette.md | 5 +++++ src/types.ts | 9 +++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/palette-jsdoc-fix.md create mode 100644 .jules/palette.md diff --git a/.changeset/palette-jsdoc-fix.md b/.changeset/palette-jsdoc-fix.md new file mode 100644 index 00000000..e912698e --- /dev/null +++ b/.changeset/palette-jsdoc-fix.md @@ -0,0 +1,5 @@ +--- +"node-version": patch +--- + +Improve JSDoc for version comparison methods to clarify invalid input handling and strictness of `is()` method. diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 00000000..799f4f2c --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,5 @@ +# Palette Journal + +## 2026-01-03 - Initial Setup +**Learning:** For utility libraries, UX often means DX (Developer Experience). Clear documentation of edge cases (like invalid inputs or strict vs loose comparison) prevents developer frustration. +**Action:** Always check if "fail-closed" or "strict" behaviors are explicitly documented in JSDoc. diff --git a/src/types.ts b/src/types.ts index 4de06674..6bb8dc91 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,13 +35,14 @@ 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 equality check and does not normalize inputs (e.g., 'v' prefix). * @param version The version to compare against (e.g., '20.0.0'). * @returns {boolean} True if current version === target version. * @example @@ -51,7 +52,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 +60,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 +68,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 */