From 9d3a673e6c54a74535e848d16d49b94b08ddf9f6 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Mon, 16 Feb 2026 17:00:01 -0600 Subject: [PATCH] =?UTF-8?q?fix(#411):=20resolve=20CI=20lint=20errors=20?= =?UTF-8?q?=E2=80=94=20prettier,=20unused=20directives,=20no-base-to-strin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth.config.ts: collapse multiline template literal to single line - auth.controller.ts: add eslint-disable for intentional no-unnecessary-condition - auth.service.ts: remove 5 unused eslint-disable directives (Node 24 resolves BetterAuth types), fix prettier formatting, fix no-base-to-string - login/page.tsx: remove unnecessary String() wrapper - auth-context.test.tsx: fix prettier line length Co-Authored-By: Claude Opus 4.6 --- apps/api/src/auth/auth.config.ts | 4 +--- apps/api/src/auth/auth.controller.ts | 1 + apps/api/src/auth/auth.service.ts | 16 +++------------- apps/web/src/app/(auth)/login/page.tsx | 2 +- apps/web/src/lib/auth/auth-context.test.tsx | 4 +++- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/apps/api/src/auth/auth.config.ts b/apps/api/src/auth/auth.config.ts index c0088bc..afaf19e 100644 --- a/apps/api/src/auth/auth.config.ts +++ b/apps/api/src/auth/auth.config.ts @@ -184,9 +184,7 @@ export function getTrustedOrigins(): string[] { origins.push(origin); } catch (urlError: unknown) { const detail = urlError instanceof Error ? urlError.message : String(urlError); - console.warn( - `[AUTH] Ignoring invalid URL in TRUSTED_ORIGINS: "${origin}" (${detail})` - ); + console.warn(`[AUTH] Ignoring invalid URL in TRUSTED_ORIGINS: "${origin}" (${detail})`); } } } diff --git a/apps/api/src/auth/auth.controller.ts b/apps/api/src/auth/auth.controller.ts index 9e171aa..0152b81 100644 --- a/apps/api/src/auth/auth.controller.ts +++ b/apps/api/src/auth/auth.controller.ts @@ -37,6 +37,7 @@ export class AuthController { // Defense-in-depth: AuthGuard should guarantee these, but if someone adds // a route with AuthenticatedRequest and forgets @UseGuards(AuthGuard), // TypeScript types won't help at runtime. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!req.user || !req.session) { throw new UnauthorizedException("Missing authentication context"); } diff --git a/apps/api/src/auth/auth.service.ts b/apps/api/src/auth/auth.service.ts index e0a5083..97e8d4b 100644 --- a/apps/api/src/auth/auth.service.ts +++ b/apps/api/src/auth/auth.service.ts @@ -38,9 +38,7 @@ export class AuthService { // PrismaService extends PrismaClient and is compatible with BetterAuth's adapter // Cast is safe as PrismaService provides all required PrismaClient methods // TODO(#411): BetterAuth returns opaque types — replace when upstream exports typed interfaces - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment this.auth = createAuth(this.prisma as unknown as PrismaClient); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call this.nodeHandler = toNodeHandler(this.auth); } @@ -107,7 +105,6 @@ export class AuthService { async verifySession(token: string): Promise { try { // TODO(#411): BetterAuth getSession returns opaque types — replace when upstream exports typed interfaces - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access const session = await this.auth.api.getSession({ headers: { authorization: `Bearer ${token}`, @@ -119,9 +116,7 @@ export class AuthService { } return { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access user: session.user as Record, - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access session: session.session as Record, }; } catch (error: unknown) { @@ -143,19 +138,14 @@ export class AuthService { /Bearer\s+\S+/gi, "Bearer [REDACTED]" ); - this.logger.error( - "Session verification failed due to unexpected error", - safeMessage - ); + this.logger.error("Session verification failed due to unexpected error", safeMessage); throw error; } } // Non-Error thrown values — log for observability, treat as auth failure if (!(error instanceof Error)) { - this.logger.warn( - "Session verification received non-Error thrown value", - typeof error === "object" ? JSON.stringify(error) : String(error), - ); + const errorDetail = typeof error === "string" ? error : JSON.stringify(error); + this.logger.warn("Session verification received non-Error thrown value", errorDetail); } return null; } diff --git a/apps/web/src/app/(auth)/login/page.tsx b/apps/web/src/app/(auth)/login/page.tsx index 22f1b5f..5c56d81 100644 --- a/apps/web/src/app/(auth)/login/page.tsx +++ b/apps/web/src/app/(auth)/login/page.tsx @@ -103,7 +103,7 @@ export default function LoginPage(): ReactElement { if (result.error) { const parsed = parseAuthError( - result.error.message ? new Error(String(result.error.message)) : result.error + result.error.message ? new Error(result.error.message) : result.error ); setError(parsed.message); } else { diff --git a/apps/web/src/lib/auth/auth-context.test.tsx b/apps/web/src/lib/auth/auth-context.test.tsx index 74727a0..f2a1861 100644 --- a/apps/web/src/lib/auth/auth-context.test.tsx +++ b/apps/web/src/lib/auth/auth-context.test.tsx @@ -330,7 +330,9 @@ describe("AuthContext", (): void => { // An Error that doesn't match any known pattern (parseAuthError returns "unknown") // should fall through to the instanceof Error catch-all and return "backend" - vi.mocked(apiGet).mockRejectedValueOnce(new Error("Something completely unexpected happened")); + vi.mocked(apiGet).mockRejectedValueOnce( + new Error("Something completely unexpected happened") + ); render(