mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 18:46:40 +00:00
Enable the object-shorthand eslint rule (#1857)
## Description: Enable the `object-shorthand` 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:
+2
-1
@@ -109,11 +109,12 @@ export default [
|
||||
"max-lines-per-function": ["error", { max: 561 }],
|
||||
"no-loss-of-precision": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 0 }],
|
||||
"no-trailing-spaces": "error",
|
||||
"object-curly-newline": ["error", { multiline: true, consistent: true }],
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
||||
"no-multiple-empty-lines": ["warn", { max: 1, maxEOF: 0 }],
|
||||
"object-shorthand": ["error", "always"],
|
||||
"no-undef": "error",
|
||||
"no-unused-vars": "off", // @typescript-eslint/no-unused-vars
|
||||
"quote-props": ["error", "consistent-as-needed"],
|
||||
|
||||
@@ -477,7 +477,7 @@ export class ClientGameRunner {
|
||||
upgradeUnits.push({
|
||||
unitId: bu.canUpgrade,
|
||||
unitType: bu.type,
|
||||
distance: distance,
|
||||
distance,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function handlePurchase(priceId: string) {
|
||||
"authorization": getAuthHeader(),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
priceId: priceId,
|
||||
priceId,
|
||||
successUrl: `${window.location.origin}#purchase-completed=true`,
|
||||
cancelUrl: `${window.location.origin}#purchase-completed=false`,
|
||||
}),
|
||||
|
||||
@@ -430,10 +430,10 @@ export class SinglePlayerModal extends LitElement {
|
||||
this.dispatchEvent(
|
||||
new CustomEvent("join-lobby", {
|
||||
detail: {
|
||||
clientID: clientID,
|
||||
gameID: gameID,
|
||||
clientID,
|
||||
gameID,
|
||||
gameStartInfo: {
|
||||
gameID: gameID,
|
||||
gameID,
|
||||
players: [
|
||||
{
|
||||
clientID,
|
||||
|
||||
@@ -633,7 +633,7 @@ export class Transport {
|
||||
if (this.isLocal || this.socket?.readyState === WebSocket.OPEN) {
|
||||
const msg = {
|
||||
type: "intent",
|
||||
intent: intent,
|
||||
intent,
|
||||
} satisfies ClientIntentMessage;
|
||||
this.sendMsg(msg);
|
||||
} else {
|
||||
|
||||
@@ -151,8 +151,8 @@ export function largestRectangleInHistogram(widths: number[]): Rectangle {
|
||||
largestRect = {
|
||||
x: stack.length === 0 ? 0 : stack[stack.length - 1] + 1,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height,
|
||||
width,
|
||||
height,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
}
|
||||
|
||||
this.addEvent({
|
||||
description: description,
|
||||
description,
|
||||
createdAt: this.game.ticks(),
|
||||
highlight: true,
|
||||
type: event.messageType,
|
||||
@@ -534,8 +534,8 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
this.addEvent({
|
||||
description: translateText("events_display.betrayal_description", {
|
||||
name: betrayed.name(),
|
||||
malusPercent: malusPercent,
|
||||
durationText: durationText,
|
||||
malusPercent,
|
||||
durationText,
|
||||
}),
|
||||
type: MessageType.ALLIANCE_BROKEN,
|
||||
highlight: true,
|
||||
@@ -685,7 +685,7 @@ export class EventsDisplay extends LitElement implements Layer {
|
||||
unsafeDescription: false,
|
||||
highlight: true,
|
||||
createdAt: this.game.ticks(),
|
||||
unitView: unitView,
|
||||
unitView,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ export class Leaderboard extends LitElement implements Layer {
|
||||
gold: renderNumber(player.gold()),
|
||||
troops: renderNumber(troops),
|
||||
isMyPlayer: player === myPlayer,
|
||||
player: player,
|
||||
player,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ export class RadialMenu implements Layer {
|
||||
return color;
|
||||
}
|
||||
|
||||
return d3.color(color)?.copy({ opacity: opacity })?.toString() ?? color;
|
||||
return d3.color(color)?.copy({ opacity })?.toString() ?? color;
|
||||
})
|
||||
.attr("stroke", "#ffffff")
|
||||
.attr("stroke-width", "2")
|
||||
@@ -438,7 +438,7 @@ export class RadialMenu implements Layer {
|
||||
const opacity = disabled ? 0.5 : 0.7;
|
||||
path.attr(
|
||||
"fill",
|
||||
d3.color(color)?.copy({ opacity: opacity })?.toString() ?? color,
|
||||
d3.color(color)?.copy({ opacity })?.toString() ?? color,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -983,7 +983,7 @@ export class RadialMenu implements Layer {
|
||||
// Update path appearance
|
||||
path.attr(
|
||||
"fill",
|
||||
d3.color(color)?.copy({ opacity: opacity })?.toString() ?? color,
|
||||
d3.color(color)?.copy({ opacity })?.toString() ?? color,
|
||||
);
|
||||
path.style("opacity", disabled ? 0.5 : 1);
|
||||
path.style("cursor", disabled ? "not-allowed" : "pointer");
|
||||
|
||||
@@ -525,7 +525,7 @@ export class TerritoryLayer implements Layer {
|
||||
|
||||
enqueueTile(tile: TileRef) {
|
||||
this.tileToRenderQueue.push({
|
||||
tile: tile,
|
||||
tile,
|
||||
lastUpdate: this.game.ticks() + this.random.nextFloat(0, 0.5),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ export class GameRunner {
|
||||
packedTileUpdates: new BigUint64Array(packedTileUpdates),
|
||||
playerNameViewData: this.playerViewData,
|
||||
tick: this.game.ticks(),
|
||||
updates: updates,
|
||||
updates,
|
||||
});
|
||||
this.isExecuting = false;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ export class PlayerImpl implements Player {
|
||||
retreating: a.retreating(),
|
||||
} satisfies AttackUpdate;
|
||||
}),
|
||||
outgoingAllianceRequests: outgoingAllianceRequests,
|
||||
outgoingAllianceRequests,
|
||||
alliances: this.alliances().map(
|
||||
(a) =>
|
||||
({
|
||||
@@ -706,7 +706,7 @@ export class PlayerImpl implements Player {
|
||||
|
||||
this.embargoes.set(other.id(), {
|
||||
createdAt: this.mg.ticks(),
|
||||
isTemporary: isTemporary,
|
||||
isTemporary,
|
||||
target: other,
|
||||
});
|
||||
}
|
||||
@@ -887,7 +887,7 @@ export class PlayerImpl implements Player {
|
||||
canBuild: this.mg.inSpawnPhase()
|
||||
? false
|
||||
: this.canBuild(u, tile, validTiles),
|
||||
canUpgrade: canUpgrade,
|
||||
canUpgrade,
|
||||
cost: this.mg.config().unitInfo(u).cost(this),
|
||||
type: u,
|
||||
} as BuildableUnit;
|
||||
|
||||
@@ -52,9 +52,9 @@ export async function loadTerrainMap(
|
||||
await mapFiles.miniMapBin(),
|
||||
);
|
||||
const result = {
|
||||
gameMap: gameMap,
|
||||
gameMap,
|
||||
manifest: await mapFiles.manifest(),
|
||||
miniGameMap: miniGameMap,
|
||||
miniGameMap,
|
||||
};
|
||||
loadedMaps.set(map, result);
|
||||
return result;
|
||||
|
||||
@@ -148,7 +148,7 @@ export class SerialAStar<NodeType> implements AStar<NodeType> {
|
||||
totalG +
|
||||
this.heuristic(neighbor, isForward ? this.dst : this.closestSource);
|
||||
// eslint-disable-next-line sort-keys
|
||||
openSet.add({ tile: neighbor, fScore: fScore });
|
||||
openSet.add({ tile: neighbor, fScore });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ export class WorkerClient {
|
||||
id: messageId,
|
||||
playerID,
|
||||
type: "player_actions",
|
||||
x: x,
|
||||
y: y,
|
||||
x,
|
||||
y,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+12
-12
@@ -48,9 +48,9 @@ export async function archive(gameRecord: GameRecord) {
|
||||
|
||||
const { message, stack, name } = error;
|
||||
log.error(`${gameRecord.info.gameID}: Final archive error: ${error}`, {
|
||||
message: message,
|
||||
stack: stack,
|
||||
name: name,
|
||||
message,
|
||||
stack,
|
||||
name,
|
||||
...(error && typeof error === "object" ? error : {}),
|
||||
});
|
||||
}
|
||||
@@ -90,9 +90,9 @@ async function archiveAnalyticsToR2(gameRecord: GameRecord) {
|
||||
|
||||
const { message, stack, name } = error;
|
||||
log.error(`${info.gameID}: Error writing game analytics to R2: ${error}`, {
|
||||
message: message,
|
||||
stack: stack,
|
||||
name: name,
|
||||
message,
|
||||
stack,
|
||||
name,
|
||||
...(error && typeof error === "object" ? error : {}),
|
||||
});
|
||||
throw error;
|
||||
@@ -147,9 +147,9 @@ export async function readGameRecord(
|
||||
const { message, stack, name } = error;
|
||||
// Log the error for monitoring purposes
|
||||
log.error(`${gameId}: Error reading game record from R2: ${error}`, {
|
||||
message: message,
|
||||
stack: stack,
|
||||
name: name,
|
||||
message,
|
||||
stack,
|
||||
name,
|
||||
...(error && typeof error === "object" ? error : {}),
|
||||
});
|
||||
|
||||
@@ -178,9 +178,9 @@ export async function gameRecordExists(gameId: GameID): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
log.error(`${gameId}: Error checking archive existence: ${error}`, {
|
||||
message: message,
|
||||
stack: stack,
|
||||
name: name,
|
||||
message,
|
||||
stack,
|
||||
name,
|
||||
...(error && typeof error === "object" ? error : {}),
|
||||
});
|
||||
return false;
|
||||
|
||||
@@ -189,7 +189,7 @@ export class Cloudflare {
|
||||
...Array.from(subdomainToService.entries()).map(
|
||||
([subdomain, service]) => ({
|
||||
hostname: `${subdomain}.${domain}`,
|
||||
service: service,
|
||||
service,
|
||||
}),
|
||||
),
|
||||
{
|
||||
|
||||
@@ -562,7 +562,7 @@ export class GameServer {
|
||||
this.clientsDisconnectedStatus.set(clientID, isDisconnected);
|
||||
this.addIntent({
|
||||
clientID,
|
||||
isDisconnected: isDisconnected,
|
||||
isDisconnected,
|
||||
type: "mark_disconnected",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export class MapPlaylist {
|
||||
continue;
|
||||
}
|
||||
nextEls.splice(i, 1);
|
||||
playlist.push({ map: next, mode: mode });
|
||||
playlist.push({ map: next, mode });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -266,7 +266,7 @@ export async function startWorker() {
|
||||
|
||||
return res.status(200).json({
|
||||
exists: true,
|
||||
gameRecord: gameRecord,
|
||||
gameRecord,
|
||||
success: true,
|
||||
});
|
||||
}),
|
||||
@@ -340,7 +340,7 @@ export async function startWorker() {
|
||||
if (process.send) {
|
||||
process.send({
|
||||
type: "WORKER_READY",
|
||||
workerId: workerId,
|
||||
workerId,
|
||||
});
|
||||
log.info("signaled ready state to master");
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ function handleWinner(
|
||||
`Winner determined by ${potentialWinner.ips.size}/${activeUniqueIPs.size} active IPs`,
|
||||
{
|
||||
gameID: gs.id,
|
||||
winnerKey: winnerKey,
|
||||
winnerKey,
|
||||
},
|
||||
);
|
||||
gs.archiveGame();
|
||||
|
||||
Reference in New Issue
Block a user