diff --git a/eslint-plugin-local/rules/no-z-array.js b/eslint-plugin-local/rules/no-z-array.js index c45016f79..02ef39b8f 100644 --- a/eslint-plugin-local/rules/no-z-array.js +++ b/eslint-plugin-local/rules/no-z-array.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ export default { create(context) { return { diff --git a/eslint.config.js b/eslint.config.js index 9495a5175..4b4e3166c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -88,7 +88,7 @@ export default [ "indent": "off", // @stylistic/ts/indent "sort-keys": "error", "@typescript-eslint/no-unsafe-argument": "error", - // "@typescript-eslint/no-unsafe-assignment": "error", // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1781 + "@typescript-eslint/no-unsafe-assignment": "error", // "@typescript-eslint/no-unsafe-member-access": "error", // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1783 // "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1784 "@typescript-eslint/no-unused-vars": "off", @@ -134,6 +134,7 @@ export default [ // Disabled rules for tests, configs "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", "sort-keys": "off", }, }, diff --git a/src/client/LangSelector.ts b/src/client/LangSelector.ts index 2aad69116..c5fef9ab6 100644 --- a/src/client/LangSelector.ts +++ b/src/client/LangSelector.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { LitElement, html } from "lit"; import { customElement, state } from "lit/decorators.js"; import "./LanguageModal"; diff --git a/src/client/UserSettingModal.ts b/src/client/UserSettingModal.ts index 344f7a46e..60d7d7f03 100644 --- a/src/client/UserSettingModal.ts +++ b/src/client/UserSettingModal.ts @@ -182,16 +182,6 @@ export class UserSettingModal extends LitElement { } } - private sliderTroopRatio(e: CustomEvent<{ value: number }>) { - const value = e.detail?.value; - if (typeof value === "number") { - const ratio = value / 100; - localStorage.setItem("settings.troopRatio", ratio.toString()); - } else { - console.warn("Slider event missing detail.value", e); - } - } - private toggleTerritoryPatterns(e: CustomEvent<{ checked: boolean }>) { const enabled = e.detail?.checked; if (typeof enabled !== "boolean") return; @@ -389,7 +379,7 @@ export class UserSettingModal extends LitElement { max="100" value="40" easter="true" - @change=${(e: CustomEvent) => { + @change=${(e: CustomEvent<{ value: unknown }>) => { const value = e.detail?.value; if (value !== undefined) { console.log("Changed:", value); @@ -408,7 +398,7 @@ export class UserSettingModal extends LitElement { min="0" max="1000" easter="true" - @change=${(e: CustomEvent) => { + @change=${(e: CustomEvent<{ value: unknown }>) => { const value = e.detail?.value; if (value !== undefined) { console.log("Changed:", value); diff --git a/src/client/Utils.ts b/src/client/Utils.ts index 184329f63..ee4d676e0 100644 --- a/src/client/Utils.ts +++ b/src/client/Utils.ts @@ -84,7 +84,7 @@ export const translateText = ( key: string, params: Record = {}, ): string => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment const self = translateText as any; self.formatterCache ??= new Map(); self.lastLang ??= null; @@ -124,6 +124,7 @@ export const translateText = ( ? "en" : langSelector.currentLang; const cacheKey = `${key}:${locale}:${message}`; + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment let formatter = self.formatterCache.get(cacheKey); if (!formatter) { diff --git a/src/client/components/baseComponents/setting/SettingSlider.ts b/src/client/components/baseComponents/setting/SettingSlider.ts index 87927d467..67bd562dd 100644 --- a/src/client/components/baseComponents/setting/SettingSlider.ts +++ b/src/client/components/baseComponents/setting/SettingSlider.ts @@ -28,17 +28,6 @@ export class SettingSlider extends LitElement { ); } - private handleSliderChange(e: Event) { - const detail = (e as CustomEvent)?.detail; - if (!detail || detail.value === undefined) { - console.warn("Invalid slider change event", e); - return; - } - - const value = detail.value; - console.log("Slider changed to", value); - } - private updateSliderStyle(slider: HTMLInputElement) { const percent = ((this.value - this.min) / (this.max - this.min)) * 100; slider.style.background = `linear-gradient(to right, #2196f3 ${percent}%, #444 ${percent}%)`; diff --git a/src/client/graphics/NameBoxCalculator.ts b/src/client/graphics/NameBoxCalculator.ts index 2d291c04d..0cb0942b9 100644 --- a/src/client/graphics/NameBoxCalculator.ts +++ b/src/client/graphics/NameBoxCalculator.ts @@ -81,9 +81,9 @@ export function createGrid( const width = scaledBoundingBox.max.x - scaledBoundingBox.min.x + 1; const height = scaledBoundingBox.max.y - scaledBoundingBox.min.y + 1; - const grid: boolean[][] = Array(width) - .fill(null) - .map(() => Array(height).fill(false)); + const grid: boolean[][] = Array>(width) + .fill(null as unknown as boolean[]) + .map(() => Array(height).fill(false)); for (let x = scaledBoundingBox.min.x; x <= scaledBoundingBox.max.x; x++) { for (let y = scaledBoundingBox.min.y; y <= scaledBoundingBox.max.y; y++) { @@ -102,7 +102,7 @@ export function createGrid( export function findLargestInscribedRectangle(grid: boolean[][]): Rectangle { const rows = grid[0].length; const cols = grid.length; - const heights: number[] = new Array(cols).fill(0); + const heights: number[] = new Array(cols).fill(0); let largestRect: Rectangle = { x: 0, y: 0, width: 0, height: 0 }; for (let row = 0; row < rows; row++) { diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index b70bbae13..03637952c 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -297,7 +297,7 @@ export class FakeHumanExecution implements Execution { UnitType.SAMLauncher, ); const structureTiles = structures.map((u) => u.tile()); - const randomTiles: (TileRef | null)[] = new Array(10); + const randomTiles: (TileRef | null)[] = new Array(10).fill(null); for (let i = 0; i < randomTiles.length; i++) { randomTiles[i] = this.randTerritoryTile(other); } diff --git a/src/core/game/GameMap.ts b/src/core/game/GameMap.ts index 230d52c3a..995e3b5d4 100644 --- a/src/core/game/GameMap.ts +++ b/src/core/game/GameMap.ts @@ -92,9 +92,9 @@ export class GameMapImpl implements GameMap { this.state = new Uint16Array(width * height); // Precompute the LUTs let ref = 0; - this.refToX = new Array(width * height); - this.refToY = new Array(width * height); - this.yToRef = new Array(height); + this.refToX = new Array(width * height); + this.refToY = new Array(width * height); + this.yToRef = new Array(height); for (let y = 0; y < height; y++) { this.yToRef[y] = ref; for (let x = 0; x < width; x++) { diff --git a/src/server/Gatekeeper.ts b/src/server/Gatekeeper.ts index 81d2fd9ff..2e1faf3b8 100644 --- a/src/server/Gatekeeper.ts +++ b/src/server/Gatekeeper.ts @@ -66,6 +66,7 @@ async function getGatekeeper(): Promise { // Use dynamic import for ES modules // Using a type assertion to avoid TypeScript errors for optional modules + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const module = await import( "./gatekeeper/RealGatekeeper.js" as string ).catch(() => import("./gatekeeper/RealGatekeeper.js" as string)); diff --git a/src/server/Master.ts b/src/server/Master.ts index c13014214..b7181e0af 100644 --- a/src/server/Master.ts +++ b/src/server/Master.ts @@ -91,6 +91,7 @@ export async function startMaster() { cluster.on("message", (worker, message) => { if (message.type === "WORKER_READY") { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const workerId = message.workerId; readyWorkers.add(workerId); log.info( @@ -121,7 +122,7 @@ export async function startMaster() { // Handle worker crashes cluster.on("exit", (worker, code, signal) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // 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`); @@ -135,6 +136,7 @@ export async function startMaster() { // Restart the worker with the same ID const newWorker = cluster.fork({ + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment WORKER_ID: workerId, }); diff --git a/tmp b/tmp deleted file mode 100644 index e69de29bb..000000000