Skip to content

Commit a067a32

Browse files
authored
chore: move main linting to oxlint (@Miodec) (monkeytypegame#7144)
- main linting is now done by oxlint. eslint remains for linting json files in the frontend (until oxlint adds support) - move type checking to the lint step (with --type-check) this improves performance by removing a duplicated typescript parse task (instead of parsing for linting then again for type checking, it parses once for both) - add a `lint-fast` npm script to get some fast fail behavior. it simply lints with no type information - oxc plugins are still in preview, so the custom plugin that checks for `__testing` usage outside of tests runs outside the main linting job until performance is improved - fixes some type issues (and config issues) that were not visible due to a missing type check on some files. now type checking will run on every file that is linted - split up oxc config for easier management waiting oxc-project/tsgolint#494 seeing around 3x improvement in type aware linting
1 parent 660668c commit a067a32

File tree

107 files changed

+972
-2035
lines changed

Some content is hidden

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

107 files changed

+972
-2035
lines changed

.eslintignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/monkey-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
run: pnpm install
161161

162162
- name: Check lint
163-
run: npm run lint-be
163+
run: npm run lint-fast-be && npm run lint-be
164164

165165
- name: Build
166166
run: npm run build-be
@@ -212,7 +212,7 @@ jobs:
212212
run: pnpm install
213213

214214
- name: Check lint
215-
run: npm run lint-fe
215+
run: npm run lint-fast-fe && npm run lint-fe
216216

217217
- name: Build
218218
run: npm run build-fe
@@ -327,7 +327,7 @@ jobs:
327327
run: pnpm install
328328

329329
- name: Check lint
330-
run: npm run lint-pkg
330+
run: npm run lint-fast-pkg && npm run lint-pkg
331331

332332
- name: Build
333333
run: npm run build-pkg

.oxlintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignorePatterns": ["node_modules", "dist", ".turbo"],
3+
"extends": [
4+
"./packages/oxlint-config/index.jsonc"
5+
// "@monkeytype/oxlint-config"
6+
]
7+
}

backend/.eslintrc.cjs

Lines changed: 0 additions & 16 deletions
This file was deleted.

backend/.oxlintrc-plugin.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ignorePatterns": ["node_modules", "__migration__", "dist", ".turbo"],
3+
"extends": ["../packages/oxlint-config/plugin.jsonc"]
4+
}

backend/.oxlintrc.json

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
{
2+
"ignorePatterns": ["node_modules", "__migration__", "dist", ".turbo"],
23
"extends": [
34
"../packages/oxlint-config/index.jsonc"
45
// "@monkeytype/oxlint-config"
5-
],
6-
"overrides": [
7-
{
8-
"files": ["__tests__/**"],
9-
"plugins": [
10-
"typescript",
11-
"unicorn",
12-
"oxc",
13-
"import",
14-
"node",
15-
"promise",
16-
"jest",
17-
"vitest"
18-
],
19-
"rules": {
20-
"no-explicit-any": "allow",
21-
"explicit-function-return-type": "off",
22-
"ban-ts-comment": "off"
23-
}
24-
},
25-
{
26-
"files": ["__tests__/**/*.d.ts"],
27-
"rules": {
28-
"typescript/consistent-type-definitions": "off",
29-
"typescript/no-empty-object-type": "off"
30-
}
31-
}
326
]
337
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import GeorgeQueue from "../../../src/queues/george-queue";
1010
import * as AuthUtil from "../../../src/utils/auth";
1111

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

1415
const { mockApp, uid } = setup();
1516
const configuration = Configuration.getCachedConfiguration();
@@ -558,12 +559,12 @@ describe("AdminController", () => {
558559
});
559560
});
560561

