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
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/monkey-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
run: pnpm install

- name: Check lint
run: npm run lint-be
run: npm run lint-fast-be && npm run lint-be

- name: Build
run: npm run build-be
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
run: pnpm install

- name: Check lint
run: npm run lint-fe
run: npm run lint-fast-fe && npm run lint-fe

- name: Build
run: npm run build-fe
Expand Down Expand Up @@ -327,7 +327,7 @@ jobs:
run: pnpm install

- name: Check lint
run: npm run lint-pkg
run: npm run lint-fast-pkg && npm run lint-pkg

- name: Build
run: npm run build-pkg
Expand Down
7 changes: 7 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ignorePatterns": ["node_modules", "dist", ".turbo"],
"extends": [
"./packages/oxlint-config/index.jsonc"
// "@monkeytype/oxlint-config"
]
}
16 changes: 0 additions & 16 deletions backend/.eslintrc.cjs

This file was deleted.

4 changes: 4 additions & 0 deletions backend/.oxlintrc-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ignorePatterns": ["node_modules", "__migration__", "dist", ".turbo"],
"extends": ["../packages/oxlint-config/plugin.jsonc"]
}
28 changes: 1 addition & 27 deletions backend/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
{
"ignorePatterns": ["node_modules", "__migration__", "dist", ".turbo"],
"extends": [
"../packages/oxlint-config/index.jsonc"
// "@monkeytype/oxlint-config"
],
"overrides": [
{
"files": ["__tests__/**"],
"plugins": [
"typescript",
"unicorn",
"oxc",
"import",
"node",
"promise",
"jest",
"vitest"
],
"rules": {
"no-explicit-any": "allow",
"explicit-function-return-type": "off",
"ban-ts-comment": "off"
}
},
{
"files": ["__tests__/**/*.d.ts"],
"rules": {
"typescript/consistent-type-definitions": "off",
"typescript/no-empty-object-type": "off"
}
}
]
}
5 changes: 3 additions & 2 deletions backend/__tests__/api/controllers/admin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GeorgeQueue from "../../../src/queues/george-queue";
import * as AuthUtil from "../../../src/utils/auth";

import { enableRateLimitExpects } from "../../__testData__/rate-limit";
import Test from "supertest/lib/test";

const { mockApp, uid } = setup();
const configuration = Configuration.getCachedConfiguration();
Expand Down Expand Up @@ -558,12 +559,12 @@ describe("AdminController", () => {
});
});

