Enable various eslint rules (#1773)

## Description:

Enable various eslint rules.

## 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-11 22:14:00 -04:00
committed by GitHub
parent 8a41919ed7
commit ce49599229
109 changed files with 471 additions and 460 deletions
+42 -42
View File
@@ -26,10 +26,10 @@ export type GameUpdates = {
[K in GameUpdateType]: UpdateTypeMap<K>[];
};
export interface MapPos {
export type MapPos = {
x: number;
y: number;
}
};
export enum Difficulty {
Easy = "Easy",
@@ -141,7 +141,7 @@ export enum GameMode {
Team = "Team",
}
export interface UnitInfo {
export type UnitInfo = {
cost: (player: Player) => Gold;
// Determines if its owner changes when its tile is conquered.
territoryBound: boolean;
@@ -151,7 +151,7 @@ export interface UnitInfo {
upgradable?: boolean;
canBuildTrainStation?: boolean;
experimental?: boolean;
}
};
export enum UnitType {
TransportShip = "Transport",
@@ -191,15 +191,15 @@ export function isStructureType(type: UnitType): boolean {
return _structureTypes.has(type);
}
export interface OwnerComp {
export type OwnerComp = {
owner: Player;
}
};
export type TrajectoryTile = {
tile: TileRef;
targetable: boolean;
};
export interface UnitParamsMap {
export type UnitParamsMap = {
[UnitType.TransportShip]: {
troops?: number;
destination?: TileRef;
@@ -253,7 +253,7 @@ export interface UnitParamsMap {
};
[UnitType.Construction]: Record<string, never>;
}
};
// Type helper to get params type for a specific unit type
export type UnitParams<T extends UnitType> = UnitParamsMap[T];
@@ -320,14 +320,14 @@ export enum PlayerType {
FakeHuman = "FAKEHUMAN",
}
export interface Execution {
export type Execution = {
isActive(): boolean;
activeDuringSpawnPhase(): boolean;
init(mg: Game, ticks: number): void;
tick(ticks: number): void;
}
};
export interface Attack {
export type Attack = {
id(): string;
retreating(): boolean;
retreated(): boolean;
@@ -346,25 +346,25 @@ export interface Attack {
clearBorder(): void;
borderSize(): number;
averagePosition(): Cell | null;
}
};
export interface AllianceRequest {
export type AllianceRequest = {
accept(): void;
reject(): void;
requestor(): Player;
recipient(): Player;
createdAt(): Tick;
}
};
export interface Alliance {
export type Alliance = {
requestor(): Player;
recipient(): Player;
createdAt(): Tick;
expiresAt(): Tick;
other(player: Player): Player;
}
};
export interface MutableAlliance extends Alliance {
export type MutableAlliance = {
expire(): void;
other(player: Player): Player;
bothAgreedToExtend(): boolean;
@@ -372,7 +372,7 @@ export interface MutableAlliance extends Alliance {
id(): number;
extend(): void;
onlyOneAgreedToExtend(): boolean;
}
} & Alliance;
export class PlayerInfo {
public readonly clan: string | null;
@@ -406,7 +406,7 @@ export function isUnit(unit: unknown): unit is Unit {
);
}
export interface Unit {
export type Unit = {
isUnit(): this is Unit;
// Common properties.
@@ -480,22 +480,22 @@ export interface Unit {
// Warships
setPatrolTile(tile: TileRef): void;
patrolTile(): TileRef | undefined;
}
};
export interface TerraNullius {
export type TerraNullius = {
isPlayer(): false;
id(): null;
clientID(): ClientID;
smallID(): number;
}
};
export interface Embargo {
export type Embargo = {
createdAt: Tick;
isTemporary: boolean;
target: PlayerID;
}
};
export interface Player {
export type Player = {
// Basic Info
smallID(): number;
info(): PlayerInfo;
@@ -629,9 +629,9 @@ export interface Player {
tradingPorts(port: Unit): Unit[];
// WARNING: this operation is expensive.
bestTransportShipSpawn(tile: TileRef): TileRef | false;
}
};
export interface Game extends GameMap {
export type Game = {
// Map & Dimensions
isOnMap(cell: Cell): boolean;
width(): number;
@@ -715,33 +715,33 @@ export interface Game extends GameMap {
addUpdate(update: GameUpdate): void;
railNetwork(): RailNetwork;
conquerPlayer(conqueror: Player, conquered: Player): void;
}
} & GameMap;
export interface PlayerActions {
export type PlayerActions = {
canAttack: boolean;
buildableUnits: BuildableUnit[];
canSendEmojiAllPlayers: boolean;
interaction?: PlayerInteraction;
}
};
export interface BuildableUnit {
export type BuildableUnit = {
canBuild: TileRef | false;
// unit id of the existing unit that can be upgraded, or false if it cannot be upgraded.
canUpgrade: number | false;
type: UnitType;
cost: Gold;
}
};
export interface PlayerProfile {
export type PlayerProfile = {
relations: Record<number, Relation>;
alliances: number[];
}
};
export interface PlayerBorderTiles {
export type PlayerBorderTiles = {
borderTiles: ReadonlySet<TileRef>;
}
};
export interface PlayerInteraction {
export type PlayerInteraction = {
sharedBorder: boolean;
canSendEmoji: boolean;
canSendAllianceRequest: boolean;
@@ -751,14 +751,14 @@ export interface PlayerInteraction {
canDonateTroops: boolean;
canEmbargo: boolean;
allianceExpiresAt?: Tick;
}
};
export interface EmojiMessage {
export type EmojiMessage = {
message: string;
senderID: number;
recipientID: number | typeof AllPlayers;
createdAt: Tick;
}
};
export enum MessageType {
ATTACK_FAILED,
@@ -832,8 +832,8 @@ export function getMessageCategory(messageType: MessageType): MessageCategory {
return MESSAGE_TYPE_CATEGORIES[messageType];
}
export interface NameViewData {
export type NameViewData = {
x: number;
y: number;
size: number;
}
};