Enable the @typescript-eslint/no-non-null-assertion eslint rule (#1899)

## Description:

Enable the `@typescript-eslint/no-non-null-assertion` eslint rule.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
This commit is contained in:
Scott Anderson
2025-08-23 13:50:41 -04:00
committed by GitHub
parent add81b9c04
commit f5316cc378
35 changed files with 188 additions and 127 deletions
+4 -4
View File
@@ -662,8 +662,8 @@ export class GameServer {
// Count occurrences of each hash
for (const client of this.activeClients) {
if (client.hashes.has(turnNumber)) {
const clientHash = client.hashes.get(turnNumber)!;
const clientHash = client.hashes.get(turnNumber);
if (clientHash !== undefined) {
counts.set(clientHash, (counts.get(clientHash) ?? 0) + 1);
}
}
@@ -683,8 +683,8 @@ export class GameServer {
let outOfSyncClients: Client[] = [];
for (const client of this.activeClients) {
if (client.hashes.has(turnNumber)) {
const clientHash = client.hashes.get(turnNumber)!;
const clientHash = client.hashes.get(turnNumber);
if (clientHash !== undefined) {
if (clientHash !== mostCommonHash) {
outOfSyncClients.push(client);
}
+10 -4
View File
@@ -103,14 +103,20 @@ export class MapPlaylist {
const numAttempts = 10000;
for (let i = 0; i < numAttempts; i++) {
if (this.shuffleMapsPlaylist()) {
log.info(`Generated map playlist in ${i} attempts`);
return this.mapsPlaylist.shift()!;
log.info(`Generated map playlist in ${i + 1} attempts`);
const next = this.mapsPlaylist.shift();
if (next !== undefined) return next;
log.error("Playlist unexpectedly empty after successful shuffle; using fallback.");
return { map: GameMapType.World, mode: GameMode.FFA };
}
}
log.error("Failed to generate a valid map playlist");
}
// Even if it failed, playlist will be partially populated.
return this.mapsPlaylist.shift()!;
// Even if it failed, playlist may be partially populated.
const fallback = this.mapsPlaylist.shift();
if (fallback !== undefined) return fallback;
log.error("Playlist empty after shuffle failure; using fallback.");
return { map: GameMapType.World, mode: GameMode.FFA };
}
private shuffleMapsPlaylist(): boolean {
@@ -131,10 +131,11 @@ function handleWinner(
// Add client vote
const winnerKey = JSON.stringify(clientMsg.winner);
if (!gs.winnerVotes.has(winnerKey)) {
gs.winnerVotes.set(winnerKey, { ips: new Set(), winner: clientMsg });
let potentialWinner = gs.winnerVotes.get(winnerKey);
if (potentialWinner === undefined) {
potentialWinner = { ips: new Set(), winner: clientMsg };
gs.winnerVotes.set(winnerKey, potentialWinner);
}
const potentialWinner = gs.winnerVotes.get(winnerKey)!;
potentialWinner.ips.add(client.ip);
const activeUniqueIPs = new Set(gs.activeClients.map((c) => c.ip));