async function expectFailForNonAdmin(call: SuperTest): Promise<void> {
async function expectFailForNonAdmin(call: Test): Promise<void> {
isAdminMock.mockResolvedValue(false);
const { body } = await call.expect(403);
expect(body.message).toEqual("You don't have permission to do this.");
}
async function expectFailForDisabledEndpoint(call: SuperTest): Promise<void> {
async function expectFailForDisabledEndpoint(call: Test): Promise<void> {
await enableAdminEndpoints(false);
const { body } = await call.expect(503);
expect(body.message).toEqual("Admin endpoints are currently disabled.");
Expand Down
15 changes: 7 additions & 8 deletions backend/__tests__/api/controllers/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ import { mockAuthenticateWithApeKey } from "../../__testData__/auth";
import { randomUUID } from "node:crypto";
import { MonkeyMail, UserStreak } from "@monkeytype/schemas/users";
import MonkeyError, { isFirebaseError } from "../../../src/utils/error";
import { LeaderboardEntry } from "@monkeytype/schemas/leaderboards";
import * as WeeklyXpLeaderboard from "../../../src/services/weekly-xp-leaderboard";
import * as ConnectionsDal from "../../../src/dal/connections";
import { pb } from "../../__testData__/users";
import { SuperTest } from "supertest";
import Test from "supertest/lib/test";

const { mockApp, uid, mockAuth } = setup();
const configuration = Configuration.getCachedConfiguration();
Expand Down Expand Up @@ -2979,7 +2978,7 @@ describe("user controller test", () => {

getUserByNameMock.mockResolvedValue(foundUser as any);

const rank = { rank: 24 } as LeaderboardEntry;
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
leaderboardGetRankMock.mockResolvedValue(rank);
leaderboardGetCountMock.mockResolvedValue(100);

Expand Down Expand Up @@ -3041,7 +3040,7 @@ describe("user controller test", () => {
...foundUser,
profileDetails: { showActivityOnPublicProfile: true },
} as any);
const rank = { rank: 24 } as LeaderboardEntry;
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
leaderboardGetRankMock.mockResolvedValue(rank);
leaderboardGetCountMock.mockResolvedValue(100);

Expand All @@ -3063,7 +3062,7 @@ describe("user controller test", () => {
...foundUser,
profileDetails: { showActivityOnPublicProfile: false },
} as any);
const rank = { rank: 24 } as LeaderboardEntry;
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
leaderboardGetRankMock.mockResolvedValue(rank);
leaderboardGetCountMock.mockResolvedValue(100);

Expand All @@ -3081,7 +3080,7 @@ describe("user controller test", () => {
banned: true,
} as any);

const rank = { rank: 24 } as LeaderboardEntry;
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
leaderboardGetRankMock.mockResolvedValue(rank);
leaderboardGetCountMock.mockResolvedValue(100);

Expand Down Expand Up @@ -3132,7 +3131,7 @@ describe("user controller test", () => {
const uid = foundUser.uid;
getUserMock.mockResolvedValue(foundUser as any);

const rank = { rank: 24 } as LeaderboardEntry;
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
leaderboardGetRankMock.mockResolvedValue(rank);
leaderboardGetCountMock.mockResolvedValue(100);

Expand Down Expand Up @@ -4050,7 +4049,7 @@ async function enableConnectionsEndpoints(enabled: boolean): Promise<void> {
);
}

async function expectFailForDisabledEndpoint(call: SuperTest): Promise<void> {
async function expectFailForDisabledEndpoint(call: Test): Promise<void> {
await enableConnectionsEndpoints(false);
const { body } = await call.expect(503);
expect(body.message).toEqual("Connections are not available at this time.");
Expand Down
6 changes: 5 additions & 1 deletion backend/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": "@monkeytype/typescript-config/base.json",
"compilerOptions": {
"noEmit": true
"noEmit": true,
"noImplicitAny": false,
"strictFunctionTypes": false,
"useUnknownInCatchVariables": false,
"strictPropertyInitialization": false
},
"files": ["vitest.d.ts"],
"include": ["./**/*.ts", "./**/*.spec.ts", "./setup-tests.ts"]
Expand Down
11 changes: 4 additions & 7 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"private": true,
"license": "GPL-3.0",
"scripts": {
"eslint": "eslint \"./src/**/*.ts\"",
"oxlint": "oxlint .",
"lint": "npm run oxlint && npm run eslint",
"lint": "oxlint . --type-aware --type-check && oxlint -c .oxlintrc-plugin.json",
"lint-fast": "oxlint .",
"build": "npm run gen-docs && tsc --build",
"watch": "tsc --build --watch",
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -59,7 +58,6 @@
"zod": "3.23.8"
},
"devDependencies": {
"@monkeytype/eslint-config": "workspace:*",
"@monkeytype/oxlint-config": "workspace:*",
"@monkeytype/typescript-config": "workspace:*",
"@redocly/cli": "2.0.5",
Expand All @@ -81,10 +79,9 @@
"@types/uuid": "10.0.0",
"@vitest/coverage-v8": "4.0.8",
"concurrently": "8.2.2",
"eslint": "8.57.1",
"eslint-watch": "8.0.0",
"openapi3-ts": "2.0.2",
"oxlint": "1.29.0",
"oxlint": "1.33.0",
"oxlint-tsgolint": "0.9.0",
"readline-sync": "1.4.10",
"supertest": "7.1.4",
"testcontainers": "11.4.0",
Expand Down
10 changes: 4 additions & 6 deletions backend/private/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const buildNumberInput = (schema, parentState, key) => {
input.type = "number";
input.value = parentState[key];

const min = schema.min || 0;
const min = schema.min ?? 0;
input.min = min;

input.addEventListener("change", () => {
Expand All @@ -44,7 +44,7 @@ const buildBooleanInput = (parentState, key) => {
const input = document.createElement("input");
input.classList.add("base-input");
input.type = "checkbox";
input.checked = parentState[key] || false;
input.checked = parentState[key] ?? false;

input.addEventListener("change", () => {
parentState[key] = input.checked;
Expand All @@ -57,7 +57,7 @@ const buildStringInput = (parentState, key) => {
const input = document.createElement("input");
input.classList.add("base-input");
input.type = "text";
input.value = parentState[key] || "";
input.value = parentState[key] ?? "";

input.addEventListener("change", () => {
parentState[key] = input.value;
Expand Down Expand Up @@ -157,9 +157,7 @@ const render = (state, schema) => {
if (type === "object") {
const entries = Object.entries(fields);
entries.forEach(([key, value]) => {
if (!state[key]) {
state[key] = defaultValueForType(value.type);
}
state[key] ??= defaultValueForType(value.type);

const childElement = build(
value,
Expand Down
14 changes: 9 additions & 5 deletions backend/scripts/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ function addAuth(
function getRequiredPermissions(
metadata: EndpointMetadata | undefined,
): PermissionId[] | undefined {
if (metadata === undefined || metadata.requirePermission === undefined)
if (metadata === undefined || metadata.requirePermission === undefined) {
return undefined;
}

if (Array.isArray(metadata.requirePermission))
if (Array.isArray(metadata.requirePermission)) {
return metadata.requirePermission;
}
return [metadata.requirePermission];
}

Expand All @@ -219,14 +221,15 @@ function addRateLimit(
metadata: EndpointMetadata | undefined,
): void {
if (metadata === undefined || metadata.rateLimit === undefined) return;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// oxlint-disable-next-line no-unsafe-assignment
const okResponse = operation.responses["200"];
if (okResponse === undefined) return;

operation.description += getRateLimitDescription(metadata.rateLimit);

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// oxlint-disable-next-line no-unsafe-assignment no-unsafe-member-access
okResponse["headers"] = {
// oxlint-disable-next-line no-unsafe-member-access
...okResponse["headers"],
"x-ratelimit-limit": {
schema: { type: "integer" },
Expand Down Expand Up @@ -277,8 +280,9 @@ function addRequiredConfiguration(
operation: OperationObject,
metadata: EndpointMetadata | undefined,
): void {
if (metadata === undefined || metadata.requireConfiguration === undefined)
if (metadata === undefined || metadata.requireConfiguration === undefined) {
return;
}

//@ts-expect-error somehow path doesnt exist
operation.description += `**Required configuration:** This operation can only be called if the [configuration](#tag/configuration/operation/configuration.get) for \`${metadata.requireConfiguration.path}\` is \`true\`.\n\n`;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async function updateUser(uid: string): Promise<void> {
lbPersonalBests[mode.mode][mode.mode2] = {};
}

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

Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export async function getUser(req: MonkeyRequest): Promise<GetUserResponse> {
uid,
);
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// oxlint-disable-next-line no-unsafe-member-access
if (e.code === "auth/user-not-found") {
throw new MonkeyError(
404,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/ts-rest-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function callController<
TParams,
TResponse,
//ignoring as it might be used in the future
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
// oxlint-disable-next-line no-unnecessary-type-parameters
TStatus = 200,
>(
handler: MonkeyHandler<TQuery, TBody, TParams, TResponse>,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TsRestRequest as TsRestRequestGeneric } from "@ts-rest/express";
import { Request as ExpressRequest } from "express";
import { Context } from "../middlewares/context";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// oxlint-disable-next-line no-explicit-any
export type TsRestRequest = TsRestRequestGeneric<any>;

export type ExpressRequestWithContext = {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/dal/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function create(

return created;
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// oxlint-disable-next-line no-unsafe-member-access
if (e.name === "MongoServerError" && e.code === 11000) {
const existing = await getCollection().findOne(
{ key },
Expand Down
6 changes: 3 additions & 3 deletions backend/src/dal/leaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function get(

return leaderboard;
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// oxlint-disable-next-line no-unsafe-member-access
if (e.error === 175) {
//QueryPlanKilled, collection was removed during the query
return false;
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function getRank(
return results[0] ?? null;
}
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// oxlint-disable-next-line no-unsafe-member-access
if (e.error === 175) {
//QueryPlanKilled, collection was removed during the query
return false;
Expand Down Expand Up @@ -393,7 +393,7 @@ async function createIndex(
Logger.warning(`Index ${key} not matching, dropping and recreating...`);

const existingIndex = (await getUsersCollection().listIndexes().toArray())
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// oxlint-disable-next-line no-unsafe-member-access
.map((it) => it.name as string)
.find((it) => it.startsWith(key));

Expand Down
Loading
Loading