From eb58fd278b21cba7f176c8d6e16e6823523b879d Mon Sep 17 00:00:00 2001 From: Albert Salgueda Date: Tue, 17 Mar 2026 18:01:47 +0100 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20resolve=20lint=20errors=20=E2=80=94?= =?UTF-8?q?=20remove=20unused=20imports,=20fix=20any=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- src/app/(dashboard)/[orgSlug]/billing/page.tsx | 1 - src/components/billing/current-spend.tsx | 2 -- src/lib/credits/balance.test.ts | 4 ++-- src/lib/credits/balance.ts | 2 +- src/lib/stripe/webhooks.test.ts | 6 ++++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/app/(dashboard)/[orgSlug]/billing/page.tsx b/src/app/(dashboard)/[orgSlug]/billing/page.tsx index 7974127..3f1c719 100644 --- a/src/app/(dashboard)/[orgSlug]/billing/page.tsx +++ b/src/app/(dashboard)/[orgSlug]/billing/page.tsx @@ -29,7 +29,6 @@ export default function BillingPage() {
({ import { getBalance, checkSufficientBalance, deductCredits, addCredits } from './balance' function mockSelectChain(balance: string) { - const chain: Record = {} + const chain: Record = {} chain.from = vi.fn(() => chain) chain.where = vi.fn(() => chain) chain.limit = vi.fn(() => Promise.resolve([{ balance }])) @@ -35,7 +35,7 @@ describe('getBalance', () => { }) it('returns 0 when no org found', async () => { - const chain: Record = {} + const chain: Record = {} chain.from = vi.fn(() => chain) chain.where = vi.fn(() => chain) chain.limit = vi.fn(() => Promise.resolve([])) diff --git a/src/lib/credits/balance.ts b/src/lib/credits/balance.ts index 2e4a9d0..b947b37 100644 --- a/src/lib/credits/balance.ts +++ b/src/lib/credits/balance.ts @@ -1,5 +1,5 @@ import { db } from '@/lib/db' -import { organizations, creditTransactions } from '@/lib/db/schema' +import { organizations } from '@/lib/db/schema' import { eq, sql } from 'drizzle-orm' interface DeductMeta { diff --git a/src/lib/stripe/webhooks.test.ts b/src/lib/stripe/webhooks.test.ts index 8a477f6..4ca9ae9 100644 --- a/src/lib/stripe/webhooks.test.ts +++ b/src/lib/stripe/webhooks.test.ts @@ -47,7 +47,9 @@ vi.mock('@/lib/constants', () => ({ import { handleStripeEvent } from './webhooks' -function chainMock(returnValue: unknown) { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function chainMock(returnValue: unknown): Record { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const chain: Record = {} const terminal = () => Promise.resolve(returnValue) const methods = ['from', 'select', 'update', 'insert', 'eq', 'in', 'single', 'order', 'limit'] @@ -181,7 +183,7 @@ describe('handleStripeEvent', () => { describe('payment_intent.succeeded', () => { it('adds credits for credit_topup payment intents', async () => { const txnChain = chainMock({ data: [], error: null }) - txnChain.single = undefined as any + txnChain.single = undefined as unknown txnChain.limit = vi.fn(() => Promise.resolve({ data: [], error: null })) const orgChain = chainMock({ data: null, error: null }) From f70ce039491d0f16724502c481d07828cae7c9fb Mon Sep 17 00:00:00 2001 From: Albert Salgueda Date: Tue, 17 Mar 2026 18:08:12 +0100 Subject: [PATCH 2/2] fix: resolve remaining lint errors for CI - Add eslint-disable comments for `as any` casts in ensure-customer.test.ts - Refactor sidebar-state.tsx to use lazy useState initializers instead of useEffect setState - Suppress unused parameter warning on handleSubscriptionCreated stub Co-Authored-By: Claude Opus 4.6 --- src/components/layout/sidebar-state.tsx | 15 +++++++-------- src/lib/stripe/ensure-customer.test.ts | 5 +++++ src/lib/stripe/webhooks.ts | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/layout/sidebar-state.tsx b/src/components/layout/sidebar-state.tsx index 1e54b6d..3e79ebe 100644 --- a/src/components/layout/sidebar-state.tsx +++ b/src/components/layout/sidebar-state.tsx @@ -13,14 +13,13 @@ interface SidebarStateContextValue { const SidebarStateContext = createContext(null) export function SidebarStateProvider({ children }: { children: React.ReactNode }) { - const [collapsed, setCollapsed] = useState(false) - const [hydrated, setHydrated] = useState(false) - - useEffect(() => { - const stored = window.localStorage.getItem(SIDEBAR_STORAGE_KEY) - if (stored === 'true') setCollapsed(true) - setHydrated(true) - }, []) + const [collapsed, setCollapsed] = useState(() => { + if (typeof window !== 'undefined') { + return window.localStorage.getItem(SIDEBAR_STORAGE_KEY) === 'true' + } + return false + }) + const [hydrated] = useState(() => typeof window !== 'undefined') useEffect(() => { if (hydrated) { diff --git a/src/lib/stripe/ensure-customer.test.ts b/src/lib/stripe/ensure-customer.test.ts index bc9515a..7538858 100644 --- a/src/lib/stripe/ensure-customer.test.ts +++ b/src/lib/stripe/ensure-customer.test.ts @@ -51,6 +51,7 @@ describe('ensureStripeCustomer', () => { it('returns existing stripe_customer_id if valid in current mode', async () => { const org = makeOrg({ stripe_customer_id: 'cus_existing' }) + // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(stripe.customers.retrieve).mockResolvedValue({ id: 'cus_existing' } as any) const result = await ensureStripeCustomer(org) @@ -62,10 +63,12 @@ describe('ensureStripeCustomer', () => { it('creates new customer if existing ID is from wrong Stripe mode', async () => { const org = makeOrg({ stripe_customer_id: 'cus_live_mode_id' }) vi.mocked(stripe.customers.retrieve).mockRejectedValue(new Error('No such customer')) + // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(stripe.customers.create).mockResolvedValue({ id: 'cus_test_new' } as any) const mockEq = vi.fn().mockResolvedValue({ data: null, error: null }) const mockUpdate = vi.fn(() => ({ eq: mockEq })) + // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(supabaseAdmin.from).mockReturnValue({ update: mockUpdate } as any) const result = await ensureStripeCustomer(org) @@ -76,10 +79,12 @@ describe('ensureStripeCustomer', () => { it('creates a Stripe customer when none exists', async () => { const org = makeOrg({ stripe_customer_id: null }) + // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(stripe.customers.create).mockResolvedValue({ id: 'cus_new123' } as any) const mockEq = vi.fn().mockResolvedValue({ data: null, error: null }) const mockUpdate = vi.fn(() => ({ eq: mockEq })) + // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(supabaseAdmin.from).mockReturnValue({ update: mockUpdate } as any) const result = await ensureStripeCustomer(org) diff --git a/src/lib/stripe/webhooks.ts b/src/lib/stripe/webhooks.ts index a3ce2b2..f723242 100644 --- a/src/lib/stripe/webhooks.ts +++ b/src/lib/stripe/webhooks.ts @@ -198,7 +198,7 @@ async function handlePaymentIntentFailed(pi: Stripe.PaymentIntent): Promise { +async function handleSubscriptionCreated(_sub: Stripe.Subscription): Promise { // eslint-disable-line @typescript-eslint/no-unused-vars // Instance creation is handled in handleCheckoutCompleted. }