Skip to content

Commit b570bd1

Browse files
committed
chore: enable prefer template
1 parent 18b7505 commit b570bd1

119 files changed

Lines changed: 393 additions & 423 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/__tests__/__integration__/dal/blocklist.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("BlocklistDal", () => {
2626
const now = 1715082588;
2727
vi.setSystemTime(now);
2828

29-
const name = "user" + new ObjectId().toHexString();
29+
const name = `user${new ObjectId().toHexString()}`;
3030
const email = `${name}@example.com`;
3131

3232
//WHEN
@@ -56,7 +56,7 @@ describe("BlocklistDal", () => {
5656
const now = 1715082588;
5757
vi.setSystemTime(now);
5858

59-
const name = "user" + new ObjectId().toHexString();
59+
const name = `user${new ObjectId().toHexString()}`;
6060
const email = `${name}@example.com`;
6161
const discordId = `${name}DiscordId`;
6262

@@ -78,7 +78,7 @@ describe("BlocklistDal", () => {
7878
const now = 1715082588;
7979
vi.setSystemTime(now);
8080

81-
const name = "user" + new ObjectId().toHexString();
81+
const name = `user${new ObjectId().toHexString()}`;
8282
const email = `${name}@example.com`;
8383
const email2 = `${name}@otherdomain.com`;
8484
await BlacklistDal.add({ name, email });
@@ -114,9 +114,9 @@ describe("BlocklistDal", () => {
114114
const now = 1715082588;
115115
vi.setSystemTime(now);
116116

117-
const name = "user" + new ObjectId().toHexString();
117+
const name = `user${new ObjectId().toHexString()}`;
118118
const email = `${name}@example.com`;
119-
const name2 = "user" + new ObjectId().toHexString();
119+
const name2 = `user${new ObjectId().toHexString()}`;
120120
await BlacklistDal.add({ name, email });
121121

122122
//WHEN
@@ -136,8 +136,8 @@ describe("BlocklistDal", () => {
136136
const now = 1715082588;
137137
vi.setSystemTime(now);
138138

139-
const name = "user" + new ObjectId().toHexString();
140-
const name2 = "user" + new ObjectId().toHexString();
139+
const name = `user${new ObjectId().toHexString()}`;
140+
const name2 = `user${new ObjectId().toHexString()}`;
141141
const email = `${name}@example.com`;
142142
const discordId = `${name}DiscordId`;
143143

@@ -160,7 +160,7 @@ describe("BlocklistDal", () => {
160160
describe("contains", () => {
161161
it("contains user", async () => {
162162
//GIVEN
163-
const name = "user" + new ObjectId().toHexString();
163+
const name = `user${new ObjectId().toHexString()}`;
164164
const email = `${name}@example.com`;
165165
const discordId = `${name}DiscordId`;
166166
await BlacklistDal.add({ name, email, discordId });
@@ -229,7 +229,7 @@ describe("BlocklistDal", () => {
229229
describe("remove", () => {
230230
it("removes existing username", async () => {
231231
//GIVEN
232-
const name = "user" + new ObjectId().toHexString();
232+
const name = `user${new ObjectId().toHexString()}`;
233233
const email = `${name}@example.com`;
234234
await BlacklistDal.add({ name, email });
235235
await BlacklistDal.add({ name: "test", email: "test@example.com" });
@@ -251,7 +251,7 @@ describe("BlocklistDal", () => {
251251
});
252252
it("removes existing email", async () => {
253253
//GIVEN
254-
const name = "user" + new ObjectId().toHexString();
254+
const name = `user${new ObjectId().toHexString()}`;
255255
const email = `${name}@example.com`;
256256
await BlacklistDal.add({ name, email });
257257
await BlacklistDal.add({ name: "test", email: "test@example.com" });
@@ -273,7 +273,7 @@ describe("BlocklistDal", () => {
273273
});
274274
it("removes existing discordId", async () => {
275275
//GIVEN
276-
const name = "user" + new ObjectId().toHexString();
276+
const name = `user${new ObjectId().toHexString()}`;
277277
const email = `${name}@example.com`;
278278
const discordId = `${name}DiscordId`;
279279
await BlacklistDal.add({ name, email, discordId });
@@ -304,7 +304,7 @@ describe("BlocklistDal", () => {
304304
});
305305
it("removes existing username,email and discordId", async () => {
306306
//GIVEN
307-
const name = "user" + new ObjectId().toHexString();
307+
const name = `user${new ObjectId().toHexString()}`;
308308
const email = `${name}@example.com`;
309309
const discordId = `${name}DiscordId`;
310310
await BlacklistDal.add({ name, email, discordId });
@@ -336,7 +336,7 @@ describe("BlocklistDal", () => {
336336

337337
it("does not remove for empty user", async () => {
338338
//GIVEN
339-
const name = "user" + new ObjectId().toHexString();
339+
const name = `user${new ObjectId().toHexString()}`;
340340
const email = `${name}@example.com`;
341341
const discordId = `${name}DiscordId`;
342342
await BlacklistDal.add({ name, email, discordId });

backend/__tests__/__integration__/dal/leaderboards.isolated.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ async function createUser(
496496
userProperties?: Partial<UserDal.DBUser>,
497497
): Promise<UserDal.DBUser> {
498498
const uid = new ObjectId().toHexString();
499-
await UserDal.addUser("User " + uid, uid + "@example.com", uid);
499+
await UserDal.addUser(`User ${uid}`, `${uid}@example.com`, uid);
500500

501501
await DB.getDb()
502502
?.collection<UserDal.DBUser>("users")
@@ -505,8 +505,8 @@ async function createUser(
505505
{
506506
$set: {
507507
timeTyping: 7200,
508-
discordId: "discord " + uid,
509-
discordAvatar: "avatar " + uid,
508+
discordId: `discord ${uid}`,
509+
discordAvatar: `avatar ${uid}`,
510510
...userProperties,
511511
lbPersonalBests,
512512
},

backend/__tests__/__integration__/dal/user.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ describe("UserDal", () => {
128128

129129
it("isNameAvailable should correctly check if a username is available", async () => {
130130
// given
131-
const name1 = "user" + new ObjectId().toHexString();
132-
const name2 = "user" + new ObjectId().toHexString();
131+
const name1 = `user${new ObjectId().toHexString()}`;
132+
const name2 = `user${new ObjectId().toHexString()}`;
133133
const { uid: user1 } = await UserTestData.createUser({ name: name1 });
134134
await UserTestData.createUser({ name: name2 });
135135

@@ -160,8 +160,8 @@ describe("UserDal", () => {
160160

161161
it("updatename should not allow unavailable usernames", async () => {
162162
// given
163-
const name1 = "user" + new ObjectId().toHexString();
164-
const name2 = "user" + new ObjectId().toHexString();
163+
const name1 = `user${new ObjectId().toHexString()}`;
164+
const name2 = `user${new ObjectId().toHexString()}`;
165165
const user1 = await UserTestData.createUser({ name: name1 });
166166
const user2 = await UserTestData.createUser({ name: name2 });
167167
const _decoy = await UserTestData.createUser();
@@ -173,8 +173,8 @@ describe("UserDal", () => {
173173
});
174174

175175
it("same usernames (different casing) should be available only for the same user", async () => {
176-
const name1 = "user" + new ObjectId().toHexString();
177-
const name2 = "user" + new ObjectId().toHexString();
176+
const name1 = `user${new ObjectId().toHexString()}`;
177+
const name2 = `user${new ObjectId().toHexString()}`;
178178
const user1 = await UserTestData.createUser({ name: name1 });
179179
const user2 = await UserTestData.createUser({ name: name2 });
180180

@@ -192,8 +192,8 @@ describe("UserDal", () => {
192192

193193
it("UserDAL.updateName should change the name of a user", async () => {
194194
// given
195-
const name = "user" + new ObjectId().toHexString();
196-
const renamed = "renamed" + new ObjectId().toHexString();
195+
const name = `user${new ObjectId().toHexString()}`;
196+
const renamed = `renamed${new ObjectId().toHexString()}`;
197197
const testUser = await UserTestData.createUser({ name: name });
198198

199199
// when
@@ -1696,7 +1696,7 @@ describe("UserDal", () => {
16961696

16971697
it("increments bananas", async () => {
16981698
//GIVEN
1699-
const name = "user" + new ObjectId().toHexString();
1699+
const name = `user${new ObjectId().toHexString()}`;
17001700
const { uid } = await UserTestData.createUser({
17011701
name,
17021702
bananas: 1,

backend/__tests__/__testData__/connections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export async function createConnection(
55
data: Partial<ConnectionsDal.DBConnection>,
66
maxPerUser = 25,
77
): Promise<ConnectionsDal.DBConnection> {
8-
const defaultName = "user" + new ObjectId().toHexString();
8+
const defaultName = `user${new ObjectId().toHexString()}`;
99
const result = await ConnectionsDal.create(
1010
{
1111
uid: data.initiatorUid ?? new ObjectId().toHexString(),

backend/__tests__/__testData__/users.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export async function createUser(
77
user?: Partial<UserDAL.DBUser>,
88
): Promise<UserDAL.DBUser> {
99
const uid = new ObjectId().toHexString();
10-
await UserDAL.addUser("user" + uid, uid + "@example.com", uid);
10+
await UserDAL.addUser(`user${uid}`, `${uid}@example.com`, uid);
1111
await DB.collection("users").updateOne({ uid }, { $set: { ...user } });
1212
return await UserDAL.getUser(uid, "test");
1313
}
@@ -16,7 +16,7 @@ export async function createUserWithoutMigration(
1616
user?: Partial<UserDAL.DBUser>,
1717
): Promise<UserDAL.DBUser> {
1818
const uid = new ObjectId().toHexString();
19-
await UserDAL.addUser("user" + uid, uid + "@example.com", uid);
19+
await UserDAL.addUser(`user${uid}`, `${uid}@example.com`, uid);
2020
await DB.collection("users").updateOne({ uid }, { $set: { ...user } });
2121
await DB.collection("users").updateOne(
2222
{ uid },

backend/__tests__/api/controllers/leaderboard.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ describe("Loaderboard Controller", () => {
395395
await mockApp
396396
.get("/leaderboards/rank")
397397
.query({ language: "english", mode: "time", mode2: "60" })
398-
.set("authorization", "ApeKey " + apeKey)
398+
.set("authorization", `ApeKey ${apeKey}`)
399399
.expect(200);
400400
});
401401
it("should get for mode", async () => {
@@ -405,7 +405,7 @@ describe("Loaderboard Controller", () => {
405405
.get("/leaderboards/rank")
406406
.set("Authorization", `Bearer ${uid}`)
407407
.query({ language: "english", mode, mode2: "custom" });
408-
expect(response.status, "for mode " + mode).toEqual(200);
408+
expect(response.status, `for mode ${mode}`).toEqual(200);
409409
}
410410
});
411411

@@ -417,7 +417,7 @@ describe("Loaderboard Controller", () => {
417417
.set("Authorization", `Bearer ${uid}`)
418418
.query({ language: "english", mode: "words", mode2 });
419419

420-
expect(response.status, "for mode2 " + mode2).toEqual(200);
420+
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
421421
}
422422
});
423423
it("fails for missing query", async () => {
@@ -750,7 +750,7 @@ describe("Loaderboard Controller", () => {
750750
const response = await mockApp
751751
.get("/leaderboards/daily")
752752
.query({ language: "english", mode, mode2: "custom" });
753-
expect(response.status, "for mode " + mode).toEqual(200);
753+
expect(response.status, `for mode ${mode}`).toEqual(200);
754754
}
755755
});
756756

@@ -760,7 +760,7 @@ describe("Loaderboard Controller", () => {
760760
.get("/leaderboards/daily")
761761
.query({ language: "english", mode: "words", mode2 });
762762

763-
expect(response.status, "for mode2 " + mode2).toEqual(200);
763+
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
764764
}
765765
});
766766

@@ -963,7 +963,7 @@ describe("Loaderboard Controller", () => {
963963
.get("/leaderboards/daily/rank")
964964
.set("Authorization", `Bearer ${uid}`)
965965
.query({ language: "english", mode, mode2: "custom" });
966-
expect(response.status, "for mode " + mode).toEqual(200);
966+
expect(response.status, `for mode ${mode}`).toEqual(200);
967967
}
968968
});
969969

@@ -974,7 +974,7 @@ describe("Loaderboard Controller", () => {
974974
.set("Authorization", `Bearer ${uid}`)
975975
.query({ language: "english", mode: "words", mode2 });
976976

977-
expect(response.status, "for mode2 " + mode2).toEqual(200);
977+
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
978978
}
979979
});
980980

backend/__tests__/api/controllers/public.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("PublicController", () => {
4040
const response = await mockApp
4141
.get("/public/speedHistogram")
4242
.query({ language: "english", mode, mode2: "custom" });
43-
expect(response.status, "for mode " + mode).toEqual(200);
43+
expect(response.status, `for mode ${mode}`).toEqual(200);
4444
}
4545
});
4646

@@ -61,7 +61,7 @@ describe("PublicController", () => {
6161
.get("/public/speedHistogram")
6262
.query({ language: "english", mode: "words", mode2 });
6363

64-
expect(response.status, "for mode2 " + mode2).toEqual(200);
64+
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
6565
}
6666
});
6767
it("fails for missing query", async () => {

backend/__tests__/api/controllers/user.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,9 +3349,9 @@ describe("user controller test", () => {
33493349
socialProfiles: {
33503350
twitter: new Array(21).fill("x").join(""),
33513351
github: new Array(40).fill("x").join(""),
3352-
website:
3353-
"https://" +
3354-
new Array(201 - "https://".length).fill("x").join(""),
3352+
website: `https://${new Array(201 - "https://".length)
3353+
.fill("x")
3354+
.join("")}`,
33553355
},
33563356
})
33573357
.expect(422);

backend/private/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function download(filename, text) {
294294
let element = document.createElement("a");
295295
element.setAttribute(
296296
"href",
297-
"data:text/plain;charset=utf-8," + encodeURIComponent(text),
297+
`data:text/plain;charset=utf-8,${encodeURIComponent(text)}`,
298298
);
299299
element.setAttribute("download", filename);
300300

backend/scripts/openapi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function getRateLimitDescription(limit: RateLimiterId | RateLimitIds): string {
259259
)} with ApeKeys`;
260260
}
261261

262-
return result + ".\n\n";
262+
return `${result}.\n\n`;
263263
}
264264

265265
function formatWindow(window: Window): string {
@@ -273,7 +273,7 @@ function formatWindow(window: Window): string {
273273

274274
return `every ${duration}`;
275275
}
276-
return "per " + window;
276+
return `per ${window}`;
277277
}
278278

279279
function addRequiredConfiguration(

0 commit comments

Comments
 (0)