From 64e8024c62e4e792d0d795b3767f509a0979f982 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 31 Mar 2026 22:14:03 +0000 Subject: [PATCH] Fix lint failures: unused vars, eqeqeq, toSorted - Remove unused seededSet/unseededSet variables in test - Replace != null with !== null && !== undefined (eqeqeq rule) - Replace .sort() with .toSorted() in simulator and route (unicorn/no-array-sort) https://claude.ai/code/session_01WZ6FjMmC2eBeZ1564M9Ruz --- app/routes/admin.sports-seasons.$id.darts-elo.tsx | 6 +++--- .../simulations/__tests__/darts-simulator.test.ts | 10 ++-------- app/services/simulations/darts-simulator.ts | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/routes/admin.sports-seasons.$id.darts-elo.tsx b/app/routes/admin.sports-seasons.$id.darts-elo.tsx index 890cfd3..52cd5f4 100644 --- a/app/routes/admin.sports-seasons.$id.darts-elo.tsx +++ b/app/routes/admin.sports-seasons.$id.darts-elo.tsx @@ -195,7 +195,7 @@ export default function AdminSportsSeasonDartsElo() { const initial: Record = {}; participants.forEach(p => { const d = existingData[p.id]; - if (d?.elo != null) initial[p.id] = d.elo.toString(); + if (d?.elo !== null && d?.elo !== undefined) initial[p.id] = d.elo.toString(); }); return initial; }); @@ -204,7 +204,7 @@ export default function AdminSportsSeasonDartsElo() { const initial: Record = {}; participants.forEach(p => { const d = existingData[p.id]; - if (d?.ranking != null) initial[p.id] = d.ranking.toString(); + if (d?.ranking !== null && d?.ranking !== undefined) initial[p.id] = d.ranking.toString(); }); return initial; }); @@ -292,7 +292,7 @@ export default function AdminSportsSeasonDartsElo() { const isSubmitting = navigation.state === 'submitting'; // Sort participants for display: by current rank (ascending), then unranked alphabetically - const sortedParticipants = [...participants].sort((a, b) => { + const sortedParticipants = [...participants].toSorted((a, b) => { const rankA = rankValues[a.id] ? parseInt(rankValues[a.id], 10) : null; const rankB = rankValues[b.id] ? parseInt(rankValues[b.id], 10) : null; if (rankA !== null && rankB !== null) return rankA - rankB; diff --git a/app/services/simulations/__tests__/darts-simulator.test.ts b/app/services/simulations/__tests__/darts-simulator.test.ts index 7614441..f85feb4 100644 --- a/app/services/simulations/__tests__/darts-simulator.test.ts +++ b/app/services/simulations/__tests__/darts-simulator.test.ts @@ -111,7 +111,7 @@ describe("getSeededMatchOrder", () => { it("for n=32, contains all seeds 1–32 exactly once", () => { const order = getSeededMatchOrder(32); expect(order).toHaveLength(32); - const sorted = [...order].sort((a, b) => a - b); + const sorted = [...order].toSorted((a, b) => a - b); expect(sorted).toEqual(Array.from({ length: 32 }, (_, i) => i + 1)); }); @@ -140,11 +140,7 @@ describe("buildR1Bracket", () => { const allPlayers = pairs.flat(); expect(allPlayers).toHaveLength(128); - const seededSet = new Set(seeded); - const unseededSet = new Set(unseeded); for (const [a, b] of pairs) { - // Each pair has one seeded and one unseeded (first 32 pairs), - // or two unseeded (last 32 pairs). expect(a).toBeTruthy(); expect(b).toBeTruthy(); } @@ -162,8 +158,6 @@ describe("buildR1Bracket", () => { it("each of the 32 seeded players faces an unseeded opponent in their R1 match", () => { const pairs = buildR1Bracket(seeded, unseeded); - const unseededSet = new Set(unseeded); - const seededSet = new Set(seeded); // First 32 pairs: seeded vs unseeded for (let i = 0; i < 32; i++) { @@ -429,7 +423,7 @@ describe("DartsSimulator.simulate() — Path B (pre-bracket)", () => { const sim = new DartsSimulator(); const results = await sim.simulate("season-1"); - const sorted = [...results].sort((a, b) => b.probabilities.probFirst - a.probabilities.probFirst); + const sorted = [...results].toSorted((a, b) => b.probabilities.probFirst - a.probabilities.probFirst); // player-1 is world #1 with the highest Elo — should have highest win probability expect(sorted[0].participantId).toBe("player-1"); }); diff --git a/app/services/simulations/darts-simulator.ts b/app/services/simulations/darts-simulator.ts index 96af36b..922e6ba 100644 --- a/app/services/simulations/darts-simulator.ts +++ b/app/services/simulations/darts-simulator.ts @@ -461,7 +461,7 @@ export class DartsSimulator implements Simulator { // Sort participants by world ranking (ascending). Fall back to Elo order (descending) for // any without a ranking, then alphabetical as a final tiebreak. - const sorted = [...allParticipants].sort((a, b) => { + const sorted = [...allParticipants].toSorted((a, b) => { const rankA = rankingMap.get(a.id); const rankB = rankingMap.get(b.id); if (rankA !== undefined && rankB !== undefined) return rankA - rankB;