Eliminates all 208 no-non-null-assertion warnings across 38 files. Promotes typescript/no-non-null-assertion from warn to error in .oxlintrc.json. Fix patterns applied: - Map.get(key)! after .has() check → extract with get() + null guard - Map.get(key)! on pre-populated count maps → ?? 0 default - .set(id, map.get(id)! + 1) increment → ?? 0 before adding - participant1Id!/participant2Id! on DB matches → ?? "" fallback - array.find()! in tests → guard + throw or expect().toBeDefined() - bracketTemplateCache.get(id)! → null guard extract - Various nullable field accesses → optional chain or ?? default Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
701 B
TypeScript
20 lines
701 B
TypeScript
export type DraftPick = {
|
|
id: string;
|
|
team: { id: string; name: string };
|
|
participant: { id: string; name: string };
|
|
sport: { id: string; name: string };
|
|
};
|
|
|
|
export function groupPicksByTeamAndSport(
|
|
picks: DraftPick[]
|
|
): Map<string, Map<string, DraftPick[]>> {
|
|
const map = new Map<string, Map<string, DraftPick[]>>();
|
|
picks.forEach((pick) => {
|
|
if (!map.has(pick.team.id)) map.set(pick.team.id, new Map());
|
|
const teamMap = map.get(pick.team.id) ?? new Map<string, DraftPick[]>();
|
|
if (!map.has(pick.team.id)) map.set(pick.team.id, teamMap);
|
|
if (!teamMap.has(pick.sport.id)) teamMap.set(pick.sport.id, []);
|
|
teamMap.get(pick.sport.id)?.push(pick);
|
|
});
|
|
return map;
|
|
}
|