diff --git a/eslint.config.js b/eslint.config.js index 2984c0ac7..0744e3672 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -49,6 +49,7 @@ export default [ rules: { // Enable rules "@typescript-eslint/prefer-nullish-coalescing": "error", + curly: ["error", "multi-line"], eqeqeq: "error", "sort-keys": "error", }, diff --git a/src/client/InputHandler.ts b/src/client/InputHandler.ts index 15d6bee9d..f8839d0f9 100644 --- a/src/client/InputHandler.ts +++ b/src/client/InputHandler.ts @@ -214,23 +214,27 @@ export class InputHandler { if ( this.activeKeys.has(this.keybinds.moveUp) || this.activeKeys.has("ArrowUp") - ) + ) { deltaY += this.PAN_SPEED; + } if ( this.activeKeys.has(this.keybinds.moveDown) || this.activeKeys.has("ArrowDown") - ) + ) { deltaY -= this.PAN_SPEED; + } if ( this.activeKeys.has(this.keybinds.moveLeft) || this.activeKeys.has("ArrowLeft") - ) + ) { deltaX += this.PAN_SPEED; + } if ( this.activeKeys.has(this.keybinds.moveRight) || this.activeKeys.has("ArrowRight") - ) + ) { deltaX -= this.PAN_SPEED; + } if (deltaX || deltaY) { this.eventBus.emit(new DragEvent(deltaX, deltaY)); diff --git a/src/client/Main.ts b/src/client/Main.ts index 97cca212c..8bba30fe4 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -212,8 +212,9 @@ class Client { "territory-patterns-input-preview-button", ); territoryModal instanceof TerritoryPatternsModal; - if (patternButton === null) + if (patternButton === null) { throw new Error("territory-patterns-input-preview-button"); + } territoryModal.previewButton = patternButton; territoryModal.updatePreview(); territoryModal.resizeObserver = new ResizeObserver((entries) => { @@ -371,8 +372,9 @@ class Client { const joinPrivateLobbyButton = document.getElementById( "join-private-lobby-button", ); - if (joinPrivateLobbyButton === null) + if (joinPrivateLobbyButton === null) { throw new Error("Missing join-private-lobby-button"); + } joinPrivateLobbyButton.addEventListener("click", () => { if (this.usernameInput?.isValid()) { this.joinModal.open(); diff --git a/src/client/PublicLobby.ts b/src/client/PublicLobby.ts index e94ed794b..38acdfd2f 100644 --- a/src/client/PublicLobby.ts +++ b/src/client/PublicLobby.ts @@ -75,8 +75,9 @@ export class PublicLobby extends LitElement { async fetchLobbies(): Promise { try { const response = await fetch(`/api/public_lobbies`); - if (!response.ok) + if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); + } const data = await response.json(); return data.lobbies; } catch (error) { diff --git a/src/client/graphics/layers/RadialMenu.ts b/src/client/graphics/layers/RadialMenu.ts index 9e81cc7cc..d1b84286d 100644 --- a/src/client/graphics/layers/RadialMenu.ts +++ b/src/client/graphics/layers/RadialMenu.ts @@ -417,8 +417,9 @@ export class RadialMenu implements Layer { (this.currentLevel > 0 && level === 0 && d.data.id === this.selectedItemId) - ) + ) { return; + } path.attr("filter", null); path.attr("stroke-width", "2"); const color = disabled @@ -437,15 +438,17 @@ export class RadialMenu implements Layer { this.params === null || d.data.disabled(this.params) || this.navigationInProgress - ) + ) { return; + } if ( this.currentLevel > 0 && level === 0 && d.data.id !== this.selectedItemId - ) + ) { return; + } const subMenu = d.data.subMenu?.(this.params); if (subMenu && subMenu.length > 0) { diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 4fb2765fe..ea7f15731 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -112,13 +112,15 @@ class SAMTargetingSystem { if ( a.unit.type() === UnitType.HydrogenBomb && b.unit.type() !== UnitType.HydrogenBomb - ) + ) { return -1; + } if ( a.unit.type() !== UnitType.HydrogenBomb && b.unit.type() === UnitType.HydrogenBomb - ) + ) { return 1; + } return 0; })[0] ?? null diff --git a/src/core/execution/WarshipExecution.ts b/src/core/execution/WarshipExecution.ts index 9e0a71309..3791b796f 100644 --- a/src/core/execution/WarshipExecution.ts +++ b/src/core/execution/WarshipExecution.ts @@ -124,25 +124,29 @@ export class WarshipExecution implements Execution { if ( unitA.type() === UnitType.TransportShip && unitB.type() !== UnitType.TransportShip - ) + ) { return -1; + } if ( unitA.type() !== UnitType.TransportShip && unitB.type() === UnitType.TransportShip - ) + ) { return 1; + } // Then prioritize Warships. if ( unitA.type() === UnitType.Warship && unitB.type() !== UnitType.Warship - ) + ) { return -1; + } if ( unitA.type() !== UnitType.Warship && unitB.type() === UnitType.Warship - ) + ) { return 1; + } // If both are the same type, sort by distance (lower `distSquared` means closer) return distA - distB; diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index 02ec95eb5..831ed5933 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -286,10 +286,12 @@ export class GameImpl implements Game { ); // Automatically remove embargoes only if they were automatically created - if (requestor.hasEmbargoAgainst(recipient)) + if (requestor.hasEmbargoAgainst(recipient)) { requestor.endTemporaryEmbargo(recipient.id()); - if (recipient.hasEmbargoAgainst(requestor)) + } + if (recipient.hasEmbargoAgainst(requestor)) { recipient.endTemporaryEmbargo(requestor.id()); + } this.addUpdate({ accepted: true, diff --git a/src/core/pathfinding/SerialAStar.ts b/src/core/pathfinding/SerialAStar.ts index fdb138c82..41d9972be 100644 --- a/src/core/pathfinding/SerialAStar.ts +++ b/src/core/pathfinding/SerialAStar.ts @@ -119,8 +119,9 @@ export class SerialAStar implements AStar { if ( neighbor !== (isForward ? this.dst : this.closestSource) && !this.graph.isTraversable(current, neighbor) - ) + ) { continue; + } const gScore = isForward ? this.fwdGScore : this.bwdGScore; const openSet = isForward ? this.fwdOpenSet : this.bwdOpenSet;