Enable the sort-keys eslint rule (#1746)

## Description:

Enable the `sort-keys` eslint rule.

Fixes #1629

## 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
- [ ] I have read and accepted the CLA agreement (only required once).
This commit is contained in:
Scott Anderson
2025-08-07 19:13:42 -04:00
committed by GitHub
parent 63cb51a4f9
commit b56e380107
48 changed files with 320 additions and 254 deletions
+60 -60
View File
@@ -144,17 +144,17 @@ const TeamCountConfigSchema = z.union([
export type TeamCountConfig = z.infer<typeof TeamCountConfigSchema>;
export const GameConfigSchema = z.object({
gameMap: z.enum(GameMapType),
difficulty: z.enum(Difficulty),
gameType: z.enum(GameType),
gameMode: z.enum(GameMode),
disableNPCs: z.boolean(),
bots: z.number().int().min(0).max(400),
difficulty: z.enum(Difficulty),
disableNPCs: z.boolean(),
disabledUnits: z.enum(UnitType).array().optional(),
gameMap: z.enum(GameMapType),
gameMode: z.enum(GameMode),
gameType: z.enum(GameType),
infiniteGold: z.boolean(),
infiniteTroops: z.boolean(),
instantBuild: z.boolean(),
maxPlayers: z.number().optional(),
disabledUnits: z.enum(UnitType).array().optional(),
playerTeams: TeamCountConfigSchema.optional(),
});
@@ -244,82 +244,82 @@ const BaseIntentSchema = z.object({
});
export const AllianceExtensionIntentSchema = BaseIntentSchema.extend({
type: z.literal("allianceExtension"),
recipient: ID,
type: z.literal("allianceExtension"),
});
export const AttackIntentSchema = BaseIntentSchema.extend({
type: z.literal("attack"),
targetID: ID.nullable(),
troops: z.number().nonnegative().nullable(),
type: z.literal("attack"),
});
export const SpawnIntentSchema = BaseIntentSchema.extend({
type: z.literal("spawn"),
name: UsernameSchema,
flag: FlagSchema,
name: UsernameSchema,
pattern: PatternSchema,
playerType: PlayerTypeSchema,
tile: z.number(),
type: z.literal("spawn"),
});
export const BoatAttackIntentSchema = BaseIntentSchema.extend({
type: z.literal("boat"),
targetID: ID.nullable(),
troops: z.number().nonnegative(),
dst: z.number(),
src: z.number().nullable(),
targetID: ID.nullable(),
troops: z.number().nonnegative(),
type: z.literal("boat"),
});
export const AllianceRequestIntentSchema = BaseIntentSchema.extend({
type: z.literal("allianceRequest"),
recipient: ID,
type: z.literal("allianceRequest"),
});
export const AllianceRequestReplyIntentSchema = BaseIntentSchema.extend({
type: z.literal("allianceRequestReply"),
requestor: ID, // The one who made the original alliance request
accept: z.boolean(),
requestor: ID, // The one who made the original alliance request
type: z.literal("allianceRequestReply"),
});
export const BreakAllianceIntentSchema = BaseIntentSchema.extend({
type: z.literal("breakAlliance"),
recipient: ID,
type: z.literal("breakAlliance"),
});
export const TargetPlayerIntentSchema = BaseIntentSchema.extend({
type: z.literal("targetPlayer"),
target: ID,
type: z.literal("targetPlayer"),
});
export const EmojiIntentSchema = BaseIntentSchema.extend({
type: z.literal("emoji"),
recipient: z.union([ID, z.literal(AllPlayers)]),
emoji: EmojiSchema,
recipient: z.union([ID, z.literal(AllPlayers)]),
type: z.literal("emoji"),
});
export const EmbargoIntentSchema = BaseIntentSchema.extend({
type: z.literal("embargo"),
targetID: ID,
action: z.union([z.literal("start"), z.literal("stop")]),
targetID: ID,
type: z.literal("embargo"),
});
export const DonateGoldIntentSchema = BaseIntentSchema.extend({
type: z.literal("donate_gold"),
recipient: ID,
gold: z.bigint().nullable(),
recipient: ID,
type: z.literal("donate_gold"),
});
export const DonateTroopIntentSchema = BaseIntentSchema.extend({
type: z.literal("donate_troops"),
recipient: ID,
troops: z.number().nullable(),
type: z.literal("donate_troops"),
});
export const BuildUnitIntentSchema = BaseIntentSchema.extend({
tile: z.number(),
type: z.literal("build_unit"),
unit: z.enum(UnitType),
tile: z.number(),
});
export const UpgradeStructureIntentSchema = BaseIntentSchema.extend({
@@ -329,8 +329,8 @@ export const UpgradeStructureIntentSchema = BaseIntentSchema.extend({
});
export const CancelAttackIntentSchema = BaseIntentSchema.extend({
type: z.literal("cancel_attack"),
attackID: z.string(),
type: z.literal("cancel_attack"),
});
export const CancelBoatIntentSchema = BaseIntentSchema.extend({
@@ -339,9 +339,9 @@ export const CancelBoatIntentSchema = BaseIntentSchema.extend({
});
export const MoveWarshipIntentSchema = BaseIntentSchema.extend({
tile: z.number(),
type: z.literal("move_warship"),
unitId: z.number(),
tile: z.number(),
});
export const DeleteUnitIntentSchema = BaseIntentSchema.extend({
@@ -350,20 +350,20 @@ export const DeleteUnitIntentSchema = BaseIntentSchema.extend({
});
export const QuickChatIntentSchema = BaseIntentSchema.extend({
type: z.literal("quick_chat"),
recipient: ID,
quickChatKey: QuickChatKeySchema,
recipient: ID,
target: ID.optional(),
type: z.literal("quick_chat"),
});
export const MarkDisconnectedIntentSchema = BaseIntentSchema.extend({
type: z.literal("mark_disconnected"),
isDisconnected: z.boolean(),
type: z.literal("mark_disconnected"),
});
export const KickPlayerIntentSchema = BaseIntentSchema.extend({
type: z.literal("kick_player"),
target: ID,
type: z.literal("kick_player"),
});
const IntentSchema = z.discriminatedUnion("type", [
@@ -395,22 +395,22 @@ const IntentSchema = z.discriminatedUnion("type", [
//
export const TurnSchema = z.object({
turnNumber: z.number(),
intents: IntentSchema.array(),
// The hash of the game state at the end of the turn.
hash: z.number().nullable().optional(),
intents: IntentSchema.array(),
turnNumber: z.number(),
});
export const PlayerSchema = z.object({
clientID: ID,
username: UsernameSchema,
flag: FlagSchema,
pattern: PatternSchema,
username: UsernameSchema,
});
export const GameStartInfoSchema = z.object({
gameID: ID,
config: GameConfigSchema,
gameID: ID,
players: PlayerSchema.array(),
});
@@ -427,8 +427,8 @@ export type Winner = z.infer<typeof WinnerSchema>;
//
export const ServerTurnMessageSchema = z.object({
type: z.literal("turn"),
turn: TurnSchema,
type: z.literal("turn"),
});
export const ServerPingMessageSchema = z.object({
@@ -436,30 +436,30 @@ export const ServerPingMessageSchema = z.object({
});
export const ServerPrestartMessageSchema = z.object({
type: z.literal("prestart"),
gameMap: z.nativeEnum(GameMapType),
type: z.literal("prestart"),
});
export const ServerStartGameMessageSchema = z.object({
type: z.literal("start"),
gameStartInfo: GameStartInfoSchema,
// Turns the client missed if they are late to the game.
turns: TurnSchema.array(),
gameStartInfo: GameStartInfoSchema,
type: z.literal("start"),
});
export const ServerDesyncSchema = z.object({
type: z.literal("desync"),
turn: z.number(),
correctHash: z.number().nullable(),
clientsWithCorrectHash: z.number(),
correctHash: z.number().nullable(),
totalActiveClients: z.number(),
turn: z.number(),
type: z.literal("desync"),
yourHash: z.number().optional(),
});
export const ServerErrorSchema = z.object({
type: z.literal("error"),
error: z.string(),
message: z.string().optional(),
type: z.literal("error"),
});
export const ServerMessageSchema = z.discriminatedUnion("type", [
@@ -476,21 +476,21 @@ export const ServerMessageSchema = z.discriminatedUnion("type", [
//
export const ClientSendWinnerSchema = z.object({
allPlayersStats: AllPlayersStatsSchema,
type: z.literal("winner"),
winner: WinnerSchema,
allPlayersStats: AllPlayersStatsSchema,
});
export const ClientHashSchema = z.object({
type: z.literal("hash"),
hash: z.number(),
turnNumber: z.number(),
type: z.literal("hash"),
});
export const ClientLogMessageSchema = z.object({
type: z.literal("log"),
severity: z.enum(LogSeverity),
log: ID,
severity: z.enum(LogSeverity),
type: z.literal("log"),
});
export const ClientPingMessageSchema = z.object({
@@ -498,20 +498,20 @@ export const ClientPingMessageSchema = z.object({
});
export const ClientIntentMessageSchema = z.object({
type: z.literal("intent"),
intent: IntentSchema,
type: z.literal("intent"),
});
// WARNING: never send this message to clients.
export const ClientJoinMessageSchema = z.object({
type: z.literal("join"),
clientID: ID,
token: TokenSchema, // WARNING: PII
flag: FlagSchema,
gameID: ID,
lastTurn: z.number(), // The last turn the client saw.
username: UsernameSchema,
flag: FlagSchema,
pattern: PatternSchema,
token: TokenSchema, // WARNING: PII
type: z.literal("join"),
username: UsernameSchema,
});
export const ClientMessageSchema = z.discriminatedUnion("type", [
@@ -534,11 +534,11 @@ export const PlayerRecordSchema = PlayerSchema.extend({
export type PlayerRecord = z.infer<typeof PlayerRecordSchema>;
export const GameEndInfoSchema = GameStartInfoSchema.extend({
duration: z.number().nonnegative(),
end: z.number(),
num_turns: z.number(),
players: PlayerRecordSchema.array(),
start: z.number(),
end: z.number(),
duration: z.number().nonnegative(),
num_turns: z.number(),
winner: WinnerSchema,
});
export type GameEndInfo = z.infer<typeof GameEndInfoSchema>;
@@ -546,11 +546,11 @@ export type GameEndInfo = z.infer<typeof GameEndInfoSchema>;
const GitCommitSchema = z.string().regex(/^[0-9a-fA-F]{40}$/);
export const AnalyticsRecordSchema = z.object({
info: GameEndInfoSchema,
version: z.literal("v0.0.2"),
gitCommit: GitCommitSchema,
subdomain: z.string(),
domain: z.string(),
gitCommit: GitCommitSchema,
info: GameEndInfoSchema,
subdomain: z.string(),
version: z.literal("v0.0.2"),
});
export type AnalyticsRecord = z.infer<typeof AnalyticsRecordSchema>;