From 356364d2009c3ea07149f0d627f9ac07286d3468 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:38:52 -0400 Subject: [PATCH] Enable the `@typescript-eslint/no-unsafe-argument` eslint rule (#1831) ## Description: Enable the `@typescript-eslint/no-unsafe-argument` eslint rule. Fixes #1780 ## 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 --- eslint.config.js | 5 +++-- src/client/LangSelector.ts | 4 ++++ src/client/LanguageModal.ts | 4 +++- src/client/Transport.ts | 1 + src/client/graphics/layers/RadialMenu.ts | 8 ++++---- src/core/game/PlayerImpl.ts | 2 +- tmp | 0 7 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 tmp diff --git a/eslint.config.js b/eslint.config.js index 6c312e996..9495a5175 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -43,7 +43,6 @@ export default [ { rules: { // Disable rules that would fail. The failures should be fixed, and the entries here removed. - "@typescript-eslint/no-explicit-any": "off", // https://github.com/openfrontio/OpenFrontIO/issues/1789 "@typescript-eslint/no-unused-expressions": "off", // https://github.com/openfrontio/OpenFrontIO/issues/1790 "no-case-declarations": "off", // https://github.com/openfrontio/OpenFrontIO/issues/1791 }, @@ -88,7 +87,7 @@ export default [ "eqeqeq": "error", "indent": "off", // @stylistic/ts/indent "sort-keys": "error", - // "@typescript-eslint/no-unsafe-argument": "error", // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1780 + "@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-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 @@ -108,6 +107,7 @@ export default [ "max-lines-per-function": ["error", { max: 561 }], "no-loss-of-precision": "error", "no-multi-spaces": "error", + "no-trailing-spaces": "error", "object-curly-newline": ["error", { multiline: true, consistent: true }], "object-curly-spacing": ["error", "always"], "object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }], @@ -133,6 +133,7 @@ export default [ rules: { // Disabled rules for tests, configs "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unsafe-argument": "off", "sort-keys": "off", }, }, diff --git a/src/client/LangSelector.ts b/src/client/LangSelector.ts index b55c78955..2aad69116 100644 --- a/src/client/LangSelector.ts +++ b/src/client/LangSelector.ts @@ -125,6 +125,7 @@ export class LangSelector extends LitElement { private loadLanguage(lang: string): Record { const language = this.languageMap[lang] ?? {}; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const flat = flattenTranslations(language); return flat; } @@ -186,6 +187,7 @@ export class LangSelector extends LitElement { if (currentLangEntry) finalList.push(currentLangEntry); if (englishEntry) finalList.push(englishEntry); if (browserLangEntry) finalList.push(browserLangEntry); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument finalList.push(...list); if (debugLang) finalList.push(debugLang); @@ -316,6 +318,7 @@ export class LangSelector extends LitElement { .languageList=${this.languageList} .currentLang=${this.currentLang} @language-selected=${(e: CustomEvent) => + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.changeLanguage(e.detail.lang)} @close-modal=${() => (this.showModal = false)} > @@ -336,6 +339,7 @@ function flattenTranslations( if (typeof value === "string") { result[fullKey] = value; } else if (value && typeof value === "object" && !Array.isArray(value)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument flattenTranslations(value, fullKey, result); } else { console.warn("Unknown type", typeof value, value); diff --git a/src/client/LanguageModal.ts b/src/client/LanguageModal.ts index 236715d03..73c4a1b1f 100644 --- a/src/client/LanguageModal.ts +++ b/src/client/LanguageModal.ts @@ -106,7 +106,9 @@ export class LanguageModal extends LitElement { return html`