From c0b7dccfa7feb563bfe2ae389bad349167ad5f5f Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Wed, 8 Jul 2026 21:01:20 -0400 Subject: [PATCH] fix(lint): use Number.parseInt/parseFloat in terminal-view-attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit oxlint unicorn(prefer-number-properties) flagged 24 global parseInt/parseFloat calls in the terminal-view-attributes feature (ee540f32d, perf-branch only), failing PR Checks 'verify' lint. Mechanical global→Number.* rewrite via oxlint --fix; behaviorally identical. Pre-existed the latest main merge. Co-authored-by: Orca --- .../terminal-view-attribute-responder.ts | 8 ++--- .../terminal-view-attributes-publisher.ts | 36 ++++++++++--------- src/shared/terminal-view-attributes.ts | 8 ++--- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/main/daemon/terminal-view-attribute-responder.ts b/src/main/daemon/terminal-view-attribute-responder.ts index 551ffddbe21..68ff83c349f 100644 --- a/src/main/daemon/terminal-view-attribute-responder.ts +++ b/src/main/daemon/terminal-view-attribute-responder.ts @@ -110,10 +110,10 @@ export function installTerminalViewAttributeResponder( while (slots.length > 1) { const idx = slots.shift() as string const spec = slots.shift() as string - if (!/^\d+$/.exec(idx)) { + if (!/^\d+$/.test(idx)) { continue } - const index = parseInt(idx, 10) + const index = Number.parseInt(idx, 10) if (!isValidColorIndex(index)) { continue } @@ -143,8 +143,8 @@ export function installTerminalViewAttributeResponder( return true } for (const slot of data.split(';')) { - if (/^\d+$/.exec(slot)) { - ansiOverrides.delete(parseInt(slot, 10)) + if (/^\d+$/.test(slot)) { + ansiOverrides.delete(Number.parseInt(slot, 10)) } } return true diff --git a/src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.ts b/src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.ts index 05970b77725..304ff399f6c 100644 --- a/src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.ts +++ b/src/renderer/src/components/terminal-pane/terminal-view-attributes-publisher.ts @@ -97,38 +97,38 @@ export function parseCssColor(css: string): ParsedCssColor | null { case 4: return { rgb: [ - parseInt(css.slice(1, 2).repeat(2), 16), - parseInt(css.slice(2, 3).repeat(2), 16), - parseInt(css.slice(3, 4).repeat(2), 16) + Number.parseInt(css.slice(1, 2).repeat(2), 16), + Number.parseInt(css.slice(2, 3).repeat(2), 16), + Number.parseInt(css.slice(3, 4).repeat(2), 16) ], alpha: 0xff } case 5: return { rgb: [ - parseInt(css.slice(1, 2).repeat(2), 16), - parseInt(css.slice(2, 3).repeat(2), 16), - parseInt(css.slice(3, 4).repeat(2), 16) + Number.parseInt(css.slice(1, 2).repeat(2), 16), + Number.parseInt(css.slice(2, 3).repeat(2), 16), + Number.parseInt(css.slice(3, 4).repeat(2), 16) ], - alpha: parseInt(css.slice(4, 5).repeat(2), 16) + alpha: Number.parseInt(css.slice(4, 5).repeat(2), 16) } case 7: return { rgb: [ - parseInt(css.slice(1, 3), 16), - parseInt(css.slice(3, 5), 16), - parseInt(css.slice(5, 7), 16) + Number.parseInt(css.slice(1, 3), 16), + Number.parseInt(css.slice(3, 5), 16), + Number.parseInt(css.slice(5, 7), 16) ], alpha: 0xff } case 9: return { rgb: [ - parseInt(css.slice(1, 3), 16), - parseInt(css.slice(3, 5), 16), - parseInt(css.slice(5, 7), 16) + Number.parseInt(css.slice(1, 3), 16), + Number.parseInt(css.slice(3, 5), 16), + Number.parseInt(css.slice(5, 7), 16) ], - alpha: parseInt(css.slice(7, 9), 16) + alpha: Number.parseInt(css.slice(7, 9), 16) } default: return null @@ -139,8 +139,12 @@ export function parseCssColor(css: string): ParsedCssColor | null { ) if (rgbaMatch) { return { - rgb: [parseInt(rgbaMatch[1], 10), parseInt(rgbaMatch[2], 10), parseInt(rgbaMatch[3], 10)], - alpha: Math.round((rgbaMatch[5] === undefined ? 1 : parseFloat(rgbaMatch[5])) * 0xff) + rgb: [ + Number.parseInt(rgbaMatch[1], 10), + Number.parseInt(rgbaMatch[2], 10), + Number.parseInt(rgbaMatch[3], 10) + ], + alpha: Math.round((rgbaMatch[5] === undefined ? 1 : Number.parseFloat(rgbaMatch[5])) * 0xff) } } return null diff --git a/src/shared/terminal-view-attributes.ts b/src/shared/terminal-view-attributes.ts index 736003845dd..fa587a17b5c 100644 --- a/src/shared/terminal-view-attributes.ts +++ b/src/shared/terminal-view-attributes.ts @@ -54,9 +54,9 @@ export function parseXColorSpec(spec: string): TerminalViewRgb | null { if (m) { const base = m[1] ? 15 : m[4] ? 255 : m[7] ? 4095 : 65535 return [ - Math.round((parseInt(m[1] || m[4] || m[7] || m[10], 16) / base) * 255), - Math.round((parseInt(m[2] || m[5] || m[8] || m[11], 16) / base) * 255), - Math.round((parseInt(m[3] || m[6] || m[9] || m[12], 16) / base) * 255) + Math.round((Number.parseInt(m[1] || m[4] || m[7] || m[10], 16) / base) * 255), + Math.round((Number.parseInt(m[2] || m[5] || m[8] || m[11], 16) / base) * 255), + Math.round((Number.parseInt(m[3] || m[6] || m[9] || m[12], 16) / base) * 255) ] } return null @@ -67,7 +67,7 @@ export function parseXColorSpec(spec: string): TerminalViewRgb | null { const adv = low.length / 3 const result: TerminalViewRgb = [0, 0, 0] for (let i = 0; i < 3; ++i) { - const c = parseInt(low.slice(adv * i, adv * i + adv), 16) + const c = Number.parseInt(low.slice(adv * i, adv * i + adv), 16) result[i] = adv === 1 ? c << 4 : adv === 2 ? c : adv === 3 ? c >> 4 : c >> 8 } return result