mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 00:02:24 +00:00
Enable eleven oxlint rules that simplify code without changing behavior, and fix
every existing violation. Each candidate was gated on measured cost rather than
assumption, so rules that regressed runtime performance or type checking were
dropped instead of suppressed.
typescript/no-redundant-type-constituents is the largest addition: 113 sites, no
autofix. Dead constituents are deleted. Where the redundant literal existed to
document intent (`string | 'all'`), it is preserved as `(string & {})`, which
keeps the autocomplete hint the original code was reaching for instead of
flattening it away. The rule also caught a broken import —
remote-shared-control-retirement-probe.ts pulled RuntimeStatus from
src/shared/types, which does not export it, so the type silently degraded to
`any`; no tsconfig covers that file, so tsc never saw it.
oxlint stays at 1.77.0 rather than 1.78.0 because .npmrc sets
minimum-release-age=4320 and 1.78.0 is younger than that window.
Rules evaluated and rejected, with what disqualified each:
- prefer-string-raw: String.raw is a runtime call, not a literal (184x slower)
- prefer-string-replace-all: 26% slower
- text-encoding-identifier-case: ~5% slower, reproducible
- prefer-spread: [...str] is 110% slower than split('') and differs on surrogates
- no-implicit-coercion: `!!x` narrows types and `Boolean(x)` does not (22 tsc errors)
- prefer-arrow-callback: arrows are not constructible, breaking `new` on mocks
- object-shorthand: rewrites source text asserted by a tracked reliability gate
- switch-case-braces: pushes ten files past max-lines, which cannot be suppressed
- no-useless-switch-case: drops `case undefined:` that switch-exhaustiveness-check needs
- arrow-body-style: 115 violations have no fix, and it breaks max-lines
- newline-after-import: false-positives on the leading-semicolon ASI idiom
electron-vite-output-contract asserted on the literal
Object.prototype.hasOwnProperty.call text; retarget it to Object.hasOwn, which
rejects inherited keys identically.
97 lines
2.7 KiB
JavaScript
97 lines
2.7 KiB
JavaScript
const fs = require('node:fs')
|
|
|
|
const ESC = '\x1b'
|
|
const MOUSE_REPORT_PATTERN = new RegExp(`${ESC}\\[<(64|65);\\d+;\\d+M`, 'g')
|
|
|
|
// Optional flags:
|
|
// --log <path> append "<Date.now()> <reportsInChunk>" per consumed stdin
|
|
// chunk so tests can measure when reports reached the PTY.
|
|
// --heavy emit Claude-Code-scale redraw frames (~4KB of styled cells
|
|
// per render, ~430KB/s at 120 reports/s — matches output
|
|
// volume measured from a real Claude Code session scrolling
|
|
// at 120 reports/s) instead of minimal rows.
|
|
const args = process.argv.slice(2)
|
|
const logIndex = args.indexOf('--log')
|
|
const LOG_PATH = logIndex !== -1 ? args[logIndex + 1] : null
|
|
const HEAVY_FRAMES = args.includes('--heavy')
|
|
|
|
let offset = 0
|
|
let pending = ''
|
|
|
|
function write(data) {
|
|
process.stdout.write(data)
|
|
}
|
|
|
|
function visibleRows() {
|
|
return Math.max(3, process.stdout.rows || 24)
|
|
}
|
|
|
|
function visibleCols() {
|
|
return Math.max(20, process.stdout.columns || 80)
|
|
}
|
|
|
|
function heavyRowFiller(row, cols) {
|
|
// ~19 bytes per 8 visible columns of styled filler.
|
|
const unit = `${ESC}[38;5;${((row * 17) % 200) + 16}m········`
|
|
const units = Math.max(0, Math.floor((cols - 24) / 8))
|
|
return `${unit.repeat(units)}${ESC}[0m`
|
|
}
|
|
|
|
function render() {
|
|
const rows = visibleRows()
|
|
const cols = visibleCols()
|
|
let frame = `${ESC}[?2026h${ESC}[H`
|
|
frame += `TUI_SCROLL_READY offset=${offset}${ESC}[K`
|
|
for (let row = 1; row < rows; row += 1) {
|
|
const label = `TUI_SCROLL_ROW_${String(offset + row - 1).padStart(4, '0')}`
|
|
frame += `\r\n${label}${HEAVY_FRAMES ? ` ${heavyRowFiller(row, cols)}` : ''}${ESC}[K`
|
|
}
|
|
frame += `${ESC}[?2026l`
|
|
write(frame)
|
|
}
|
|
|
|
function cleanup() {
|
|
write(`${ESC}[?1003l${ESC}[?1006l${ESC}[?25h${ESC}[?1049l`)
|
|
process.exit(0)
|
|
}
|
|
|
|
process.stdin.setEncoding('utf8')
|
|
if (process.stdin.isTTY) {
|
|
process.stdin.setRawMode(true)
|
|
}
|
|
process.stdin.resume()
|
|
|
|
write(`${ESC}[?1049h${ESC}[?1003h${ESC}[?1006h${ESC}[?25l${ESC}[2J`)
|
|
render()
|
|
|
|
process.stdin.on('data', (chunk) => {
|
|
if (chunk.includes('\x03') || chunk.includes('q')) {
|
|
cleanup()
|
|
}
|
|
|
|
pending += chunk.toString()
|
|
let match
|
|
let lastIndex = 0
|
|
let reportsInChunk = 0
|
|
|
|
MOUSE_REPORT_PATTERN.lastIndex = 0
|
|
while ((match = MOUSE_REPORT_PATTERN.exec(pending)) !== null) {
|
|
offset = Math.max(0, offset + (match[1] === '65' ? 1 : -1))
|
|
reportsInChunk += 1
|
|
lastIndex = MOUSE_REPORT_PATTERN.lastIndex
|
|
}
|
|
|
|
if (lastIndex > 0) {
|
|
if (LOG_PATH) {
|
|
fs.appendFileSync(LOG_PATH, `${Date.now()} ${reportsInChunk}\n`)
|
|
}
|
|
pending = pending.slice(lastIndex)
|
|
render()
|
|
return
|
|
}
|
|
|
|
pending = pending.slice(-32)
|
|
})
|
|
|
|
process.on('SIGINT', cleanup)
|