561-
async function expectFailForNonAdmin(call: SuperTest): Promise<void> {
562+
async function expectFailForNonAdmin(call: Test): Promise<void> {
562563
isAdminMock.mockResolvedValue(false);
563564
const { body } = await call.expect(403);
564565
expect(body.message).toEqual("You don't have permission to do this.");
565566
}
566-
async function expectFailForDisabledEndpoint(call: SuperTest): Promise<void> {
567+
async function expectFailForDisabledEndpoint(call: Test): Promise<void> {
567568
await enableAdminEndpoints(false);
568569
const { body } = await call.expect(503);
569570
expect(body.message).toEqual("Admin endpoints are currently disabled.");

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ import { mockAuthenticateWithApeKey } from "../../__testData__/auth";
3333
import { randomUUID } from "node:crypto";
3434
import { MonkeyMail, UserStreak } from "@monkeytype/schemas/users";
3535
import MonkeyError, { isFirebaseError } from "../../../src/utils/error";
36-
import { LeaderboardEntry } from "@monkeytype/schemas/leaderboards";
3736
import * as WeeklyXpLeaderboard from "../../../src/services/weekly-xp-leaderboard";
3837
import * as ConnectionsDal from "../../../src/dal/connections";
3938
import { pb } from "../../__testData__/users";
40-
import { SuperTest } from "supertest";
39+
import Test from "supertest/lib/test";
4140

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

29802979
getUserByNameMock.mockResolvedValue(foundUser as any);
29812980

2982-
const rank = { rank: 24 } as LeaderboardEntry;
2981+
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
29832982
leaderboardGetRankMock.mockResolvedValue(rank);
29842983
leaderboardGetCountMock.mockResolvedValue(100);
29852984

@@ -3041,7 +3040,7 @@ describe("user controller test", () => {
30413040
...foundUser,
30423041
profileDetails: { showActivityOnPublicProfile: true },
30433042
} as any);
3044-
const rank = { rank: 24 } as LeaderboardEntry;
3043+
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
30453044
leaderboardGetRankMock.mockResolvedValue(rank);
30463045
leaderboardGetCountMock.mockResolvedValue(100);
30473046

@@ -3063,7 +3062,7 @@ describe("user controller test", () => {
30633062
...foundUser,
30643063
profileDetails: { showActivityOnPublicProfile: false },
30653064
} as any);
3066-
const rank = { rank: 24 } as LeaderboardEntry;
3065+
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
30673066
leaderboardGetRankMock.mockResolvedValue(rank);
30683067
leaderboardGetCountMock.mockResolvedValue(100);
30693068

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

3084-
const rank = { rank: 24 } as LeaderboardEntry;
3083+
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
30853084
leaderboardGetRankMock.mockResolvedValue(rank);
30863085
leaderboardGetCountMock.mockResolvedValue(100);
30873086

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

3135-
const rank = { rank: 24 } as LeaderboardEntry;
3134+
const rank = { rank: 24 } as LeaderboardDal.DBLeaderboardEntry;
31363135
leaderboardGetRankMock.mockResolvedValue(rank);
31373136
leaderboardGetCountMock.mockResolvedValue(100);
31383137

@@ -4050,7 +4049,7 @@ async function enableConnectionsEndpoints(enabled: boolean): Promise<void> {
40504049
);
40514050
}
40524051

4053-
async function expectFailForDisabledEndpoint(call: SuperTest): Promise<void> {
4052+
async function expectFailForDisabledEndpoint(call: Test): Promise<void> {
40544053
await enableConnectionsEndpoints(false);
40554054
const { body } = await call.expect(503);
40564055
expect(body.message).toEqual("Connections are not available at this time.");

backend/__tests__/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"extends": "@monkeytype/typescript-config/base.json",
33
"compilerOptions": {
4-
"noEmit": true
4+
"noEmit": true,
5+
"noImplicitAny": false,
6+
"strictFunctionTypes": false,
7+
"useUnknownInCatchVariables": false,
8+
"strictPropertyInitialization": false
59
},
610
"files": ["vitest.d.ts"],
711
"include": ["./**/*.ts", "./**/*.spec.ts", "./setup-tests.ts"]

backend/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"private": true,
55
"license": "GPL-3.0",
66
"scripts": {
7-
"eslint": "eslint \"./src/**/*.ts\"",
8-
"oxlint": "oxlint .",
9-
"lint": "npm run oxlint && npm run eslint",
7+
"lint": "oxlint . --type-aware --type-check && oxlint -c .oxlintrc-plugin.json",
8+
"lint-fast": "oxlint .",
109
"build": "npm run gen-docs && tsc --build",
1110
"watch": "tsc --build --watch",
1211
"clean": "tsc --build --clean",
@@ -59,7 +58,6 @@
5958
"zod": "3.23.8"
6059
},
6160
"devDependencies": {
62-
"@monkeytype/eslint-config": "workspace:*",
6361
"@monkeytype/oxlint-config": "workspace:*",
6462
"@monkeytype/typescript-config": "workspace:*",
6563
"@redocly/cli": "2.0.5",
@@ -81,10 +79,9 @@
8179
"@types/uuid": "10.0.0",
8280
"@vitest/coverage-v8": "4.0.8",
8381
"concurrently": "8.2.2",
84-
"eslint": "8.57.1",
85-
"eslint-watch": "8.0.0",
8682
"openapi3-ts": "2.0.2",
87-
"oxlint": "1.29.0",
83+
"oxlint": "1.33.0",
84+
"oxlint-tsgolint": "0.9.0",
8885
"readline-sync": "1.4.10",
8986
"supertest": "7.1.4",
9087
"testcontainers": "11.4.0",

0 commit comments

Comments
 (0)