mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 00:03:08 +00:00
fix(lint): use Number.parseInt/parseFloat in terminal-view-attributes
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 <help@stably.ai>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user