diff --git a/config/oxlint-anti-slop.json b/config/oxlint-anti-slop.json index 3e48b189302..d2ac1d35d75 100644 --- a/config/oxlint-anti-slop.json +++ b/config/oxlint-anti-slop.json @@ -38,7 +38,7 @@ "anti-slop/no-shape-in-symbol-names": "off", "anti-slop/no-unknown-parameters": "off", "anti-slop/no-unknown-returns": "off", - "anti-slop/no-unknown-type-aliases": "off", + "anti-slop/no-unknown-type-aliases": "error", "anti-slop/no-unsafe-dictionary-type": "off", "anti-slop/no-widen-then-assert": "error", "anti-slop/require-readable-spacing": "off", diff --git a/src/main/runtime/workspace-session-failed-write-rollback.ts b/src/main/runtime/workspace-session-failed-write-rollback.ts index 4f9e79a03d7..7234446cb9d 100644 --- a/src/main/runtime/workspace-session-failed-write-rollback.ts +++ b/src/main/runtime/workspace-session-failed-write-rollback.ts @@ -2,9 +2,21 @@ import { isDeepStrictEqual } from 'node:util' import type { WorkspaceSessionState } from '../../shared/workspace-session-state-types' const MISSING = Symbol('missing') -type RollbackValue = unknown -function isRecord(value: RollbackValue): value is Record { +/** A JSON-shaped slot of persisted session state, or the absent-key sentinel. */ +type RollbackSlot = + | string + | number + | boolean + | null + | undefined + | typeof MISSING + | readonly RollbackSlot[] + | RollbackRecord + +type RollbackRecord = { readonly [key: string]: RollbackSlot } + +function isRecord(value: RollbackSlot): value is RollbackRecord { return ( value !== MISSING && typeof value === 'object' && @@ -15,10 +27,10 @@ function isRecord(value: RollbackValue): value is Record { } function rollbackValue( - original: RollbackValue, - staged: RollbackValue, - current: RollbackValue -): RollbackValue { + original: RollbackSlot, + staged: RollbackSlot, + current: RollbackSlot +): RollbackSlot { if (isDeepStrictEqual(original, staged)) { return current } @@ -29,7 +41,7 @@ function rollbackValue( return current } let changed = false - const next: Record = { ...current } + const next: Record = { ...current } for (const key of new Set([ ...Object.keys(original), ...Object.keys(staged), diff --git a/src/renderer/src/hooks/direct-ssh-host-hydration.ts b/src/renderer/src/hooks/direct-ssh-host-hydration.ts index 419dc134075..2c326501760 100644 --- a/src/renderer/src/hooks/direct-ssh-host-hydration.ts +++ b/src/renderer/src/hooks/direct-ssh-host-hydration.ts @@ -18,7 +18,7 @@ import { directSshAuthoritiesEqual } from './direct-ssh-reconnect-tokens' export const DIRECT_SSH_HOST_READ_TIMEOUT_MS = 5_000 -type HostReadTimer = unknown +type HostReadTimer = ReturnType export type DirectSshHostHydrationDeps = { store: Pick, 'getState' | 'setState'> @@ -121,7 +121,7 @@ export function createDirectSshHostHydration( const setTimer: NonNullable = deps.setTimer ?? ((callback, delayMs) => setTimeout(callback, delayMs)) const clearTimer: NonNullable = - deps.clearTimer ?? ((timer) => clearTimeout(timer as ReturnType)) + deps.clearTimer ?? ((timer) => clearTimeout(timer)) const catalogRevisionByTarget = new Map() const catalogInFlight = new Map>() const pendingDeadlines = new Set<{ timer: HostReadTimer; settle: () => void }>() diff --git a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-stabilization.ts b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-stabilization.ts index f20ea1e4a30..9924e55d70b 100644 --- a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-stabilization.ts +++ b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-stabilization.ts @@ -5,7 +5,7 @@ export type DirectSshReconnectTargetState = { authority: DirectSshAuthority installedAt: number dampUntil: number | null - timer: DirectSshReconnectTimer + timer: DirectSshReconnectTimer | null } export function createDirectSshReconnectTargetState( diff --git a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-types.ts b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-types.ts index 6cc76174ed1..31dfbe5a8ea 100644 --- a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-types.ts +++ b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator-types.ts @@ -113,7 +113,7 @@ export type DirectSshCoordinatorTelemetry = { damped: boolean } -export type DirectSshReconnectTimer = unknown +export type DirectSshReconnectTimer = ReturnType export type DirectSshReconnectCoordinatorDeps = { scheduler: DirectSshWorktreeRefreshScheduler diff --git a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator.ts b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator.ts index 7ddf3892ff8..01474789f1c 100644 --- a/src/renderer/src/hooks/direct-ssh-reconnect-coordinator.ts +++ b/src/renderer/src/hooks/direct-ssh-reconnect-coordinator.ts @@ -42,9 +42,7 @@ export function createDirectSshReconnectCoordinator( const now = deps.now ?? Date.now const setTimer = deps.setTimer ?? ((callback: () => void, delayMs: number) => setTimeout(callback, delayMs)) - const clearTimer = - deps.clearTimer ?? - ((timer: DirectSshReconnectTimer) => clearTimeout(timer as ReturnType)) + const clearTimer = deps.clearTimer ?? ((timer: DirectSshReconnectTimer) => clearTimeout(timer)) const stabilizationMs = deps.stabilizationMs ?? DIRECT_SSH_RELAY_STABILIZATION_MS const targets = new Map() let stopped = false