chore(lint): replace ESLint with Oxlint and clear anti-slop findings

This commit is contained in:
Chris Scott committed 2026-11-13 01:13:34 -05:00
1 parent c6c13335e5
commit b625acfc0c
1083 files changed
+67089 -80136

No files matched your search

@@ -1,25 +1,15 @@
import { Database } from 'bun:sqlite'
import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { z } from 'zod'
import { getOpenCodeConfigFilePath, getOpenCodeConfigHome } from '@opencode-manager/shared/config/env'
import { migrate } from '../../src/db/migration-runner'
import { allMigrations } from '../../src/db/migrations'
import { selectRow, selectTableColumns } from '../../src/db/rows'
import { applyTestEnv, createTempWorkspace, type TempWorkspace } from '../helpers/test-env'
const paths = vi.hoisted(() => ({
workDir: '',
configHome: '',
configFile: '',
}))
vi.mock('@opencode-manager/shared/config/env', async (importOriginal) => ({
...(await importOriginal()),
getOpenCodeConfigHome: () => paths.configHome,
getOpenCodeConfigFilePath: () => paths.configFile,
}))
const originalHome = process.env.HOME
const originalImportConfigPath = process.env.OPENCODE_IMPORT_CONFIG_PATH
const TableNameRowSchema = z.object({ name: z.string() })
function migrateToV18(db: Database): void {
migrate(db, allMigrations.filter(migration => (migration.legacy?.version ?? Infinity) < 19))
@@ -30,27 +20,26 @@ function insertConfig(db: Database, name: string, content: string, isDefault: bo
.run('default', name, content, isDefault ? 1 : 0, Date.now(), Date.now())
}
function tableExists(db: Database, table: string): boolean {
return selectRow(db, TableNameRowSchema, "SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?", table) !== null
}
function archiveDir(): string {
return path.join(getOpenCodeConfigHome(), 'opencode-configs-archive')
}
describe('019-drop-opencode-configs', () => {
beforeEach(async () => {
paths.workDir = await mkdtemp(path.join(tmpdir(), 'opencode-config-migration-'))
paths.configHome = path.join(paths.workDir, '.config')
paths.configFile = path.join(paths.configHome, 'opencode', 'opencode.json')
process.env.HOME = paths.workDir
delete process.env.OPENCODE_IMPORT_CONFIG_PATH
let workspace: TempWorkspace
let restoreEnv: () => void
beforeEach(() => {
workspace = createTempWorkspace('opencode-config-migration-')
restoreEnv = applyTestEnv({ HOME: workspace.path, OPENCODE_IMPORT_CONFIG_PATH: undefined })
})
afterEach(async () => {
await rm(paths.workDir, { recursive: true, force: true })
if (originalHome === undefined) {
delete process.env.HOME
} else {
process.env.HOME = originalHome
}
if (originalImportConfigPath === undefined) {
delete process.env.OPENCODE_IMPORT_CONFIG_PATH
} else {
process.env.OPENCODE_IMPORT_CONFIG_PATH = originalImportConfigPath
}
afterEach(() => {
restoreEnv()
workspace.restore()
})
it('archives rows, restores the default file, and drops the table and column', async () => {
@@ -64,12 +53,11 @@ describe('019-drop-opencode-configs', () => {
migrate(db, allMigrations)
expect(db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'opencode_configs'").get()).toBeUndefined()
const columns = (db.prepare('PRAGMA table_info(repos)').all() as Array<{ name: string }>).map(column => column.name)
expect(columns).not.toContain('opencode_config_name')
expect(await readFile(path.join(paths.configHome, 'opencode-configs-archive', 'default.json'), 'utf8')).toBe(defaultContent)
expect(await readFile(path.join(paths.configHome, 'opencode-configs-archive', 'team_main_config.json'), 'utf8')).toBe(namedContent)
expect(await readFile(paths.configFile, 'utf8')).toBe(defaultContent)
expect(tableExists(db, 'opencode_configs')).toBe(false)
expect(selectTableColumns(db, 'repos').map(column => column.name)).not.toContain('opencode_config_name')
expect(await readFile(path.join(archiveDir(), 'default.json'), 'utf8')).toBe(defaultContent)
expect(await readFile(path.join(archiveDir(), 'team_main_config.json'), 'utf8')).toBe(namedContent)
expect(await readFile(getOpenCodeConfigFilePath(), 'utf8')).toBe(defaultContent)
})
it('leaves an existing opencode.json byte-identical', async () => {
@@ -80,12 +68,12 @@ describe('019-drop-opencode-configs', () => {
insertConfig(db, 'default', defaultContent, true)
const existingContent = '{\n // keep me\n "model": "existing"\n}\n'
await mkdir(path.dirname(paths.configFile), { recursive: true })
await writeFile(paths.configFile, existingContent)
await mkdir(path.dirname(getOpenCodeConfigFilePath()), { recursive: true })
await writeFile(getOpenCodeConfigFilePath(), existingContent)
migrate(db, allMigrations)
expect(await readFile(paths.configFile, 'utf8')).toBe(existingContent)
expect(await readFile(getOpenCodeConfigFilePath(), 'utf8')).toBe(existingContent)
})
it('does not create the config file when an import source exists', async () => {
@@ -95,13 +83,13 @@ describe('019-drop-opencode-configs', () => {
const defaultContent = JSON.stringify({ model: 'default' })
insertConfig(db, 'default', defaultContent, true)
const importSource = path.join(paths.workDir, 'import-source.json')
const importSource = path.join(workspace.path, 'import-source.json')
await writeFile(importSource, '{}')
process.env.OPENCODE_IMPORT_CONFIG_PATH = importSource
migrate(db, allMigrations)
await expect(readFile(paths.configFile, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' })
await expect(readFile(getOpenCodeConfigFilePath(), 'utf8')).rejects.toMatchObject({ code: 'ENOENT' })
})
it('keeps every profile when sanitized names collide or the archive destination already exists', async () => {
@@ -115,16 +103,15 @@ describe('019-drop-opencode-configs', () => {
insertConfig(db, 'team_main_config', secondContent, false)
insertConfig(db, 'team_main_config-1', suffixedContent, false)
const archiveDir = path.join(paths.configHome, 'opencode-configs-archive')
await mkdir(archiveDir, { recursive: true })
await mkdir(archiveDir(), { recursive: true })
const preExistingContent = JSON.stringify({ model: 'pre-existing' })
await writeFile(path.join(archiveDir, 'team_main_config.json'), preExistingContent)
await writeFile(path.join(archiveDir(), 'team_main_config.json'), preExistingContent)
migrate(db, allMigrations)
expect(await readFile(path.join(archiveDir, 'team_main_config.json'), 'utf8')).toBe(preExistingContent)
expect(await readFile(path.join(archiveDir(), 'team_main_config.json'), 'utf8')).toBe(preExistingContent)
const archivedContents = await Promise.all(
(await readdir(archiveDir)).map(file => readFile(path.join(archiveDir, file), 'utf8'))
(await readdir(archiveDir())).map(file => readFile(path.join(archiveDir(), file), 'utf8')),
)
expect(archivedContents).toHaveLength(4)
expect(new Set(archivedContents).size).toBe(4)