chore(linting): enable restrict-plus-operands

This commit is contained in:
Miodec 2025-08-27 11:26:04 +02:00
parent 10557c9dba
commit b9feaf538b
9 changed files with 27 additions and 18 deletions

View file

@ -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) {

View file

@ -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);
});
},
},

View file

@ -264,7 +264,9 @@ export async function setup(challengeName: string): Promise<boolean> {
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}`);

View file

@ -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) +

View file

@ -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);
});
});

View file

@ -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 + "']"

View file

@ -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<void> {
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);
}
}

View file

@ -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",

View file

@ -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;