From b9feaf538b1d4ae7c7148dafcae2afb39f8a5eaa Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 27 Aug 2025 11:26:04 +0200 Subject: [PATCH] chore(linting): enable restrict-plus-operands --- frontend/scripts/fontawesome.ts | 2 +- frontend/src/ts/commandline/lists.ts | 6 +++++- .../src/ts/controllers/challenge-controller.ts | 4 +++- frontend/src/ts/controllers/input-controller.ts | 2 +- frontend/src/ts/pages/settings.ts | 3 ++- frontend/src/ts/test/test-config.ts | 4 ++-- frontend/src/ts/test/test-ui.ts | 5 +++-- packages/eslint-config/index.js | 15 +++++++-------- packages/funbox/src/list.ts | 4 +++- 9 files changed, 27 insertions(+), 18 deletions(-) diff --git a/frontend/scripts/fontawesome.ts b/frontend/scripts/fontawesome.ts index 612f0a7f4..809a71a89 100644 --- a/frontend/scripts/fontawesome.ts +++ b/frontend/scripts/fontawesome.ts @@ -99,7 +99,7 @@ export function getFontawesomeConfig(debug = false): FontawesomeConfig { (it) => !(solid.includes(it) || regular.includes(it) || brands.includes(it)) ); if (leftOvers.length !== 0) { - throw new Error("unknown icons: " + leftOvers); + throw new Error("unknown icons: " + leftOvers.toString()); } if (debug) { diff --git a/frontend/src/ts/commandline/lists.ts b/frontend/src/ts/commandline/lists.ts index c49cf042e..bd4d29314 100644 --- a/frontend/src/ts/commandline/lists.ts +++ b/frontend/src/ts/commandline/lists.ts @@ -297,7 +297,11 @@ export const commands: CommandsSubgroup = { Notifications.add("Copied to clipboard", 1); }) .catch((e: unknown) => { - Notifications.add("Failed to copy to clipboard: " + e, -1); + const message = Misc.createErrorMessage( + e, + "Failed to copy to clipboard" + ); + Notifications.add(message, -1); }); }, }, diff --git a/frontend/src/ts/controllers/challenge-controller.ts b/frontend/src/ts/controllers/challenge-controller.ts index 7d438b441..e7499e57c 100644 --- a/frontend/src/ts/controllers/challenge-controller.ts +++ b/frontend/src/ts/controllers/challenge-controller.ts @@ -264,7 +264,9 @@ export async function setup(challengeName: string): Promise { UpdateConfig.setDifficulty("normal", true); } else if (challenge.type === "script") { Loader.show(); - const response = await fetch("/challenges/" + challenge.parameters[0]); + const response = await fetch( + "/challenges/" + (challenge.parameters[0] as string) + ); Loader.hide(); if (response.status !== 200) { throw new Error(`${response.status} ${response.statusText}`); diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 6e0b30c96..3d60b3eed 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -637,7 +637,7 @@ async function handleChar( if (charIndex >= currCorrectedTestInputLength) { TestInput.corrected.current += !isCharKorean ? char - : Hangul.disassemble(char).concat(); + : Hangul.disassemble(char).concat().join(""); } else if (!thisCharCorrect) { TestInput.corrected.current = TestInput.corrected.current.substring(0, charIndex) + diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 7322d5246..63e5fa7b5 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -1199,7 +1199,8 @@ $(".pageSettings .section .groupTitle button").on("click", (e) => { Notifications.add("Link copied to clipboard", 1); }) .catch((e: unknown) => { - Notifications.add("Failed to copy to clipboard: " + e, -1); + const msg = Misc.createErrorMessage(e, "Failed to copy to clipboard"); + Notifications.add(msg, -1); }); }); diff --git a/frontend/src/ts/test/test-config.ts b/frontend/src/ts/test/test-config.ts index 0b39a323d..97f291bd2 100644 --- a/frontend/src/ts/test/test-config.ts +++ b/frontend/src/ts/test/test-config.ts @@ -238,7 +238,7 @@ function updateActiveExtraButtons(key: string, value: ConfigValue): void { $("#testConfig .time .textButton").removeClass("active"); const timeCustom = ![15, 30, 60, 120].includes(value as number) ? "custom" - : value; + : (value as number); $( "#testConfig .time .textButton[timeConfig='" + timeCustom + "']" ).addClass("active"); @@ -247,7 +247,7 @@ function updateActiveExtraButtons(key: string, value: ConfigValue): void { const wordCustom = ![10, 25, 50, 100, 200].includes(value as number) ? "custom" - : value; + : (value as number); $( "#testConfig .wordCount .textButton[wordCount='" + wordCustom + "']" diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 194599273..3ebd865b5 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -65,7 +65,7 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => { if (eventKey === "fontSize") { $("#caret, #paceCaret, #liveStatsMini, #typingTest, #wordsInput").css( "fontSize", - eventValue + "rem" + (eventValue as number) + "rem" ); if (!nosave) { OutOfFocus.hide(); @@ -1688,7 +1688,8 @@ async function copyToClipboard(content: string): Promise { duration: 2, }); } catch (e) { - Notifications.add("Could not copy to clipboard: " + e, -1); + const msg = Misc.createErrorMessage(e, "Could not copy to clipboard"); + Notifications.add(msg, -1); } } diff --git a/packages/eslint-config/index.js b/packages/eslint-config/index.js index 084c0d28a..2d76f819c 100644 --- a/packages/eslint-config/index.js +++ b/packages/eslint-config/index.js @@ -120,13 +120,6 @@ module.exports = { allowArray: true, }, ], - //162, 31 when allowing numbers and strings, kinda related to restrict-template-expressions - "@typescript-eslint/restrict-plus-operands": [ - "off", - { - allowNumberAndString: true, - }, - ], //using "@typescript-eslint/no-unsafe-member-access": "error", @@ -170,6 +163,12 @@ module.exports = { "@typescript-eslint/use-unknown-in-catch-callback-variable": "error", "@typescript-eslint/await-thenable": "error", "@typescript-eslint/no-unnecessary-type-arguments": "error", + "@typescript-eslint/restrict-plus-operands": [ + "error", + { + allowNumberAndString: true, + }, + ], //handled by oxlint "@typescript-eslint/no-non-null-assertion": "off", @@ -179,7 +178,7 @@ module.exports = { "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/no-empty-function": "off", "no-empty": "off", - "@typescript-eslint/only-throw-error": "off", + "@typescript-eslint/only-throw-error": "error", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-unsafe-function-type": "off", "@typescript-eslint/consistent-type-definitions": "off", diff --git a/packages/funbox/src/list.ts b/packages/funbox/src/list.ts index ef0ba3992..eacce0e4b 100644 --- a/packages/funbox/src/list.ts +++ b/packages/funbox/src/list.ts @@ -480,7 +480,9 @@ export function getFunbox( //@ts-expect-error sanity check if (out.includes(undefined)) { - throw new Error("One of the funboxes is invalid: " + nameOrNames); + throw new Error( + "One of the funboxes is invalid: " + nameOrNames.toString() + ); } return out;