Skip to content

Commit b9feaf5

Browse files
committed
chore(linting): enable restrict-plus-operands
1 parent 10557c9 commit b9feaf5

File tree

9 files changed

+27
-18
lines changed

9 files changed

+27
-18
lines changed

frontend/scripts/fontawesome.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function getFontawesomeConfig(debug = false): FontawesomeConfig {
9999
(it) => !(solid.includes(it) || regular.includes(it) || brands.includes(it))
100100
);
101101
if (leftOvers.length !== 0) {
102-
throw new Error("unknown icons: " + leftOvers);
102+
throw new Error("unknown icons: " + leftOvers.toString());
103103
}
104104

105105
if (debug) {

frontend/src/ts/commandline/lists.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ export const commands: CommandsSubgroup = {
297297
Notifications.add("Copied to clipboard", 1);
298298
})
299299
.catch((e: unknown) => {
300-
Notifications.add("Failed to copy to clipboard: " + e, -1);
300+
const message = Misc.createErrorMessage(
301+
e,
302+
"Failed to copy to clipboard"
303+
);
304+
Notifications.add(message, -1);
301305
});
302306
},
303307
},

frontend/src/ts/controllers/challenge-controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ export async function setup(challengeName: string): Promise<boolean> {
264264
UpdateConfig.setDifficulty("normal", true);
265265
} else if (challenge.type === "script") {
266266
Loader.show();
267-
const response = await fetch("/challenges/" + challenge.parameters[0]);
267+
const response = await fetch(
268+
"/challenges/" + (challenge.parameters[0] as string)
269+
);
268270
Loader.hide();
269271
if (response.status !== 200) {
270272
throw new Error(`${response.status} ${response.statusText}`);

frontend/src/ts/controllers/input-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ async function handleChar(
637637
if (charIndex >= currCorrectedTestInputLength) {
638638
TestInput.corrected.current += !isCharKorean
639639
? char
640-
: Hangul.disassemble(char).concat();
640+
: Hangul.disassemble(char).concat().join("");
641641
} else if (!thisCharCorrect) {
642642
TestInput.corrected.current =
643643
TestInput.corrected.current.substring(0, charIndex) +

frontend/src/ts/pages/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,8 @@ $(".pageSettings .section .groupTitle button").on("click", (e) => {
11991199
Notifications.add("Link copied to clipboard", 1);
12001200
})
12011201
.catch((e: unknown) => {
1202-
Notifications.add("Failed to copy to clipboard: " + e, -1);
1202+
const msg = Misc.createErrorMessage(e, "Failed to copy to clipboard");
1203+
Notifications.add(msg, -1);
12031204
});
12041205
});
12051206

frontend/src/ts/test/test-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function updateActiveExtraButtons(key: string, value: ConfigValue): void {
238238
$("#testConfig .time .textButton").removeClass("active");
239239
const timeCustom = ![15, 30, 60, 120].includes(value as number)
240240
? "custom"
241-
: value;
241+
: (value as number);
242242
$(
243243
"#testConfig .time .textButton[timeConfig='" + timeCustom + "']"
244244
).addClass("active");
@@ -247,7 +247,7 @@ function updateActiveExtraButtons(key: string, value: ConfigValue): void {
247247

248248
const wordCustom = ![10, 25, 50, 100, 200].includes(value as number)
249249
? "custom"
250-
: value;
250+
: (value as number);
251251

252252
$(
253253
"#testConfig .wordCount .textButton[wordCount='" + wordCustom + "']"

frontend/src/ts/test/test-ui.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => {
6565
if (eventKey === "fontSize") {
6666
$("#caret, #paceCaret, #liveStatsMini, #typingTest, #wordsInput").css(
6767
"fontSize",
68-
eventValue + "rem"
68+
(eventValue as number) + "rem"
6969
);
7070
if (!nosave) {
7171
OutOfFocus.hide();
@@ -1688,7 +1688,8 @@ async function copyToClipboard(content: string): Promise<void> {
16881688
duration: 2,
16891689
});
16901690
} catch (e) {
1691-
Notifications.add("Could not copy to clipboard: " + e, -1);
1691+
const msg = Misc.createErrorMessage(e, "Could not copy to clipboard");
1692+
Notifications.add(msg, -1);
16921693
}
16931694
}
16941695

packages/eslint-config/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ module.exports = {
120120
allowArray: true,
121121
},
122122
],
123-
//162, 31 when allowing numbers and strings, kinda related to restrict-template-expressions
124-
"@typescript-eslint/restrict-plus-operands": [
125-
"off",
126-
{
127-
allowNumberAndString: true,
128-
},
129-
],
130123

131124
//using
132125
"@typescript-eslint/no-unsafe-member-access": "error",
@@ -170,6 +163,12 @@ module.exports = {
170163
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
171164
"@typescript-eslint/await-thenable": "error",
172165
"@typescript-eslint/no-unnecessary-type-arguments": "error",
166+
"@typescript-eslint/restrict-plus-operands": [
167+
"error",
168+
{
169+
allowNumberAndString: true,
170+
},
171+
],
173172

174173
//handled by oxlint
175174
"@typescript-eslint/no-non-null-assertion": "off",
@@ -179,7 +178,7 @@ module.exports = {
179178
"@typescript-eslint/no-unused-expressions": "off",
180179
"@typescript-eslint/no-empty-function": "off",
181180
"no-empty": "off",
182-
"@typescript-eslint/only-throw-error": "off",
181+
"@typescript-eslint/only-throw-error": "error",
183182
"@typescript-eslint/ban-ts-comment": "off",
184183
"@typescript-eslint/no-unsafe-function-type": "off",
185184
"@typescript-eslint/consistent-type-definitions": "off",

packages/funbox/src/list.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ export function getFunbox(
480480

481481
//@ts-expect-error sanity check
482482
if (out.includes(undefined)) {
483-
throw new Error("One of the funboxes is invalid: " + nameOrNames);
483+
throw new Error(
484+
"One of the funboxes is invalid: " + nameOrNames.toString()
485+
);
484486
}
485487

486488
return out;

0 commit comments

Comments
 (0)