mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
chore(lint): replace ESLint with Oxlint and clear anti-slop findings
This commit is contained in:
1 parent
c6c13335e5
commit
b625acfc0c
1083 files changed
+67089
-80136
No files matched your search
@@ -5,16 +5,19 @@ import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
import * as http from 'http'
|
||||
import { randomUUID } from 'crypto'
|
||||
import { z } from 'zod'
|
||||
import { createIPCServer } from '../../src/ipc/ipcServer'
|
||||
import type { IPCServer } from '../../src/ipc/ipcServer'
|
||||
import { repoRoot } from '../helpers/repo-root'
|
||||
|
||||
interface CapturedRequest {
|
||||
askpassType: string
|
||||
argv: string[]
|
||||
cwd?: string
|
||||
repoId?: number
|
||||
}
|
||||
const CapturedRequestSchema = z.object({
|
||||
askpassType: z.string(),
|
||||
argv: z.array(z.string()),
|
||||
cwd: z.string().optional(),
|
||||
repoId: z.number().optional(),
|
||||
})
|
||||
|
||||
type CapturedRequest = z.infer<typeof CapturedRequestSchema>
|
||||
|
||||
const scriptPath = join(repoRoot, 'backend/scripts/askpass-main.ts')
|
||||
|
||||
@@ -133,7 +136,7 @@ describe('askpass-main', () => {
|
||||
let received: CapturedRequest | undefined
|
||||
server.registerHandler('askpass', {
|
||||
handle: async (request) => {
|
||||
received = request as CapturedRequest
|
||||
received = CapturedRequestSchema.parse(request)
|
||||
return 'secret-token'
|
||||
},
|
||||
})
|
||||
@@ -236,10 +239,15 @@ async function runAskpassInProcess(overrides: Record<string, string | undefined>
|
||||
resolveExit = resolve
|
||||
})
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(((code?: number) => {
|
||||
resolveExit(code)
|
||||
return undefined as never
|
||||
}) as typeof process.exit)
|
||||
const originalExit = process.exit
|
||||
Object.defineProperty(process, 'exit', {
|
||||
value: (code?: string | number | null) => {
|
||||
const exitCode = z.number().safeParse(code)
|
||||
resolveExit(exitCode.success ? exitCode.data : undefined)
|
||||
},
|
||||
configurable: true,
|
||||
writable: true,
|
||||
})
|
||||
|
||||
vi.resetModules()
|
||||
try {
|
||||
@@ -247,7 +255,7 @@ async function runAskpassInProcess(overrides: Record<string, string | undefined>
|
||||
const code = await exitPromise
|
||||
return { code, output: existsSync(outputPath) ? readFileSync(outputPath, 'utf-8') : undefined }
|
||||
} finally {
|
||||
exitSpy.mockRestore()
|
||||
Object.defineProperty(process, 'exit', { value: originalExit, configurable: true, writable: true })
|
||||
errorSpy.mockRestore()
|
||||
for (const key of askpassEnvKeys) {
|
||||
const previous = previousEnv[key]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { z } from 'zod'
|
||||
import { readFileSync, mkdtempSync, mkdirSync, writeFileSync, rmSync, readdirSync, statSync, existsSync, chmodSync } from 'fs'
|
||||
import { execFileSync, execSync, spawnSync } from 'child_process'
|
||||
import { join } from 'path'
|
||||
@@ -394,7 +395,7 @@ describe('sandbox guest image', () => {
|
||||
stdio: 'pipe',
|
||||
})
|
||||
} catch (error) {
|
||||
status = (error as { status?: number }).status ?? 1
|
||||
status = z.object({ status: z.number().optional() }).safeParse(error).data?.status ?? 1
|
||||
}
|
||||
|
||||
expect(status, 'a failed cargo build must abort the verification script').not.toBe(0)
|
||||
|
||||
Reference in new issue
Block a user