Enable the @stylistic/ts/quotes eslint rule (#1850)

## Description:

Enable the `@stylistic/ts/quotes` eslint rule.

Fixes #1788

## 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-17 21:00:16 -04:00
committed by GitHub
parent 0a40bcebf0
commit 1da46cfef2
24 changed files with 44 additions and 44 deletions
+3 -3
View File
@@ -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: [
+1 -1
View File
@@ -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 (
+1 -1
View File
@@ -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";
+1 -1
View File
@@ -75,7 +75,7 @@ export class PublicLobby extends LitElement {
async fetchLobbies(): Promise<GameInfo[]> {
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();
+1 -1
View File
@@ -206,7 +206,7 @@ export class SinglePlayerModal extends LitElement {
<div class="option-card-title">
${typeof o === "string"
? translateText(`public_lobby.teams_${o}`)
: translateText(`public_lobby.teams`, { num: o })}
: translateText("public_lobby.teams", { num: o })}
</div>
</div>
`,
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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) {
+3 -3
View File
@@ -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(),
);
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -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;
@@ -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;
}
+2 -2
View File
@@ -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;
}
+3 -3
View File
@@ -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");
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -15,7 +15,7 @@ import version from "../../../resources/version.txt";
const ctx: Worker = self as unknown as Worker;
let gameRunner: Promise<GameRunner> | null = null;
const mapLoader = new FetchGameMapLoader(`/maps`, version);
const mapLoader = new FetchGameMapLoader("/maps", version);
function gameUpdate(gu: GameUpdateViewData | ErrorUpdate) {
// skip if ErrorUpdate
+4 -4
View File
@@ -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,
});
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -43,7 +43,7 @@ async function setupTunnels() {
const domainToService = new Map<string, string>().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++) {
+5 -5
View File
@@ -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);
});
}
@@ -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",