From 1af7e58ae03608e17fb0a08a70a1efe2a3121d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TATSUNO=20=E2=80=9CTaz=E2=80=9D=20Yasuhiro?= Date: Fri, 1 Nov 2024 10:22:08 +0900 Subject: [PATCH] refactor: compare with undefined directly (#3602) --- src/router/reg-exp-router/trie.ts | 4 ++-- src/utils/color.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/router/reg-exp-router/trie.ts b/src/router/reg-exp-router/trie.ts index d7b146cf..39bf99f7 100644 --- a/src/router/reg-exp-router/trie.ts +++ b/src/router/reg-exp-router/trie.ts @@ -57,11 +57,11 @@ export class Trie { const paramReplacementMap: ReplacementMap = [] regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex) => { - if (typeof handlerIndex !== 'undefined') { + if (handlerIndex !== undefined) { indexReplacementMap[++captureIndex] = Number(handlerIndex) return '$()' } - if (typeof paramIndex !== 'undefined') { + if (paramIndex !== undefined) { paramReplacementMap[Number(paramIndex)] = ++captureIndex return '' } diff --git a/src/utils/color.ts b/src/utils/color.ts index 7e6d7b8b..522d3460 100644 --- a/src/utils/color.ts +++ b/src/utils/color.ts @@ -17,7 +17,7 @@ export function getColorEnabled(): boolean { const isNoColor = typeof Deno?.noColor === 'boolean' ? (Deno.noColor as boolean) - : typeof process !== 'undefined' + : process !== undefined ? // eslint-disable-next-line no-unsafe-optional-chaining 'NO_COLOR' in process?.env : false