mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
The rule rejects the broad `object` type on any function input (declarations, expressions, arrows, methods, call/construct signatures, function types), plus local aliases and unions that resolve to `object`. `object` accepts every non-primitive while exposing no properties, so it documents nothing and pushes callers into assertions at the boundary. Fixes all 185 violations across src, config, tests and mobile, and flips the rule from "off" to "error" in config/oxlint-anti-slop.json. Approach: replace each `object` input with the type its owner already has. Most sites took an existing domain type or a type-only import (36 added); 40 new aliases name shapes that had none. Where a value is genuinely only compared by reference, it gets a named identity token instead of a shape -- `Record<string, never>`, the built-in `WeakKey`, or a `unique symbol` brand, matching the branding already used in src/shared. Same treatment for WeakMap and Map key parameters. Two `as unknown as` casts became unnecessary once the parameter carried a real type and were removed; no new casts were added. Suppressions added: none. No `oxlint-disable` for this rule anywhere, and no max-lines disable or per-file bump. Three files sat exactly at their max-lines cap, so the added type imports were made line-neutral rather than suppressed: - src/main/ipc/browser.ts exports the existing guest-registration args type (renamed BrowserGuestArgs) so browser.test.ts reuses it on one line. - pane-scroll.ts takes TerminalScrollIntentTarget through the existing pane-manager-types import via a type-only re-export. - direct-rpc-client.ts drops the identity parameter entirely: the session check moved into the sendProbe callback that owns the token. Verified: anti-slop config reports zero violations over src config tests mobile; run-typecheck-projects-in-parallel exits 0; 144 affected test files pass (1749 tests); oxlint and oxfmt clean on all changed files. Mobile has no runnable test/typecheck target in this worktree (expo is not installed), so its 6 files were typechecked against a standalone config and diffed against the base branch -- error sets are byte-identical, including test files.
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { GitCapabilityCache } from '../../shared/git-capability-cache'
|
|
import type { SshGitProvider } from '../providers/ssh-git-provider'
|
|
import { parseWslUncPath } from '../../shared/wsl-paths'
|
|
import {
|
|
isWslLinkedWorktreeGitRoutingCandidate,
|
|
prepareWslLinkedWorktreeGitRouting
|
|
} from './wsl-linked-worktree-git-routing'
|
|
|
|
type LocalGitCapabilityTarget = {
|
|
cwd?: string
|
|
wslDistro?: string
|
|
signal?: AbortSignal
|
|
}
|
|
|
|
const localCapabilitiesByExecutionHost = new Map<string, GitCapabilityCache>()
|
|
// Why: reconnecting creates a new provider, while concurrent IPC/runtime users
|
|
// of one SSH connection must share the same remote Git capability results.
|
|
let sshCapabilitiesByProvider = new WeakMap<SshGitProvider, GitCapabilityCache>()
|
|
|
|
function getLocalGitExecutionHostKey(target: LocalGitCapabilityTarget): string {
|
|
const wslDistro =
|
|
target.wslDistro ?? (target.cwd ? parseWslUncPath(target.cwd)?.distro : undefined)
|
|
return wslDistro ? `wsl:${wslDistro}` : 'local'
|
|
}
|
|
|
|
export function getLocalGitCapabilityCache(
|
|
target: LocalGitCapabilityTarget = {}
|
|
): GitCapabilityCache {
|
|
const executionHost = getLocalGitExecutionHostKey(target)
|
|
let cache = localCapabilitiesByExecutionHost.get(executionHost)
|
|
if (!cache) {
|
|
cache = new GitCapabilityCache()
|
|
localCapabilitiesByExecutionHost.set(executionHost, cache)
|
|
}
|
|
return cache
|
|
}
|
|
|
|
export function withLocalGitCapabilityCacheForExecution<T>(
|
|
target: LocalGitCapabilityTarget,
|
|
run: (capabilities: GitCapabilityCache) => Promise<T>
|
|
): Promise<T> {
|
|
if (!target.cwd || !isWslLinkedWorktreeGitRoutingCandidate(target.cwd, target.wslDistro)) {
|
|
try {
|
|
return run(getLocalGitCapabilityCache(target))
|
|
} catch (error) {
|
|
return Promise.reject(error)
|
|
}
|
|
}
|
|
return prepareWslLinkedWorktreeGitRouting(target.cwd, target.wslDistro, {
|
|
signal: target.signal
|
|
}).then((usesHostGit) =>
|
|
run(
|
|
getLocalGitCapabilityCache(
|
|
usesHostGit ? { cwd: target.cwd } : { cwd: target.cwd, wslDistro: target.wslDistro }
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
export function getSshGitCapabilityCache(provider: SshGitProvider): GitCapabilityCache {
|
|
let cache = sshCapabilitiesByProvider.get(provider)
|
|
if (!cache) {
|
|
cache = new GitCapabilityCache()
|
|
sshCapabilitiesByProvider.set(provider, cache)
|
|
}
|
|
return cache
|
|
}
|
|
|
|
export function clearGitCapabilityStateForTests(): void {
|
|
localCapabilitiesByExecutionHost.clear()
|
|
sshCapabilitiesByProvider = new WeakMap()
|
|
}
|