diff --git a/eslint.config.js b/eslint.config.js index 8eccab6cb..4f309b3f9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -39,13 +39,10 @@ export default [ { rules: { // Disable rules that would fail. The failures should be fixed, and the entries here removed. - "@typescript-eslint/no-empty-object-type": "off", "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-require-imports": "off", "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/no-unused-vars": "off", "no-case-declarations": "off", - "no-useless-escape": "off", }, }, { diff --git a/src/core/EventBus.ts b/src/core/EventBus.ts index 73ee89ccd..008cc7320 100644 --- a/src/core/EventBus.ts +++ b/src/core/EventBus.ts @@ -1,4 +1,4 @@ -export interface GameEvent {} +export type GameEvent = object; export interface EventConstructor { new (...args: any[]): T; diff --git a/src/core/Schemas.ts b/src/core/Schemas.ts index f7ee6fd6b..9c359b41e 100644 --- a/src/core/Schemas.ts +++ b/src/core/Schemas.ts @@ -162,7 +162,7 @@ export const TeamSchema = z.string(); const SafeString = z .string() .regex( - /^([a-zA-Z0-9\s.,!?@#$%&*()\-_+=\[\]{}|;:"'\/\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|üÜ])*$/, + /^([a-zA-Z0-9\s.,!?@#$%&*()\-_+=[\]{}|;:"'/\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|üÜ])*$/, ) .max(1000); diff --git a/src/core/Util.ts b/src/core/Util.ts index 06d2246b2..ba138fe3c 100644 --- a/src/core/Util.ts +++ b/src/core/Util.ts @@ -139,7 +139,7 @@ export function getMode(list: Set): number { export function sanitize(name: string): string { return Array.from(name) .join("") - .replace(/[^\p{L}\p{N}\s\p{Emoji}\p{Emoji_Component}\[\]_]/gu, ""); + .replace(/[^\p{L}\p{N}\s\p{Emoji}\p{Emoji_Component}[\]_]/gu, ""); } export function processName(name: string): string { diff --git a/src/core/execution/MissileSiloExecution.ts b/src/core/execution/MissileSiloExecution.ts index ad05dfd1c..a7cd2bb6c 100644 --- a/src/core/execution/MissileSiloExecution.ts +++ b/src/core/execution/MissileSiloExecution.ts @@ -25,9 +25,7 @@ export class MissileSiloExecution implements Execution { this.active = false; return; } - this.silo = this.player.buildUnit(UnitType.MissileSilo, spawn, { - cooldownDuration: this.mg.config().SiloCooldown(), - }); + this.silo = this.player.buildUnit(UnitType.MissileSilo, spawn, {}); if (this.player !== this.silo.owner()) { this.player = this.silo.owner(); diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 1ff7f0b03..a897711fa 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -96,9 +96,7 @@ export class SAMLauncherExecution implements Execution { this.active = false; return; } - this.sam = this.player.buildUnit(UnitType.SAMLauncher, spawnTile, { - cooldownDuration: this.mg.config().SAMCooldown(), - }); + this.sam = this.player.buildUnit(UnitType.SAMLauncher, spawnTile, {}); } if (!this.sam.isActive()) { this.active = false; diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 3eca00170..5c50d07c3 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -194,11 +194,11 @@ export interface UnitParamsMap { patrolTile: TileRef; }; - [UnitType.Shell]: {}; + [UnitType.Shell]: Record; - [UnitType.SAMMissile]: {}; + [UnitType.SAMMissile]: Record; - [UnitType.Port]: {}; + [UnitType.Port]: Record; [UnitType.AtomBomb]: { targetTile?: number; @@ -219,25 +219,23 @@ export interface UnitParamsMap { loaded?: boolean; }; - [UnitType.Factory]: {}; + [UnitType.Factory]: Record; - [UnitType.MissileSilo]: { - cooldownDuration?: number; - }; + [UnitType.MissileSilo]: Record; - [UnitType.DefensePost]: {}; + [UnitType.DefensePost]: Record; - [UnitType.SAMLauncher]: {}; + [UnitType.SAMLauncher]: Record; - [UnitType.City]: {}; + [UnitType.City]: Record; - [UnitType.MIRV]: {}; + [UnitType.MIRV]: Record; [UnitType.MIRVWarhead]: { targetTile?: number; }; - [UnitType.Construction]: {}; + [UnitType.Construction]: Record; } // Type helper to get params type for a specific unit type @@ -381,7 +379,12 @@ export class PlayerInfo { } export function isUnit(unit: Unit | UnitParams): unit is Unit { - return "isUnit" in unit && typeof unit.isUnit === "function" && unit.isUnit(); + return ( + unit !== undefined && + "isUnit" in unit && + typeof unit.isUnit === "function" && + unit.isUnit() + ); } export interface Unit { diff --git a/src/core/validations/username.ts b/src/core/validations/username.ts index 7cc6c03d1..a7fe4f9dd 100644 --- a/src/core/validations/username.ts +++ b/src/core/validations/username.ts @@ -22,7 +22,7 @@ const matcher = new RegExpMatcher({ export const MIN_USERNAME_LENGTH = 3; export const MAX_USERNAME_LENGTH = 27; -const validPattern = /^[a-zA-Z0-9_\[\] 🐈🍀üÜ]+$/u; +const validPattern = /^[a-zA-Z0-9_[\] 🐈🍀üÜ]+$/u; const shadowNames = [ "NicePeopleOnly", diff --git a/tests/core/executions/SAMLauncherExecution.test.ts b/tests/core/executions/SAMLauncherExecution.test.ts index 993488399..2802c3b76 100644 --- a/tests/core/executions/SAMLauncherExecution.test.ts +++ b/tests/core/executions/SAMLauncherExecution.test.ts @@ -130,9 +130,7 @@ describe("SAM", () => { }); test("two sams should not target twice same nuke", async () => { - const sam1 = defender.buildUnit(UnitType.SAMLauncher, game.ref(1, 1), { - cooldownDuration: 10, - }); + const sam1 = defender.buildUnit(UnitType.SAMLauncher, game.ref(1, 1), {}); game.addExecution(new SAMLauncherExecution(defender, null, sam1)); const sam2 = defender.buildUnit(UnitType.SAMLauncher, game.ref(1, 2), {}); game.addExecution(new SAMLauncherExecution(defender, null, sam2));