From f325b5e969c5a8d7d57dfca2daa8e066c90a466b Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Tue, 27 Oct 2026 14:34:30 -0500 Subject: [PATCH] Account page: clear its three lint errors The equity curve's running total is summed before the map that reads it, the first load runs from a timer like the polls, and the two recharts callbacks keep their any with the repo's usual disable line. No change in what the page shows. Co-Authored-By: Claude Opus 5.5 --- app/accounts/[id]/page.tsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/accounts/[id]/page.tsx b/app/accounts/[id]/page.tsx index a77f4b7..b7f4cf1 100644 --- a/app/accounts/[id]/page.tsx +++ b/app/accounts/[id]/page.tsx @@ -282,6 +282,7 @@ function ObjRow({ passed, label, value }: { passed: boolean; label: ReactNode; v ); } +// eslint-disable-next-line @typescript-eslint/no-explicit-any function EquityTooltip({ active, payload, label }: any) { if (!active || !payload?.length) return null; // Always read from the raw data point so fill-only series don't interfere @@ -487,9 +488,11 @@ export default function AccountPage() { }, [accountId]); useEffect(() => { - void load(); + // The first load from a timer too, like the polls: not setState + // from the effect's own body. + const first = setTimeout(() => { void load(); }, 0); const interval = setInterval(() => { void load(); }, 5000); - return () => clearInterval(interval); + return () => { clearTimeout(first); clearInterval(interval); }; }, [load]); if (!account) { @@ -555,13 +558,19 @@ export default function AccountPage() { } const sortedEvents = [...allDates].sort().map((d) => eventsByDate.get(d)!); + // Running equity after each event, summed here rather than inside the + // map below: a render callback mustn't reassign an outer variable. + const runningAfter: number[] = []; let running = 0; + for (const ev of sortedEvents) { + if (ev.fundAmt !== undefined) running += ev.fundAmt; // withdrawals reduce equity + if (ev.pnl !== undefined) running += ev.pnl; + runningAfter.push(running); + } const equityData = [ { label: '', equity: 0, pnl: 0, origin: true, pos: 0, neg: 0, isWithdrawal: false }, - ...sortedEvents.map((ev) => { - if (ev.fundAmt !== undefined) running += ev.fundAmt; // withdrawals reduce equity - if (ev.pnl !== undefined) running += ev.pnl; - const equity = Math.round(running * 100) / 100; + ...sortedEvents.map((ev, i) => { + const equity = Math.round(runningAfter[i] * 100) / 100; return { label: fmtDate(ev.date), equity, @@ -902,6 +911,7 @@ export default function AccountPage() { stroke={`url(#${strokeGradId})`} strokeWidth={2.5} fill="none" + // eslint-disable-next-line @typescript-eslint/no-explicit-any dot={(props: any) => { if (props.payload?.origin) return ; return (