Skip to content

Commit 2ee582a

Browse files
committed
chore: configure eslint/curly rule
1 parent b5a03e0 commit 2ee582a

File tree

24 files changed

+98
-48
lines changed

24 files changed

+98
-48
lines changed

backend/__tests__/__testData__/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export async function mockAuthenticateWithApeKey(
1212
uid: string,
1313
config: Configuration,
1414
): Promise<string> {
15-
if (!config.apeKeys.acceptKeys)
15+
if (!config.apeKeys.acceptKeys) {
1616
throw Error("config.apeKeys.acceptedKeys needs to be set to true");
17+
}
1718
const { apeKeyBytes, apeKeySaltRounds } = config.apeKeys;
1819

1920
const apiKey = randomBytes(apeKeyBytes).toString("base64url");

backend/src/api/controllers/dev.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ async function createTestResults(
9696
const results = createArray(day.amount, () =>
9797
createResult(user, day.timestamp),
9898
);
99-
if (results.length > 0)
99+
if (results.length > 0) {
100100
await ResultDal.getResultCollection().insertMany(results);
101+
}
101102
}
102103
}
103104

@@ -222,8 +223,9 @@ async function updateUser(uid: string): Promise<void> {
222223
)) as DBResult;
223224

224225
personalBests[mode.mode] ??= {};
225-
if (personalBests[mode.mode][mode.mode2] === undefined)
226+
if (personalBests[mode.mode][mode.mode2] === undefined) {
226227
personalBests[mode.mode][mode.mode2] = [];
228+
}
227229

