From 92123677c439348b7d967709986cd37a6bd0a773 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 30 Aug 2024 12:58:07 +0800 Subject: [PATCH] commitlint: honor our own WorkflowGuidelines The workflow guidelines state that we should avoid the keyword "undefined". This is also extra good because it seems that the `?`-based guards against both null and undefined, at least according to this example: https://github.com/conventional-changelog/commitlint/commit/7ab4bab31f4b19ddedd850e435398037437007b6 --- commitlint/helpers.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/commitlint/helpers.ts b/commitlint/helpers.ts index 3134e621..dc4ee720 100644 --- a/commitlint/helpers.ts +++ b/commitlint/helpers.ts @@ -20,11 +20,8 @@ export abstract class Helpers { potentialString: any, paramName: string ): string | null { - if (potentialString === null || potentialString === undefined) { - // otherwise, String(null) might give us the stupid string "null" - return null; - } - return String(potentialString); + // this null/undefined check is required, otherwise, String(null) might give us the stupid string "null" + return potentialString ? String(potentialString) : null; } public static assertNotNull(