From 862bba4c652e11e3ca8cfebcb40da8dd4fb4b756 Mon Sep 17 00:00:00 2001 From: yacobmole Date: Thu, 11 Dec 2025 10:35:21 +1100 Subject: [PATCH] chore: lint & format --- packages/better-auth/src/auth/custom.test.ts | 42 ++++++++++---------- packages/better-auth/src/auth/custom.ts | 30 +++++++------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/better-auth/src/auth/custom.test.ts b/packages/better-auth/src/auth/custom.test.ts index dec6f2adab..901a7a808d 100644 --- a/packages/better-auth/src/auth/custom.test.ts +++ b/packages/better-auth/src/auth/custom.test.ts @@ -3,25 +3,25 @@ import type { Auth } from "../types"; import { betterAuth } from "./custom"; describe("auth-custom", () => { - test("default auth type should be okay (no interceptor)", () => { - const auth = betterAuth({}); - type T = typeof auth; - expectTypeOf().toEqualTypeOf(); - }); - test("default auth type should be okay (with interceptor)", () => { - const auth = betterAuth({}, (ctx) => ctx); - type T = typeof auth; - expectTypeOf().toEqualTypeOf(); - }); - test("an invalid interceptor type should throw", () => { - expect(() => betterAuth({}, "not an interceptor" as any)).toThrow(); - }); - test("context should be modified all the way down", async () => { - const auth = betterAuth({}, (ctx) => { - ctx.appName = "My Different App Name"; - return ctx; - }); - const newContext = await auth.$context; - expect(newContext.appName).toBe("My Different App Name"); - }); + test("default auth type should be okay (no interceptor)", () => { + const auth = betterAuth({}); + type T = typeof auth; + expectTypeOf().toEqualTypeOf(); + }); + test("default auth type should be okay (with interceptor)", () => { + const auth = betterAuth({}, (ctx) => ctx); + type T = typeof auth; + expectTypeOf().toEqualTypeOf(); + }); + test("an invalid interceptor type should throw", () => { + expect(() => betterAuth({}, "not an interceptor" as any)).toThrow(); + }); + test("context should be modified all the way down", async () => { + const auth = betterAuth({}, (ctx) => { + ctx.appName = "My Different App Name"; + return ctx; + }); + const newContext = await auth.$context; + expect(newContext.appName).toBe("My Different App Name"); + }); }); diff --git a/packages/better-auth/src/auth/custom.ts b/packages/better-auth/src/auth/custom.ts index e91032e772..b73136907e 100644 --- a/packages/better-auth/src/auth/custom.ts +++ b/packages/better-auth/src/auth/custom.ts @@ -14,22 +14,22 @@ import { createBetterAuth } from "./base"; */ export const betterAuth = ( - options: Options & - // fixme(alex): do we need Record here? - Record, - contextInterceptor?: (ctx: AuthContext) => AuthContext, + options: Options & + // fixme(alex): do we need Record here? + Record, + contextInterceptor?: (ctx: AuthContext) => AuthContext, ): Auth => { - const isValidInterceptor = typeof contextInterceptor === "function"; - const interceptor = isValidInterceptor - ? contextInterceptor - : (ctx: AuthContext) => ctx; + const isValidInterceptor = typeof contextInterceptor === "function"; + const interceptor = isValidInterceptor + ? contextInterceptor + : (ctx: AuthContext) => ctx; - if (!isValidInterceptor && contextInterceptor !== undefined) { - throw new BetterAuthError( - "Provided contextInterceptor is not a valid function", - ); - } + if (!isValidInterceptor && contextInterceptor !== undefined) { + throw new BetterAuthError( + "Provided contextInterceptor is not a valid function", + ); + } - const initFn = (options: Options) => init(options).then(interceptor); - return createBetterAuth(options, initFn); + const initFn = (options: Options) => init(options).then(interceptor); + return createBetterAuth(options, initFn); };