228230
const entry = {
229231
acc: best.acc,
@@ -241,8 +243,9 @@ async function updateUser(uid: string): Promise<void> {
241243
(personalBests[mode.mode][mode.mode2] as PersonalBest[]).push(entry);
242244

243245
if (mode.mode === "time") {
244-
if (lbPersonalBests[mode.mode][mode.mode2] === undefined)
246+
if (lbPersonalBests[mode.mode][mode.mode2] === undefined) {
245247
lbPersonalBests[mode.mode][mode.mode2] = {};
248+
}
246249

247250
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
248251
lbPersonalBests[mode.mode][mode.mode2][mode.language] = entry;

backend/src/api/controllers/user.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,9 @@ export function generateCurrentTestActivity(
12071207
let thisYearData = testActivity?.[thisYear.getFullYear().toString()];
12081208
let lastYearData = testActivity?.[lastYear.getFullYear().toString()];
12091209

1210-
if (lastYearData === undefined && thisYearData === undefined)
1210+
if (lastYearData === undefined && thisYearData === undefined) {
12111211
return undefined;
1212+
}
12121213

12131214
lastYearData = lastYearData ?? [];
12141215
thisYearData = thisYearData ?? [];

backend/src/api/controllers/webhooks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export async function githubRelease(
1111

1212
if (action === "published") {
1313
const releaseId = req.body.release?.id;
14-
if (releaseId === undefined)
14+
if (releaseId === undefined) {
1515
throw new MonkeyError(422, 'Missing property "release.id".');
16+
}
1617

1718
await GeorgeQueue.sendReleaseAnnouncement(releaseId);
1819
return new MonkeyResponse("Added release announcement task to queue", null);

backend/src/dal/connections.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export async function getConnections(options: {
2020
}): Promise<DBConnection[]> {
2121
const { initiatorUid, receiverUid, status } = options;
2222

23-
if (initiatorUid === undefined && receiverUid === undefined)
23+
if (initiatorUid === undefined && receiverUid === undefined) {
2424
throw new Error("Missing filter");
25+
}
2526

2627
let filter: Filter<DBConnection> = { $or: [] };
2728

backend/src/dal/user.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,9 @@ export async function checkIfPb(
459459
"stopOnLetter" in result &&
460460
result.stopOnLetter === true &&
461461
result.acc < 100
462-
)
462+
) {
463463
return false;
464+
}
464465

465466
if (mode === "quote") {
466467
return false;
@@ -510,8 +511,9 @@ export async function checkIfTagPb(
510511
"stopOnLetter" in result &&
511512
result.stopOnLetter === true &&
512513
result.acc < 100
513-
)
514+
) {
514515
return [];
516+
}
515517

516518
if (mode === "quote") {
517519
return [];
@@ -605,8 +607,9 @@ export async function linkDiscord(
605607
discordAvatar?: string,
606608
): Promise<void> {
607609
const updates: Partial<DBUser> = { discordId };
608-
if (discordAvatar !== undefined && discordAvatar !== null)
610+
if (discordAvatar !== undefined && discordAvatar !== null) {
609611
updates.discordAvatar = discordAvatar;
612+
}
610613

611614
await updateUser({ uid }, { $set: updates }, { stack: "link discord" });
612615
}
@@ -1055,10 +1058,11 @@ export async function updateInbox(
10551058

10561059
// mongo doesnt support ??= i think
10571060
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1058-
if (inventory === null)
1061+
if (inventory === null) {
10591062
inventory = {
10601063
badges: [],
10611064
};
1065+
}
10621066
// mongo doesnt support ??= i think
10631067
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
10641068
if (inventory.badges === null) inventory.badges = [];
@@ -1104,8 +1108,9 @@ export async function updateInbox(
11041108
{ $unset: "tmp" },
11051109
]);
11061110

1107-
if (update.matchedCount !== 1)
1111+
if (update.matchedCount !== 1) {
11081112
throw new MonkeyError(404, "User not found", "update inbox");
1113+
}
11091114
}
11101115

11111116
export async function updateStreak(
@@ -1229,12 +1234,13 @@ async function updateUser(
12291234
): Promise<void> {
12301235
const result = await getUsersCollection().updateOne(filter, update);
12311236

1232-
if (result.matchedCount !== 1)
1237+
if (result.matchedCount !== 1) {
12331238
throw new MonkeyError(
12341239
error.statusCode ?? 404,
12351240
error.message ?? "User not found",
12361241
error.stack,
12371242
);
1243+
}
12381244
}
12391245

12401246
export async function getFriends(uid: string): Promise<DBFriend[]> {

backend/src/middlewares/configuration.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,30 @@ function getValue(
6262
result = result[key];
6363
}
6464

65-
if (result === undefined || result === null)
65+
if (result === undefined || result === null) {
6666
throw new MonkeyError(
6767
500,
6868
`Required configuration doesnt exist: "${path}"`,
6969
);
70-
if (typeof result !== "boolean")
70+
}
71+
if (typeof result !== "boolean") {
7172
throw new MonkeyError(
7273
500,
7374
`Required configuration is not a boolean: "${path}"`,
7475
);
76+
}
7577
return result;
7678
}
7779

7880
function getRequireConfigurations(
7981
metadata: EndpointMetadata | undefined,
8082
): RequireConfiguration[] | undefined {
81-
if (metadata === undefined || metadata.requireConfiguration === undefined)
83+
if (metadata === undefined || metadata.requireConfiguration === undefined) {
8284
return undefined;
85+
}
8386

84-
if (Array.isArray(metadata.requireConfiguration))
87+
if (Array.isArray(metadata.requireConfiguration)) {
8588
return metadata.requireConfiguration;
89+
}
8690
return [metadata.requireConfiguration];
8791
}

backend/src/middlewares/permission.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ export function verifyPermissions<
136136
function getRequiredPermissionIds(
137137
metadata: EndpointMetadata | undefined,
138138
): PermissionId[] | undefined {
139-
if (metadata === undefined || metadata.requirePermission === undefined)
139+
if (metadata === undefined || metadata.requirePermission === undefined) {
140140
return undefined;
141+
}
141142

142-
if (Array.isArray(metadata.requirePermission))
143+
if (Array.isArray(metadata.requirePermission)) {
143144
return metadata.requirePermission;
145+
}
144146
return [metadata.requirePermission];
145147
}
146148

@@ -186,11 +188,12 @@ async function checkUserPermissions(
186188
)) as DBUser;
187189

188190
for (const check of checks) {
189-
if (!check.criteria(user))
191+
if (!check.criteria(user)) {
190192
return {
191193
passed: false,
192194
invalidMessage: check.invalidMessage,
193195
};
196+
}
194197
}
195198

196199
return {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,9 @@ async function updateColors<
13601360
ao10accDataset === undefined ||
13611361
ao100wpmDataset === undefined ||
13621362
ao100accDataset === undefined
1363-
)
1363+
) {
13641364
return;
1365+
}
13651366

13661367
if (avg10On && avg100On) {
13671368
wpmDataset.pointBackgroundColor = main02;

frontend/src/ts/elements/keymap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,9 @@ async function updateLegends(): Promise<void> {
563563
layoutKey === undefined ||
564564
lowerCaseCharacter === undefined ||
565565
upperCaseCharacter === undefined
566-
)
566+
) {
567567
continue;
568+
}
568569

569570
const keyIsSymbol = [lowerCaseCharacter, upperCaseCharacter].some(
570571
(character) => symbolsPattern.test(character ?? ""),

0 commit comments

Comments
 (0)