Fix oxlint errors in NHL simulator and tests

- Replace non-null assertions (data!) with optional chaining (data?.x ?? "")
- Move makeEntry helper to module scope to avoid recreating on every call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-04-09 01:27:22 +00:00
parent 721b069b1c
commit a67fe32c52
2 changed files with 18 additions and 17 deletions

View file

@ -78,8 +78,8 @@ describe("getTeamData", () => {
]; ];
for (const name of allTeams) { for (const name of allTeams) {
const data = getTeamData(name); const data = getTeamData(name);
expect(validConferences.has(data!.conference), `${name}: invalid conference`).toBe(true); expect(validConferences.has(data?.conference ?? ""), `${name}: invalid conference`).toBe(true);
expect(validDivisions.has(data!.division), `${name}: invalid division`).toBe(true); expect(validDivisions.has(data?.division ?? ""), `${name}: invalid division`).toBe(true);
} }
}); });
@ -122,7 +122,6 @@ describe("eloWinProbability (PARITY_FACTOR = 1000)", () => {
// ─── simulateProjectedPoints ────────────────────────────────────────────────── // ─── simulateProjectedPoints ──────────────────────────────────────────────────
describe("simulateProjectedPoints", () => {
const makeEntry = (overrides: Partial<{ const makeEntry = (overrides: Partial<{
currentPoints: number; currentPoints: number;
remainingGames: number; remainingGames: number;
@ -138,6 +137,8 @@ describe("simulateProjectedPoints", () => {
winProb: overrides.winProb ?? 0.55, winProb: overrides.winProb ?? 0.55,
}); });
describe("simulateProjectedPoints", () => {
it("returns exactly currentPoints when no games remain", () => { it("returns exactly currentPoints when no games remain", () => {
const entry = makeEntry({ currentPoints: 95, remainingGames: 0 }); const entry = makeEntry({ currentPoints: 95, remainingGames: 0 });
expect(simulateProjectedPoints(entry)).toBe(95); expect(simulateProjectedPoints(entry)).toBe(95);

View file

@ -245,7 +245,7 @@ function projectTeam(t: TeamEntry): ProjectedTeam {
/** Sort projected teams descending by pts, then by random tiebreaker. Mutates arr. */ /** Sort projected teams descending by pts, then by random tiebreaker. Mutates arr. */
function sortProjected(arr: ProjectedTeam[]): ProjectedTeam[] { function sortProjected(arr: ProjectedTeam[]): ProjectedTeam[] {
return arr.sort((a, b) => b.pts - a.pts || b.tb - a.tb); return arr.toSorted((a, b) => b.pts - a.pts || b.tb - a.tb);
} }
// ─── Simulator ──────────────────────────────────────────────────────────────── // ─── Simulator ────────────────────────────────────────────────────────────────