From 70ac27ec8ef73ca3e2bd06723ab1d2c9ebb7581a Mon Sep 17 00:00:00 2001 From: Bas van Rossem Date: Wed, 17 Jun 2026 21:36:18 +0200 Subject: [PATCH] style: align oxfmt to trailing-comma 'all' and normalize code The repo was authored prettier-style (trailing-comma 'all') but .oxfmtrc.json was set to 'es5', so every formatted file diverged. Switch the config to 'all' to match the existing code, ignore docs/** and **/drizzle/** (prose + generated snapshots the formatter should not own), and reformat the source tree once for consistency. No behavioural change; all suites green (api 60, worker 28, admin 21). --- .oxfmtrc.json | 4 ++-- apps/admin/src/App.test.tsx | 2 +- apps/admin/src/auth/AuthContext.test.tsx | 2 +- apps/admin/src/lib/api.ts | 2 +- apps/admin/src/main.tsx | 2 +- apps/admin/src/screens/Activities.test.tsx | 2 +- apps/admin/src/screens/Activities.tsx | 6 +++--- apps/admin/src/screens/Live.test.tsx | 2 +- apps/admin/src/screens/Live.tsx | 2 +- apps/admin/src/screens/Login.tsx | 2 +- apps/api/src/app.ts | 2 +- apps/api/src/db/schema.ts | 8 ++++---- apps/api/src/lib/work-session.ts | 2 +- apps/api/src/routes/admin.ts | 8 ++++---- apps/api/test/activities.test.ts | 2 +- apps/api/test/export.test.ts | 6 +++--- apps/api/test/helpers.ts | 4 ++-- apps/api/test/seed.test.ts | 2 +- apps/api/test/sessions.test.ts | 2 +- apps/worker/src/App.test.tsx | 2 +- apps/worker/src/auth/AuthContext.test.tsx | 2 +- apps/worker/src/lib/api.test.ts | 5 +---- apps/worker/src/lib/api.ts | 2 +- apps/worker/src/screens/Account.test.tsx | 2 +- apps/worker/src/screens/History.test.tsx | 2 +- apps/worker/src/screens/Stopwatch.test.tsx | 20 ++++++++++---------- apps/worker/src/screens/Stopwatch.tsx | 2 +- 27 files changed, 48 insertions(+), 51 deletions(-) diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 01ad14f..58c9b63 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -6,10 +6,10 @@ "semi": true, "singleQuote": true, "jsxSingleQuote": false, - "trailingComma": "es5", + "trailingComma": "all", "bracketSpacing": true, "bracketSameLine": false, "arrowParens": "always", "endOfLine": "lf", - "ignorePatterns": ["examples/**/*"] + "ignorePatterns": ["examples/**/*", "docs/**", "**/drizzle/**"] } diff --git a/apps/admin/src/App.test.tsx b/apps/admin/src/App.test.tsx index fda4bce..1fa9fbe 100644 --- a/apps/admin/src/App.test.tsx +++ b/apps/admin/src/App.test.tsx @@ -22,7 +22,7 @@ function renderApp() { return render( - + , ); } diff --git a/apps/admin/src/auth/AuthContext.test.tsx b/apps/admin/src/auth/AuthContext.test.tsx index c8193da..b783e56 100644 --- a/apps/admin/src/auth/AuthContext.test.tsx +++ b/apps/admin/src/auth/AuthContext.test.tsx @@ -46,7 +46,7 @@ function renderHarness() { return render( - + , ); } diff --git a/apps/admin/src/lib/api.ts b/apps/admin/src/lib/api.ts index 27b6469..9b053eb 100644 --- a/apps/admin/src/lib/api.ts +++ b/apps/admin/src/lib/api.ts @@ -5,7 +5,7 @@ export const API_URL = import.meta.env.VITE_API_URL ?? 'http://localhost:3000'; export class ApiError extends Error { constructor( public status: number, - message: string + message: string, ) { super(message); this.name = 'ApiError'; diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx index 2fb2974..3381901 100644 --- a/apps/admin/src/main.tsx +++ b/apps/admin/src/main.tsx @@ -11,5 +11,5 @@ createRoot(document.getElementById('root')!).render( - + , ); diff --git a/apps/admin/src/screens/Activities.test.tsx b/apps/admin/src/screens/Activities.test.tsx index 5a6a3bc..264138d 100644 --- a/apps/admin/src/screens/Activities.test.tsx +++ b/apps/admin/src/screens/Activities.test.tsx @@ -41,7 +41,7 @@ function renderActivities() { return render( - + , ); } diff --git a/apps/admin/src/screens/Activities.tsx b/apps/admin/src/screens/Activities.tsx index e3d39ae..36c44f1 100644 --- a/apps/admin/src/screens/Activities.tsx +++ b/apps/admin/src/screens/Activities.tsx @@ -100,7 +100,7 @@ export default function Activities() { setNewName(''); setNewTypes([...ALL_TYPES]); }, - } + }, ); } @@ -118,13 +118,13 @@ export default function Activities() { if (editName.trim().length === 0 || editTypes.length === 0) return; updateActivity.mutate( { id, input: { name: editName.trim(), insole_types: editTypes } }, - { onSuccess: () => setEditingId(null) } + { onSuccess: () => setEditingId(null) }, ); } function handleDelete(id: number, name: string) { const ok = window.confirm( - `"${name}" verwijderen? Alle tijdsregistraties voor deze taak worden ook verwijderd.` + `"${name}" verwijderen? Alle tijdsregistraties voor deze taak worden ook verwijderd.`, ); if (ok) deleteActivity.mutate(id); } diff --git a/apps/admin/src/screens/Live.test.tsx b/apps/admin/src/screens/Live.test.tsx index f99e7eb..63a9428 100644 --- a/apps/admin/src/screens/Live.test.tsx +++ b/apps/admin/src/screens/Live.test.tsx @@ -38,7 +38,7 @@ function renderLive() { return render( - + , ); } diff --git a/apps/admin/src/screens/Live.tsx b/apps/admin/src/screens/Live.tsx index 782b4a7..1792492 100644 --- a/apps/admin/src/screens/Live.tsx +++ b/apps/admin/src/screens/Live.tsx @@ -54,7 +54,7 @@ function LiveCard({ session, now }: { session: WorkSession; now: number }) { const base = session.paused_at ? Date.parse(session.paused_at) : now; const worked = Math.max( 0, - Math.floor((base - Date.parse(session.start_time)) / 1000) - session.paused_seconds + Math.floor((base - Date.parse(session.start_time)) / 1000) - session.paused_seconds, ); return (
diff --git a/apps/admin/src/screens/Login.tsx b/apps/admin/src/screens/Login.tsx index b0ff77c..c313cc1 100644 --- a/apps/admin/src/screens/Login.tsx +++ b/apps/admin/src/screens/Login.tsx @@ -16,7 +16,7 @@ export default function Login() { await signIn(email, password); } catch (err) { setError( - err instanceof NotAdminError ? 'Geen toegang — alleen beheerders.' : 'Inloggen mislukt' + err instanceof NotAdminError ? 'Geen toegang — alleen beheerders.' : 'Inloggen mislukt', ); } finally { setBusy(false); diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index 8fcc9b4..7d264d8 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -18,7 +18,7 @@ export function createApp(): Hono { allowHeaders: ['Content-Type', 'Authorization'], exposeHeaders: ['set-auth-token'], // so the SPA can read the bearer token on sign-in credentials: true, - }) + }), ); app.route('/', health); app.on(['POST', 'GET'], '/api/auth/*', (c) => auth.handler(c.req.raw)); diff --git a/apps/api/src/db/schema.ts b/apps/api/src/db/schema.ts index ffe1c49..712b750 100644 --- a/apps/api/src/db/schema.ts +++ b/apps/api/src/db/schema.ts @@ -45,7 +45,7 @@ export const session = sqliteTable( }, (table) => ({ sessionUserIdIdx: index('session_userId_idx').on(table.userId), - }) + }), ); export const account = sqliteTable( @@ -73,7 +73,7 @@ export const account = sqliteTable( }, (table) => ({ accountUserIdIdx: index('account_userId_idx').on(table.userId), - }) + }), ); export const verification = sqliteTable( @@ -93,7 +93,7 @@ export const verification = sqliteTable( }, (table) => ({ verificationIdentifierIdx: index('verification_identifier_idx').on(table.identifier), - }) + }), ); export const userRelations = relations(user, ({ many }) => ({ @@ -157,5 +157,5 @@ export const workSessions = sqliteTable( (table) => ({ workSessionsUserIdIdx: index('work_sessions_userId_idx').on(table.userId), workSessionsStartTimeIdx: index('work_sessions_startTime_idx').on(table.startTime), - }) + }), ); diff --git a/apps/api/src/lib/work-session.ts b/apps/api/src/lib/work-session.ts index e8c4b69..668162b 100644 --- a/apps/api/src/lib/work-session.ts +++ b/apps/api/src/lib/work-session.ts @@ -5,7 +5,7 @@ type WorkSessionRow = typeof workSessions.$inferSelect; export function toWorkSession( row: WorkSessionRow, - opts: { activityName?: string | null; userName?: string | null; userEmail?: string | null } = {} + opts: { activityName?: string | null; userName?: string | null; userEmail?: string | null } = {}, ): WorkSession { return { id: row.id, diff --git a/apps/api/src/routes/admin.ts b/apps/api/src/routes/admin.ts index e6c08a5..228cdc3 100644 --- a/apps/api/src/routes/admin.ts +++ b/apps/api/src/routes/admin.ts @@ -35,8 +35,8 @@ adminRoutes.get('/api/admin/sessions', async (c) => { activityName: r.activityName, userName: r.userName, userEmail: r.userEmail, - }) - ) + }), + ), ); }); @@ -54,7 +54,7 @@ adminRoutes.get('/api/admin/sessions/active', async (c) => { activityName: r.activityName, userName: r.userName, userEmail: r.userEmail, - }) - ) + }), + ), ); }); diff --git a/apps/api/test/activities.test.ts b/apps/api/test/activities.test.ts index a28d47b..e52e27c 100644 --- a/apps/api/test/activities.test.ts +++ b/apps/api/test/activities.test.ts @@ -236,7 +236,7 @@ describe('activities routes', () => { expect(after.map((r) => r.id)).toEqual(ids); // In particular, b now precedes a. expect(after.findIndex((r) => r.id === b.id)).toBeLessThan( - after.findIndex((r) => r.id === a.id) + after.findIndex((r) => r.id === a.id), ); }); diff --git a/apps/api/test/export.test.ts b/apps/api/test/export.test.ts index 947ce92..8e3f042 100644 --- a/apps/api/test/export.test.ts +++ b/apps/api/test/export.test.ts @@ -14,7 +14,7 @@ async function completedSession( token: string, activityId: number, insoleType: string, - durationSeconds: number + durationSeconds: number, ): Promise { const startRes = await app.request('/api/sessions/start', { method: 'POST', @@ -47,13 +47,13 @@ describe('csv export', () => { expect(res.status).toBe(200); expect(res.headers.get('content-type')).toContain('text/csv'); expect(res.headers.get('content-disposition')).toBe( - 'attachment; filename="insole-production-report.csv"' + 'attachment; filename="insole-production-report.csv"', ); const text = await res.text(); const lines = text.split('\n'); expect(lines[0]).toBe( - '"ID","Task","Insole Type","No. of Insoles","Date","Total Duration","Paused Duration","Start Time","End Time"' + '"ID","Task","Insole Type","No. of Insoles","Date","Total Duration","Paused Duration","Start Time","End Time"', ); expect(lines).toHaveLength(2); expect(lines[1]).toContain('"Frezen"'); diff --git a/apps/api/test/helpers.ts b/apps/api/test/helpers.ts index 1cf46ec..2576b07 100644 --- a/apps/api/test/helpers.ts +++ b/apps/api/test/helpers.ts @@ -27,7 +27,7 @@ export async function createTestUser(email: string, role: 'worker' | 'admin' = ' export async function authToken( app: Hono, email: string, - role: 'worker' | 'admin' = 'worker' + role: 'worker' | 'admin' = 'worker', ): Promise { await createTestUser(email, role); const signin = await app.request('/api/auth/sign-in/email', { @@ -47,7 +47,7 @@ export function bearer(token: string): Record { // Insert an activity straight into the DB (test setup that should not depend on authz). export async function seedActivity( name: string, - insoleTypes: string[] = ['Kurk', 'Berk', '3D'] + insoleTypes: string[] = ['Kurk', 'Berk', '3D'], ): Promise { const [row] = await db.insert(activities).values({ name, insoleTypes }).returning(); return row.id; diff --git a/apps/api/test/seed.test.ts b/apps/api/test/seed.test.ts index e1b8ba8..392b237 100644 --- a/apps/api/test/seed.test.ts +++ b/apps/api/test/seed.test.ts @@ -33,7 +33,7 @@ describe('seed', () => { await seed(); expect(await db.select().from(user).where(eq(user.email, 'admin@solelog.local'))).toHaveLength( - 1 + 1, ); }); }); diff --git a/apps/api/test/sessions.test.ts b/apps/api/test/sessions.test.ts index 6decbde..a005c27 100644 --- a/apps/api/test/sessions.test.ts +++ b/apps/api/test/sessions.test.ts @@ -378,7 +378,7 @@ describe('session reads', () => { const body = await res.json(); expect(body).toHaveLength(2); expect(new Date(body[0].start_time).getTime()).toBeGreaterThan( - new Date(body[1].start_time).getTime() + new Date(body[1].start_time).getTime(), ); expect(body[0].activity_name).toBe('Slijpen'); expect(body[1].activity_name).toBe('Frezen'); diff --git a/apps/worker/src/App.test.tsx b/apps/worker/src/App.test.tsx index f0b71a9..3cbcae5 100644 --- a/apps/worker/src/App.test.tsx +++ b/apps/worker/src/App.test.tsx @@ -18,7 +18,7 @@ function renderApp() { return render( - + , ); } diff --git a/apps/worker/src/auth/AuthContext.test.tsx b/apps/worker/src/auth/AuthContext.test.tsx index 42eb116..5ac42f5 100644 --- a/apps/worker/src/auth/AuthContext.test.tsx +++ b/apps/worker/src/auth/AuthContext.test.tsx @@ -39,7 +39,7 @@ describe('AuthContext signOut', () => { render( - + , ); await user.click(screen.getByRole('button', { name: 'Uitloggen' })); diff --git a/apps/worker/src/lib/api.test.ts b/apps/worker/src/lib/api.test.ts index 396862f..8e8bb39 100644 --- a/apps/worker/src/lib/api.test.ts +++ b/apps/worker/src/lib/api.test.ts @@ -28,10 +28,7 @@ describe('api client', () => { }); it('throws ApiError on a non-2xx response', async () => { - vi.stubGlobal( - 'fetch', - vi.fn().mockResolvedValue(new Response(null, { status: 401 })), - ); + vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(null, { status: 401 }))); await expect(apiFetch('/api/me')).rejects.toMatchObject({ status: 401 }); await expect(apiFetch('/api/me')).rejects.toBeInstanceOf(ApiError); diff --git a/apps/worker/src/lib/api.ts b/apps/worker/src/lib/api.ts index 27b6469..9b053eb 100644 --- a/apps/worker/src/lib/api.ts +++ b/apps/worker/src/lib/api.ts @@ -5,7 +5,7 @@ export const API_URL = import.meta.env.VITE_API_URL ?? 'http://localhost:3000'; export class ApiError extends Error { constructor( public status: number, - message: string + message: string, ) { super(message); this.name = 'ApiError'; diff --git a/apps/worker/src/screens/Account.test.tsx b/apps/worker/src/screens/Account.test.tsx index ce57f3b..75e6bef 100644 --- a/apps/worker/src/screens/Account.test.tsx +++ b/apps/worker/src/screens/Account.test.tsx @@ -21,7 +21,7 @@ function renderAccount() { - + , ); } diff --git a/apps/worker/src/screens/History.test.tsx b/apps/worker/src/screens/History.test.tsx index a3c370c..9a2567c 100644 --- a/apps/worker/src/screens/History.test.tsx +++ b/apps/worker/src/screens/History.test.tsx @@ -46,7 +46,7 @@ function renderHistory() { return render( - + , ); } diff --git a/apps/worker/src/screens/Stopwatch.test.tsx b/apps/worker/src/screens/Stopwatch.test.tsx index 108aacf..a3a938e 100644 --- a/apps/worker/src/screens/Stopwatch.test.tsx +++ b/apps/worker/src/screens/Stopwatch.test.tsx @@ -91,7 +91,7 @@ function renderStopwatch() { return render( - + , ); } @@ -105,17 +105,17 @@ describe('Stopwatch', () => { mockedUseActivities.mockReturnValue(query>([FREZEN, PRINTEN])); mockedUseActiveSessions.mockReturnValue(query>([])); mockedUseStartSession.mockReturnValue( - mutation>(startMutate) + mutation>(startMutate), ); mockedUseStopSession.mockReturnValue(mutation>(stopMutate)); mockedUseDiscardSession.mockReturnValue( - mutation>(discardMutate) + mutation>(discardMutate), ); mockedUsePauseSession.mockReturnValue( - mutation>(pauseMutate) + mutation>(pauseMutate), ); mockedUseResumeSession.mockReturnValue( - mutation>(resumeMutate) + mutation>(resumeMutate), ); }); @@ -189,7 +189,7 @@ describe('Stopwatch', () => { const user = userEvent.setup(); // Recover an active session so the screen renders the running UI. mockedUseActiveSessions.mockReturnValue( - query>([activeSession()]) + query>([activeSession()]), ); renderStopwatch(); @@ -197,7 +197,7 @@ describe('Stopwatch', () => { await user.click(cancel); expect( - screen.getByRole('button', { name: 'Nogmaals tikken ter bevestiging' }) + screen.getByRole('button', { name: 'Nogmaals tikken ter bevestiging' }), ).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Nogmaals tikken ter bevestiging' })); @@ -208,7 +208,7 @@ describe('Stopwatch', () => { it('pauses via the server when the display is tapped while running', async () => { const user = userEvent.setup(); mockedUseActiveSessions.mockReturnValue( - query>([activeSession()]) + query>([activeSession()]), ); renderStopwatch(); @@ -225,7 +225,7 @@ describe('Stopwatch', () => { mockedUseActiveSessions.mockReturnValue( query>([ activeSession({ paused_at: new Date().toISOString(), paused_seconds: 30 }), - ]) + ]), ); renderStopwatch(); @@ -241,7 +241,7 @@ describe('Stopwatch', () => { mockedUseActiveSessions.mockReturnValue( query>([ activeSession({ paused_at: new Date().toISOString(), paused_seconds: 30 }), - ]) + ]), ); renderStopwatch(); diff --git a/apps/worker/src/screens/Stopwatch.tsx b/apps/worker/src/screens/Stopwatch.tsx index 108c453..dd1c606 100644 --- a/apps/worker/src/screens/Stopwatch.tsx +++ b/apps/worker/src/screens/Stopwatch.tsx @@ -118,7 +118,7 @@ export default function Stopwatch() { setPauseStartedMs(null); setNowMs(Date.now()); }, - } + }, ); }