Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Be extremely concise. Sacrifice grammar for concision.
Frontend is partially migrated from vanilla JS to SolidJS — new components use `.tsx`, legacy code remains vanilla.
Single test file: `pnpm vitest run path/to/test.ts`
When running oxc lint, always use `--format agent`.
For typechecking, use `oxc --type-aware --type-check` instead of `tsc`.
For styling, use Tailwind CSS, class property, `cn` utility. Do not use classlist. Only colors available are those defined in Tailwind config.
In legacy code, use `i` tags with FontAwesome classes. In new code, use `Fa` component.
In plan mode, before writing up a plan, ask clarifying questions if needed. At the end of plan mode, give me a list of unresolved questions to answer, if any. Make them concise.
26 changes: 13 additions & 13 deletions backend/__tests__/__integration__/dal/blocklist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("BlocklistDal", () => {
const now = 1715082588;
vi.setSystemTime(now);

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

//WHEN
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("BlocklistDal", () => {
const now = 1715082588;
vi.setSystemTime(now);

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

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

const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
const email2 = `${name}@otherdomain.com`;
await BlacklistDal.add({ name, email });
Expand Down Expand Up @@ -114,9 +114,9 @@ describe("BlocklistDal", () => {
const now = 1715082588;
vi.setSystemTime(now);

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

//WHEN
Expand All @@ -136,8 +136,8 @@ describe("BlocklistDal", () => {
const now = 1715082588;
vi.setSystemTime(now);

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

Expand All @@ -160,7 +160,7 @@ describe("BlocklistDal", () => {
describe("contains", () => {
it("contains user", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
const discordId = `${name}DiscordId`;
await BlacklistDal.add({ name, email, discordId });
Expand Down Expand Up @@ -229,7 +229,7 @@ describe("BlocklistDal", () => {
describe("remove", () => {
it("removes existing username", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
await BlacklistDal.add({ name, email });
await BlacklistDal.add({ name: "test", email: "test@example.com" });
Expand All @@ -251,7 +251,7 @@ describe("BlocklistDal", () => {
});
it("removes existing email", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
await BlacklistDal.add({ name, email });
await BlacklistDal.add({ name: "test", email: "test@example.com" });
Expand All @@ -273,7 +273,7 @@ describe("BlocklistDal", () => {
});
it("removes existing discordId", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
const discordId = `${name}DiscordId`;
await BlacklistDal.add({ name, email, discordId });
Expand Down Expand Up @@ -304,7 +304,7 @@ describe("BlocklistDal", () => {
});
it("removes existing username,email and discordId", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
const discordId = `${name}DiscordId`;
await BlacklistDal.add({ name, email, discordId });
Expand Down Expand Up @@ -336,7 +336,7 @@ describe("BlocklistDal", () => {

it("does not remove for empty user", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const email = `${name}@example.com`;
const discordId = `${name}DiscordId`;
await BlacklistDal.add({ name, email, discordId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ async function createUser(
userProperties?: Partial<UserDal.DBUser>,
): Promise<UserDal.DBUser> {
const uid = new ObjectId().toHexString();
await UserDal.addUser("User " + uid, uid + "@example.com", uid);
await UserDal.addUser(`User ${uid}`, `${uid}@example.com`, uid);

await DB.getDb()
?.collection<UserDal.DBUser>("users")
Expand All @@ -505,8 +505,8 @@ async function createUser(
{
$set: {
timeTyping: 7200,
discordId: "discord " + uid,
discordAvatar: "avatar " + uid,
discordId: `discord ${uid}`,
discordAvatar: `avatar ${uid}`,
...userProperties,
lbPersonalBests,
},
Expand Down
18 changes: 9 additions & 9 deletions backend/__tests__/__integration__/dal/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe("UserDal", () => {

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

Expand Down Expand Up @@ -160,8 +160,8 @@ describe("UserDal", () => {

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

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

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

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

// when
Expand Down Expand Up @@ -1696,7 +1696,7 @@ describe("UserDal", () => {

it("increments bananas", async () => {
//GIVEN
const name = "user" + new ObjectId().toHexString();
const name = `user${new ObjectId().toHexString()}`;
const { uid } = await UserTestData.createUser({
name,
bananas: 1,
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/__testData__/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function createConnection(
data: Partial<ConnectionsDal.DBConnection>,
maxPerUser = 25,
): Promise<ConnectionsDal.DBConnection> {
const defaultName = "user" + new ObjectId().toHexString();
const defaultName = `user${new ObjectId().toHexString()}`;
const result = await ConnectionsDal.create(
{
uid: data.initiatorUid ?? new ObjectId().toHexString(),
Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/__testData__/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function createUser(
user?: Partial<UserDAL.DBUser>,
): Promise<UserDAL.DBUser> {
const uid = new ObjectId().toHexString();
await UserDAL.addUser("user" + uid, uid + "@example.com", uid);
await UserDAL.addUser(`user${uid}`, `${uid}@example.com`, uid);
await DB.collection("users").updateOne({ uid }, { $set: { ...user } });
return await UserDAL.getUser(uid, "test");
}
Expand All @@ -16,7 +16,7 @@ export async function createUserWithoutMigration(
user?: Partial<UserDAL.DBUser>,
): Promise<UserDAL.DBUser> {
const uid = new ObjectId().toHexString();
await UserDAL.addUser("user" + uid, uid + "@example.com", uid);
await UserDAL.addUser(`user${uid}`, `${uid}@example.com`, uid);
await DB.collection("users").updateOne({ uid }, { $set: { ...user } });
await DB.collection("users").updateOne(
{ uid },
Expand Down
14 changes: 7 additions & 7 deletions backend/__tests__/api/controllers/leaderboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ describe("Loaderboard Controller", () => {
await mockApp
.get("/leaderboards/rank")
.query({ language: "english", mode: "time", mode2: "60" })
.set("authorization", "ApeKey " + apeKey)
.set("authorization", `ApeKey ${apeKey}`)
.expect(200);
});
it("should get for mode", async () => {
Expand All @@ -405,7 +405,7 @@ describe("Loaderboard Controller", () => {
.get("/leaderboards/rank")
.set("Authorization", `Bearer ${uid}`)
.query({ language: "english", mode, mode2: "custom" });
expect(response.status, "for mode " + mode).toEqual(200);
expect(response.status, `for mode ${mode}`).toEqual(200);
}
});

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

expect(response.status, "for mode2 " + mode2).toEqual(200);
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
}
});
it("fails for missing query", async () => {
Expand Down Expand Up @@ -750,7 +750,7 @@ describe("Loaderboard Controller", () => {
const response = await mockApp
.get("/leaderboards/daily")
.query({ language: "english", mode, mode2: "custom" });
expect(response.status, "for mode " + mode).toEqual(200);
expect(response.status, `for mode ${mode}`).toEqual(200);
}
});

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

expect(response.status, "for mode2 " + mode2).toEqual(200);
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
}
});

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

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

expect(response.status, "for mode2 " + mode2).toEqual(200);
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
}
});

Expand Down
4 changes: 2 additions & 2 deletions backend/__tests__/api/controllers/public.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("PublicController", () => {
const response = await mockApp
.get("/public/speedHistogram")
.query({ language: "english", mode, mode2: "custom" });
expect(response.status, "for mode " + mode).toEqual(200);
expect(response.status, `for mode ${mode}`).toEqual(200);
}
});

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

expect(response.status, "for mode2 " + mode2).toEqual(200);
expect(response.status, `for mode2 ${mode2}`).toEqual(200);
}
});
it("fails for missing query", async () => {
Expand Down
6 changes: 3 additions & 3 deletions backend/__tests__/api/controllers/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3349,9 +3349,9 @@ describe("user controller test", () => {
socialProfiles: {
twitter: new Array(21).fill("x").join(""),
github: new Array(40).fill("x").join(""),
website:
"https://" +
new Array(201 - "https://".length).fill("x").join(""),
website: `https://${new Array(201 - "https://".length)
.fill("x")
.join("")}`,
},
})
.expect(422);
Expand Down
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
"@vitest/coverage-v8": "4.1.5",
"concurrently": "8.2.2",
"openapi3-ts": "2.0.2",
"oxlint": "1.60.0",
"oxlint-tsgolint": "0.21.0",
"oxlint": "1.64.0",
"oxlint-tsgolint": "0.22.1",
"readline-sync": "1.4.10",
"supertest": "7.1.4",
"testcontainers": "11.11.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/private/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function download(filename, text) {
let element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(text),
`data:text/plain;charset=utf-8,${encodeURIComponent(text)}`,
);
element.setAttribute("download", filename);

Expand Down
4 changes: 2 additions & 2 deletions backend/scripts/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function getRateLimitDescription(limit: RateLimiterId | RateLimitIds): string {
)} with ApeKeys`;
}

return result + ".\n\n";
return `${result}.\n\n`;
}

function formatWindow(window: Window): string {
Expand All @@ -273,7 +273,7 @@ function formatWindow(window: Window): string {

return `every ${duration}`;
}
return "per " + window;
return `per ${window}`;
}

function addRequiredConfiguration(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export async function handleReports(
} else {
throw new MonkeyError(
500,
"Error handling reports: " + getErrorMessage(e),
`Error handling reports: ${getErrorMessage(e)}`,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/api/controllers/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ async function getOrCreateUser(
throw new MonkeyError(404, `User ${username} does not exist.`);
}

const email = username + "@example.com";
Logger.success("create user " + username);
const email = `${username}@example.com`;
Logger.success(`create user ${username}`);
const { uid } = await FirebaseAdmin().auth().createUser({
displayName: username,
password: password,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function isSubmissionEnabled(
): Promise<IsSubmissionEnabledResponse> {
const { submissionsEnabled } = req.ctx.configuration.quotes;
return new MonkeyResponse(
"Quote submission " + (submissionsEnabled ? "enabled" : "disabled"),
`Quote submission ${submissionsEnabled ? "enabled" : "disabled"}`,
{ isEnabled: submissionsEnabled },
);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ export async function addResult(
if (isPb) {
void addLog(
"user_new_pb",
`${completedEvent.mode + " " + completedEvent.mode2} ${
`${`${completedEvent.mode} ${completedEvent.mode2}`} ${
completedEvent.wpm
} ${completedEvent.acc}% ${completedEvent.rawWpm} ${
completedEvent.consistency
Expand Down
Loading
Loading