refactor(frontend): satisfy noUncheckedIndexedAccess (S3b)

Enable noUncheckedIndexedAccess and fix all 98 call sites it surfaced across 18
files. Every fix is behaviour-preserving — the flag flagged reads TypeScript
couldn't prove in-bounds, all of which were already guarded by a length/index check,
a findIndex result, or a non-empty invariant:

- read-once so a ternary's narrowing sticks (Feed overrides, linkify mention);
- non-null assertion AFTER an existing guard (PlayerModal/VideoEditor queue+cut-list
  indexing, modules step, useUndoable stacks) with a comment stating the invariant;
- nullish fallback where undefined is a real possibility (GlassTuner slider ?? def,
  ConfigPanel active group ?? [], descriptionLinks id ?? null);
- optional chaining where the entry genuinely can be absent (PlexBrowse IO entry);
- a non-empty tuple type for the RELATIVE_UNITS constant (encodes "always has [0]").

The single highest-leverage fix: PlayerModal's `active` became `queue?.[index] ??
video` (always Video), clearing 34 of the 45 errors in that file at once. Verified:
tsc/eslint/prettier clean, 56 vitest + 34 pytest + 17/17 e2e green (the e2e suite
exercises the feed/player/channel components touched here).
This commit is contained in:
2026-07-21 04:11:19 +02:00
parent 3fe0897fd3
commit e006cc879f
16 changed files with 73 additions and 44 deletions
+2 -2
View File
@@ -406,7 +406,7 @@ export default function PlexPlaylistView({
const set = new Set(keys);
setItems((prev) => prev.filter((i) => !set.has(i.id)));
try {
if (keys.length === 1) await api.plexPlaylistRemoveItem(playlistId, keys[0]);
if (keys.length === 1) await api.plexPlaylistRemoveItem(playlistId, keys[0]!);
else await api.plexPlaylistRemoveBulk(playlistId, keys);
invalidate();
} finally {
@@ -560,7 +560,7 @@ export default function PlexPlaylistView({
</button>
{items.length > 0 && (
<button
onClick={() => onPlay(order[0], order)}
onClick={() => onPlay(order[0]!, order)}
className="inline-flex items-center gap-2 rounded-xl bg-accent px-4 py-2 font-medium text-white hover:opacity-90"
>
<Play className="h-5 w-5 fill-current" />