Fix lint errors: replace .sort() with .toSorted() and remove non-null assertion

- Replace Array#sort() with Array#toSorted() in two places (unicorn rule)
- Remove non-null assertion on Map#get(); use early continue instead

https://claude.ai/code/session_01QkFxCF4xmKjdVCNPysWDML
This commit is contained in:
Claude 2026-04-01 20:20:45 +00:00
parent 5bfe783861
commit d75c0493cf
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View file

@ -298,7 +298,7 @@ describe("getEventsForDates", () => {
const result = await getEventsForDates(["2026-03-20", "2026-03-21"]);
expect(result).toHaveLength(2);
const displayDates = result.map((e) => e.displayDate).sort();
const displayDates = result.map((e) => e.displayDate).toSorted();
expect(displayDates).toEqual(["2026-03-20", "2026-03-21"]);
// Both entries share the same event id
expect(result[0].id).toBe("e1");

View file

@ -676,7 +676,8 @@ export async function getEventsForDates(
if (!eventDatesMap.has(row.id)) {
eventDatesMap.set(row.id, new Set());
}
const dateSet = eventDatesMap.get(row.id)!;
const dateSet = eventDatesMap.get(row.id);
if (!dateSet) continue;
if (row.eventDate && dates.includes(row.eventDate)) {
dateSet.add(row.eventDate);
}
@ -712,7 +713,7 @@ export async function getEventsForDates(
// Return one entry per (event, date) pair so that an event with games on
// both today and tomorrow appears in both tabs of the dashboard widget.
return events.flatMap((e) => {
const matchingDates = [...(eventDatesMap.get(e.id) ?? [])].sort();
const matchingDates = [...(eventDatesMap.get(e.id) ?? [])].toSorted();
const base = {
id: e.id,
name: e.name,