refactor: extract signals filter builder, add ESLint 10 config, fix low-hanging issues

This commit is contained in:
Sebastian Seedorf
2026-06-04 14:09:12 +02:00
parent cf9bb33ecb
commit 4b05f2968e
34 changed files with 2145 additions and 188 deletions

View File

@@ -1,5 +1,4 @@
import type { SignalRow, ChartConfig } from '@/lib/types';
import type { TimeMode } from '@/lib/types';
import type { SignalRow, ChartConfig, TimeMode } from '@/lib/types';
const MAX_SERIES = 80;
@@ -29,20 +28,25 @@ export function buildSeriesData(
? parseInt(row.game_tick, 10)
: new Date(row.real_time).getTime() / 1000;
if (!seriesMap.has(key)) seriesMap.set(key, new Map());
seriesMap.get(key)!.set(x, val);
seriesMap.get(key)?.set(x, val);
}
}
if (seriesMap.size === 0) return null;
const keys = [...seriesMap.keys()].slice(0, MAX_SERIES);
const allXs = [...new Set(keys.flatMap((k) => [...seriesMap.get(k)!.keys()]))].sort(
(a, b) => a - b,
);
const allXs = [
...new Set(
keys.flatMap((k) => {
const m = seriesMap.get(k);
return m ? [...m.keys()] : [];
}),
),
].sort((a, b) => a - b);
const data = keys.map((k) => {
const m = seriesMap.get(k)!;
return allXs.map((x) => m.get(x)); // undefined = gap
const m = seriesMap.get(k);
return m ? allXs.map((x) => m.get(x)) : []; // undefined = gap
});
return { keys, allXs, data };