mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +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.
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawnSync } from 'node:child_process'
|
|
import { existsSync, mkdirSync } from 'node:fs'
|
|
import { dirname, join, resolve } from 'node:path'
|
|
|
|
if (process.platform !== 'win32') {
|
|
// Why: electron-builder treats a skipped native build like success and can
|
|
// continue toward a Windows package whose declared orca.exe does not exist.
|
|
throw new Error(
|
|
'Windows CLI launcher compilation requires a Windows host; refusing to package without it.'
|
|
)
|
|
}
|
|
|
|
const repoRoot = resolve(import.meta.dirname, '../..')
|
|
const sourcePath = join(repoRoot, 'native', 'windows-cli-launcher', 'OrcaCliLauncher.cs')
|
|
const outputPath = readArg('--output') ?? defaultOutputPath(repoRoot)
|
|
const compilerPath = findFrameworkCompiler(process.env)
|
|
|
|
if (!compilerPath) {
|
|
throw new Error('Unable to find the .NET Framework C# compiler required for orca.exe.')
|
|
}
|
|
|
|
mkdirSync(dirname(outputPath), { recursive: true })
|
|
const result = spawnSync(
|
|
compilerPath,
|
|
['/nologo', '/target:exe', '/optimize+', '/warnaserror+', `/out:${outputPath}`, sourcePath],
|
|
{ cwd: repoRoot, stdio: 'inherit' }
|
|
)
|
|
|
|
if (result.signal) {
|
|
process.kill(process.pid, result.signal)
|
|
}
|
|
if (result.error) {
|
|
throw result.error
|
|
}
|
|
if (result.status !== 0) {
|
|
process.exit(result.status ?? 1)
|
|
}
|
|
|
|
function defaultOutputPath(projectRoot) {
|
|
return join(projectRoot, 'native', 'windows-cli-launcher', '.build', 'orca.exe')
|
|
}
|
|
|
|
function findFrameworkCompiler(env) {
|
|
const windowsDirectory = env.WINDIR ?? env.SystemRoot
|
|
if (!windowsDirectory) {
|
|
return null
|
|
}
|
|
const candidates = [
|
|
join(windowsDirectory, 'Microsoft.NET', 'Framework64', 'v4.0.30319', 'csc.exe'),
|
|
join(windowsDirectory, 'Microsoft.NET', 'Framework', 'v4.0.30319', 'csc.exe')
|
|
]
|
|
return candidates.find((candidate) => existsSync(candidate)) ?? null
|
|
}
|
|
|
|
function readArg(name) {
|
|
const index = process.argv.indexOf(name)
|
|
return index !== -1 ? process.argv[index + 1] : undefined
|
|
}
|