diff --git a/eslint.config.js b/eslint.config.js index 55ec53e65..f7c4f927e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -54,7 +54,7 @@ export default [ }, rules: { // Enable rules - // '@stylistic/quotes': ['error', 'single'], TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1788 + "@stylistic/quotes": ["error", "double", { avoidEscape: true }], "@stylistic/indent": ["error", 2], "@stylistic/semi": "error", "@stylistic/space-infix-ops": "error", @@ -116,7 +116,7 @@ export default [ "no-undef": "error", "no-unused-vars": "off", // @typescript-eslint/no-unused-vars "quote-props": ["error", "consistent-as-needed"], - 'sort-imports': 'error', + "sort-imports": "error", "space-before-blocks": ["error", "always"], "space-before-function-paren": ["error", { anonymous: "always", @@ -154,7 +154,7 @@ export default [ "tests/**/*.{js,ts,jsx,tsx}", ], plugins: ["jest"], - ...jest.configs['flat/style'], + ...jest.configs["flat/style"], }, { files: [ diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index 7379e267f..a7cda04bc 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -563,7 +563,7 @@ export class ClientGameRunner { (bu) => bu.type === UnitType.TransportShip, ); if (bu === undefined) { - console.warn(`no transport ship buildable units`); + console.warn("no transport ship buildable units"); return false; } return ( diff --git a/src/client/FlagInput.ts b/src/client/FlagInput.ts index 0412ea9ab..5628b8564 100644 --- a/src/client/FlagInput.ts +++ b/src/client/FlagInput.ts @@ -83,7 +83,7 @@ export class FlagInput extends LitElement { renderPlayerFlag(this.flag, preview); } else { const img = document.createElement("img"); - img.src = this.flag ? `/flags/${this.flag}.svg` : `/flags/xx.svg`; + img.src = this.flag ? `/flags/${this.flag}.svg` : "/flags/xx.svg"; img.style.width = "100%"; img.style.height = "100%"; img.style.objectFit = "contain"; diff --git a/src/client/PublicLobby.ts b/src/client/PublicLobby.ts index f24f63598..3012af80c 100644 --- a/src/client/PublicLobby.ts +++ b/src/client/PublicLobby.ts @@ -75,7 +75,7 @@ export class PublicLobby extends LitElement { async fetchLobbies(): Promise { try { - const response = await fetch(`/api/public_lobbies`); + const response = await fetch("/api/public_lobbies"); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); const json = await response.json(); diff --git a/src/client/SinglePlayerModal.ts b/src/client/SinglePlayerModal.ts index d1ae96a39..97cfd1c36 100644 --- a/src/client/SinglePlayerModal.ts +++ b/src/client/SinglePlayerModal.ts @@ -206,7 +206,7 @@ export class SinglePlayerModal extends LitElement {
${typeof o === "string" ? translateText(`public_lobby.teams_${o}`) - : translateText(`public_lobby.teams`, { num: o })} + : translateText("public_lobby.teams", { num: o })}
`, diff --git a/src/client/TerrainMapFileLoader.ts b/src/client/TerrainMapFileLoader.ts index 768824526..40be9b4db 100644 --- a/src/client/TerrainMapFileLoader.ts +++ b/src/client/TerrainMapFileLoader.ts @@ -1,4 +1,4 @@ import { FetchGameMapLoader } from "../core/game/FetchGameMapLoader"; import version from "../../resources/version.txt"; -export const terrainMapFileLoader = new FetchGameMapLoader(`/maps`, version); +export const terrainMapFileLoader = new FetchGameMapLoader("/maps", version); diff --git a/src/client/Transport.ts b/src/client/Transport.ts index b26fa6a97..bee171add 100644 --- a/src/client/Transport.ts +++ b/src/client/Transport.ts @@ -546,7 +546,7 @@ export class Transport { private onPauseGameEvent(event: PauseGameEvent) { if (!this.isLocal) { - console.log(`cannot pause multiplayer games`); + console.log("cannot pause multiplayer games"); return; } if (event.paused) { diff --git a/src/core/execution/DeleteUnitExecution.ts b/src/core/execution/DeleteUnitExecution.ts index e1291c60b..4bf2f193a 100644 --- a/src/core/execution/DeleteUnitExecution.ts +++ b/src/core/execution/DeleteUnitExecution.ts @@ -50,13 +50,13 @@ export class DeleteUnitExecution implements Execution { } if (mg.inSpawnPhase()) { - console.warn(`SECURITY: cannot delete units during spawn phase`); + console.warn("SECURITY: cannot delete units during spawn phase"); this.active = false; return; } if (!this.player.canDeleteUnit()) { - console.warn(`SECURITY: delete unit cooldown not expired`); + console.warn("SECURITY: delete unit cooldown not expired"); this.active = false; return; } @@ -65,7 +65,7 @@ export class DeleteUnitExecution implements Execution { this.player.recordDeleteUnit(); this.mg.displayMessage( - `events_display.unit_voluntarily_deleted`, + "events_display.unit_voluntarily_deleted", MessageType.UNIT_DESTROYED, this.player.id(), ); diff --git a/src/core/execution/MIRVExecution.ts b/src/core/execution/MIRVExecution.ts index af1b0fe70..092a5887a 100644 --- a/src/core/execution/MIRVExecution.ts +++ b/src/core/execution/MIRVExecution.ts @@ -64,7 +64,7 @@ export class MirvExecution implements Execution { if (this.nuke === null) { const spawn = this.player.canBuild(UnitType.MIRV, this.dst); if (spawn === false) { - console.warn(`cannot build MIRV`); + console.warn("cannot build MIRV"); this.active = false; return; } diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 6e22294b0..d72d894bd 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -97,7 +97,7 @@ export class NukeExecution implements Execution { if (this.nuke === null) { const spawn = this.src ?? this.player.canBuild(this.nukeType, this.dst); if (spawn === false) { - console.warn(`cannot build Nuke`); + console.warn("cannot build Nuke"); this.active = false; return; } @@ -151,7 +151,7 @@ export class NukeExecution implements Execution { // make the nuke unactive if it was intercepted if (!this.nuke.isActive()) { - console.log(`Nuke destroyed before reaching target`); + console.log("Nuke destroyed before reaching target"); this.active = false; return; } diff --git a/src/core/execution/TradeShipExecution.ts b/src/core/execution/TradeShipExecution.ts index eb3ac53eb..74a5e35fb 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -38,7 +38,7 @@ export class TradeShipExecution implements Execution { this.srcPort.tile(), ); if (spawn === false) { - console.warn(`cannot build trade ship`); + console.warn("cannot build trade ship"); this.active = false; return; } diff --git a/src/core/execution/TrainExecution.ts b/src/core/execution/TrainExecution.ts index 1edc4a7c8..8465e44e7 100644 --- a/src/core/execution/TrainExecution.ts +++ b/src/core/execution/TrainExecution.ts @@ -58,7 +58,7 @@ export class TrainExecution implements Execution { const spawn = this.player.canBuild(UnitType.Train, this.stations[0].tile()); if (spawn === false) { - console.warn(`cannot build train`); + console.warn("cannot build train"); this.active = false; return; } diff --git a/src/core/execution/TransportShipExecution.ts b/src/core/execution/TransportShipExecution.ts index 65cac218a..6901c6116 100644 --- a/src/core/execution/TransportShipExecution.ts +++ b/src/core/execution/TransportShipExecution.ts @@ -108,7 +108,7 @@ export class TransportShipExecution implements Execution { this.dst, ); if (closestTileSrc === false) { - console.warn(`can't build transport ship`); + console.warn("can't build transport ship"); this.active = false; return; } @@ -214,7 +214,7 @@ export class TransportShipExecution implements Execution { break; case PathFindResultType.PathNotFound: // TODO: add to poisoned port list - console.warn(`path not found to dst`); + console.warn("path not found to dst"); this.attacker.addTroops(this.boat.troops()); this.boat.delete(false); this.active = false; diff --git a/src/core/execution/UpgradeStructureExecution.ts b/src/core/execution/UpgradeStructureExecution.ts index 1d83f1c77..04bf5d787 100644 --- a/src/core/execution/UpgradeStructureExecution.ts +++ b/src/core/execution/UpgradeStructureExecution.ts @@ -15,7 +15,7 @@ export class UpgradeStructureExecution implements Execution { .find((unit) => unit.id() === this.unitId); if (this.structure === undefined) { - console.warn(`structure is undefined`); + console.warn("structure is undefined"); return; } diff --git a/src/core/execution/WarshipExecution.ts b/src/core/execution/WarshipExecution.ts index 331d82394..ba323a3d5 100644 --- a/src/core/execution/WarshipExecution.ts +++ b/src/core/execution/WarshipExecution.ts @@ -194,7 +194,7 @@ export class WarshipExecution implements Execution { this.warship.touch(); break; case PathFindResultType.PathNotFound: - console.log(`path not found to target`); + console.log("path not found to target"); break; } } @@ -224,7 +224,7 @@ export class WarshipExecution implements Execution { this.warship.touch(); return; case PathFindResultType.PathNotFound: - console.warn(`path not found to target tile`); + console.warn("path not found to target tile"); this.warship.setTargetTile(undefined); break; } diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index 4d53e8cc6..90a82f94a 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -248,7 +248,7 @@ export class GameImpl implements Game { .incomingAllianceRequests() .find((ar) => ar.requestor() === recipient); if (correspondingReq !== undefined) { - console.log(`got corresponding alliance requests, accepting`); + console.log("got corresponding alliance requests, accepting"); correspondingReq.accept(); return null; } @@ -502,7 +502,7 @@ export class GameImpl implements Game { conquer(owner: PlayerImpl, tile: TileRef): void { if (!this.isLand(tile)) { - throw Error(`cannot conquer water`); + throw Error("cannot conquer water"); } const previousOwner = this.owner(tile) as TerraNullius | PlayerImpl; if (previousOwner.isPlayer()) { @@ -523,7 +523,7 @@ export class GameImpl implements Game { relinquish(tile: TileRef) { if (!this.hasOwner(tile)) { - throw new Error(`Cannot relinquish tile because it is unowned`); + throw new Error("Cannot relinquish tile because it is unowned"); } if (this.isWater(tile)) { throw new Error("Cannot relinquish water"); diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index 1cef07ba5..e3b79d3a2 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -330,7 +330,7 @@ export class PlayerImpl implements Player { } relinquish(tile: TileRef) { if (this.mg.owner(tile) !== this) { - throw new Error(`Cannot relinquish tile not owned by this player`); + throw new Error("Cannot relinquish tile not owned by this player"); } this.mg.relinquish(tile); } @@ -439,7 +439,7 @@ export class PlayerImpl implements Player { createAllianceRequest(recipient: Player): AllianceRequest | null { if (this.isAlliedWith(recipient)) { - throw new Error(`cannot create alliance request, already allies`); + throw new Error("cannot create alliance request, already allies"); } return this.mg.createAllianceRequest(this, recipient satisfies Player); } diff --git a/src/core/worker/Worker.worker.ts b/src/core/worker/Worker.worker.ts index f14f69461..28e979c7e 100644 --- a/src/core/worker/Worker.worker.ts +++ b/src/core/worker/Worker.worker.ts @@ -15,7 +15,7 @@ import version from "../../../resources/version.txt"; const ctx: Worker = self as unknown as Worker; let gameRunner: Promise | null = null; -const mapLoader = new FetchGameMapLoader(`/maps`, version); +const mapLoader = new FetchGameMapLoader("/maps", version); function gameUpdate(gu: GameUpdateViewData | ErrorUpdate) { // skip if ErrorUpdate diff --git a/src/server/GameServer.ts b/src/server/GameServer.ts index f61ad49c5..019413432 100644 --- a/src/server/GameServer.ts +++ b/src/server/GameServer.ts @@ -127,7 +127,7 @@ export class GameServer { public addClient(client: Client, lastTurn: number) { this.websockets.add(client.ws); if (this.kickedClients.has(client.clientID)) { - this.log.warn(`cannot add client, already kicked`, { + this.log.warn("cannot add client, already kicked", { clientID: client.clientID, }); return; @@ -377,7 +377,7 @@ export class GameServer { } }); if (!this._hasPrestarted && !this._hasStarted) { - this.log.info(`game not started, not archiving game`); + this.log.info("game not started, not archiving game"); return; } this.log.info(`ending game with ${this.turns.length} turns`); @@ -506,7 +506,7 @@ export class GameServer { public kickClient(clientID: ClientID): void { if (this.kickedClients.has(clientID)) { - this.log.warn(`cannot kick client, already kicked`, { + this.log.warn("cannot kick client, already kicked", { clientID, }); return; @@ -529,7 +529,7 @@ export class GameServer { ); this.kickedClients.add(clientID); } else { - this.log.warn(`cannot kick client, not found in game`, { + this.log.warn("cannot kick client, not found in game", { clientID, }); } diff --git a/src/server/Master.ts b/src/server/Master.ts index 45485bcfa..f110e286d 100644 --- a/src/server/Master.ts +++ b/src/server/Master.ts @@ -123,7 +123,7 @@ export async function startMaster() { // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment const workerId = (worker as any).process?.env?.WORKER_ID; if (!workerId) { - log.error(`worker crashed could not find id`); + log.error("worker crashed could not find id"); return; } diff --git a/src/server/PrivilegeRefresher.ts b/src/server/PrivilegeRefresher.ts index b22d1d2c0..6846293c1 100644 --- a/src/server/PrivilegeRefresher.ts +++ b/src/server/PrivilegeRefresher.ts @@ -59,7 +59,7 @@ export class PrivilegeRefresher { result.data, base64url.decode, ); - this.log.info(`Privilege checker loaded successfully`); + this.log.info("Privilege checker loaded successfully"); } catch (error) { this.log.error(`Failed to fetch cosmetics from ${this.endpoint}:`, error); throw error; diff --git a/src/server/Server.ts b/src/server/Server.ts index f08a3a5ed..5a9da8449 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -43,7 +43,7 @@ async function setupTunnels() { const domainToService = new Map().set( config.subdomain(), // TODO: change to 3000 when we have a proper tunnel setup. - `http://localhost:80`, + "http://localhost:80", ); for (let i = 0; i < config.numWorkers(); i++) { diff --git a/src/server/Worker.ts b/src/server/Worker.ts index 0a8db2e1c..74ae4cc6f 100644 --- a/src/server/Worker.ts +++ b/src/server/Worker.ts @@ -30,7 +30,7 @@ const log = logger.child({ comp: `w_${workerId}` }); // Worker setup export async function startWorker() { - log.info(`Worker starting...`); + log.info("Worker starting..."); const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -98,7 +98,7 @@ export async function startWorker() { })(); if (!id) { - log.warn(`cannot create game, id not found`); + log.warn("cannot create game, id not found"); return res.status(400).json({ error: "Game ID is required" }); } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -342,7 +342,7 @@ export async function startWorker() { type: "WORKER_READY", workerId: workerId, }); - log.info(`signaled ready state to master`); + log.info("signaled ready state to master"); } }); @@ -354,10 +354,10 @@ export async function startWorker() { // Process-level error handlers process.on("uncaughtException", (err) => { - log.error(`uncaught exception:`, err); + log.error("uncaught exception:", err); }); process.on("unhandledRejection", (reason, promise) => { - log.error(`unhandled rejection at:`, promise, "reason:", reason); + log.error("unhandled rejection at:", promise, "reason:", reason); }); } diff --git a/src/server/worker/websocket/handler/message/PostJoinHandler.ts b/src/server/worker/websocket/handler/message/PostJoinHandler.ts index 6c0019bcb..06130984b 100644 --- a/src/server/worker/websocket/handler/message/PostJoinHandler.ts +++ b/src/server/worker/websocket/handler/message/PostJoinHandler.ts @@ -42,7 +42,7 @@ export async function postJoinMessageHandler( } switch (clientMsg.intent.type) { case "mark_disconnected": { - log.warn(`Should not receive mark_disconnected intent from client`); + log.warn("Should not receive mark_disconnected intent from client"); return; } @@ -52,7 +52,7 @@ export async function postJoinMessageHandler( // Check if the authenticated client is the lobby creator if (authenticatedClientID !== gs.lobbyCreatorID) { - log.warn(`Only lobby creator can kick players`, { + log.warn("Only lobby creator can kick players", { clientID: authenticatedClientID, creatorID: gs.lobbyCreatorID, gameID: gs.id, @@ -63,14 +63,14 @@ export async function postJoinMessageHandler( // Don't allow lobby creator to kick themselves if (authenticatedClientID === clientMsg.intent.target) { - log.warn(`Cannot kick yourself`, { + log.warn("Cannot kick yourself", { clientID: authenticatedClientID, }); return; } // Log and execute the kick - log.info(`Lobby creator initiated kick of player`, { + log.info("Lobby creator initiated kick of player", { creatorID: authenticatedClientID, gameID: gs.id, kickMethod: "websocket",