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:
parent
721b069b1c
commit
a67fe32c52
2 changed files with 18 additions and 17 deletions
|
|
@ -78,8 +78,8 @@ describe("getTeamData", () => {
|
|||
];
|
||||
for (const name of allTeams) {
|
||||
const data = getTeamData(name);
|
||||
expect(validConferences.has(data!.conference), `${name}: invalid conference`).toBe(true);
|
||||
expect(validDivisions.has(data!.division), `${name}: invalid division`).toBe(true);
|
||||
expect(validConferences.has(data?.conference ?? ""), `${name}: invalid conference`).toBe(true);
|
||||
expect(validDivisions.has(data?.division ?? ""), `${name}: invalid division`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -122,7 +122,6 @@ describe("eloWinProbability (PARITY_FACTOR = 1000)", () => {
|
|||
|
||||
// ─── simulateProjectedPoints ──────────────────────────────────────────────────
|
||||
|
||||
describe("simulateProjectedPoints", () => {
|
||||
const makeEntry = (overrides: Partial<{
|
||||
currentPoints: number;
|
||||
remainingGames: number;
|
||||
|
|
@ -138,6 +137,8 @@ describe("simulateProjectedPoints", () => {
|
|||
winProb: overrides.winProb ?? 0.55,
|
||||
});
|
||||
|
||||
describe("simulateProjectedPoints", () => {
|
||||
|
||||
it("returns exactly currentPoints when no games remain", () => {
|
||||
const entry = makeEntry({ currentPoints: 95, remainingGames: 0 });
|
||||
expect(simulateProjectedPoints(entry)).toBe(95);
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ function projectTeam(t: TeamEntry): ProjectedTeam {
|
|||
|
||||
/** Sort projected teams descending by pts, then by random tiebreaker. Mutates arr. */
|
||||
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 ────────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue