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,101 +1,89 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { renderHook, waitFor, act } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { MemoryRouter, useLocation } from 'react-router-dom'
import { useEffect, type ReactNode } from 'react'
import { act, screen, waitFor } from '@testing-library/react'
import { useLocation } from 'react-router-dom'
import { describe, expect, it } from 'vitest'
import { useResolveConflictsWithAgent } from './useResolveConflictsWithAgent'
import { renderHookWithProviders } from '@/test/render'
import { makeSession } from '@/test/fixtures/api'
import type { FetchRoute } from '@/test/fetchFake'
const mocks = vi.hoisted(() => ({
createSessionWithPrompt: vi.fn(),
}))
const hookProviders = {
auth: false,
theme: false,
tts: false,
initialEntries: ['/repos/1'],
} as const
vi.mock('@/api/opencode', () => ({
createSessionWithPrompt: mocks.createSessionWithPrompt,
}))
const createdSession = makeSession({ id: 'ses_new', location: { directory: '/abs/repos/my-repo' } })
const toastMocks = vi.hoisted(() => ({ error: vi.fn() }))
vi.mock('@/lib/toast', () => ({
showToast: { error: toastMocks.error },
}))
const locationRef: { current: string } = { current: '' }
function LocationProbe() {
const location = useLocation()
useEffect(() => {
locationRef.current = location.pathname
})
return null
const promptRoute: FetchRoute = {
method: 'POST',
path: '/api/opencode/api/session/ses_new/prompt',
respond: () => ({
json: {
data: {
id: 'inbox_1',
sessionID: 'ses_new',
time: { created: 1 },
type: 'user',
payload: { text: 'prompt' },
delivery: 'queue',
},
},
}),
}
function createWrapper(queryClient: QueryClient) {
return function Wrapper({ children }: { children: ReactNode }) {
return (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={['/repos/1']}>
<LocationProbe />
{children}
</MemoryRouter>
</QueryClientProvider>
)
}
function renderResolve(createRespond: FetchRoute['respond']) {
return renderHookWithProviders(
() => ({
resolve: useResolveConflictsWithAgent({ id: 1, fullPath: '/abs/repos/my-repo' }),
location: useLocation(),
}),
{
...hookProviders,
fetchRoutes: [
{ method: 'POST', path: '/api/opencode/api/session', respond: createRespond },
promptRoute,
],
},
)
}
describe('useResolveConflictsWithAgent', () => {
let queryClient: QueryClient
beforeEach(() => {
vi.clearAllMocks()
locationRef.current = '/repos/1'
queryClient = new QueryClient({
defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
})
mocks.createSessionWithPrompt.mockResolvedValue({ id: 'ses_new' })
})
const renderResolve = () =>
renderHook(() => useResolveConflictsWithAgent({ id: 1, fullPath: '/abs/repos/my-repo' }), {
wrapper: createWrapper(queryClient),
})
it('creates one session in the repo directory, sends one prompt, and navigates to it', async () => {
const { result } = renderResolve()
const { result, fetchFake } = renderResolve(() => ({ json: { data: createdSession } }))
await act(async () => {
await result.current.mutateAsync({
await result.current.resolve.mutateAsync({
operation: { kind: 'rebase', conflictedFiles: ['src/a.ts'] },
branch: 'main',
})
})
expect(mocks.createSessionWithPrompt).toHaveBeenCalledTimes(1)
expect(mocks.createSessionWithPrompt).toHaveBeenCalledWith(
{
directory: '/abs/repos/my-repo',
title: 'Resolve rebase conflicts',
},
expect.stringContaining('GIT_EDITOR=true git rebase --continue'),
'local',
)
await waitFor(() => expect(locationRef.current).toBe('/repos/1/sessions/ses_new'))
expect(fetchFake.findRequests('POST', '/api/opencode/api/session')).toHaveLength(1)
expect(fetchFake.lastRequest('POST', '/api/opencode/api/session')?.body).toEqual({
title: 'Resolve rebase conflicts',
location: { directory: '/abs/repos/my-repo' },
})
expect(fetchFake.findRequests('POST', '/api/opencode/api/session/ses_new/prompt')).toHaveLength(1)
expect(fetchFake.lastRequest('POST', '/api/opencode/api/session/ses_new/prompt')?.body).toMatchObject({
text: expect.stringContaining('GIT_EDITOR=true git rebase --continue'),
})
await waitFor(() => expect(result.current.location.pathname).toBe('/repos/1/sessions/ses_new'))
})
it('shows an error without navigating when creating the session fails', async () => {
mocks.createSessionWithPrompt.mockRejectedValue(new Error('gateway timeout'))
const { result } = renderResolve()
const { result } = renderResolve(() => ({ status: 400, json: { message: 'gateway timeout' } }))
await act(async () => {
await expect(
result.current.mutateAsync({
result.current.resolve.mutateAsync({
operation: { kind: 'merge', conflictedFiles: ['file.txt'] },
branch: 'main',
}),
).rejects.toThrow('gateway timeout')
})
expect(mocks.createSessionWithPrompt).toHaveBeenCalledTimes(1)
expect(toastMocks.error).toHaveBeenCalledTimes(1)
expect(locationRef.current).toBe('/repos/1')
expect(await screen.findByText('Could not start conflict resolution: gateway timeout')).toBeInTheDocument()
expect(result.current.location.pathname).toBe('/repos/1')
})
})