Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade deps + eslint v9 #1408

Merged
merged 4 commits into from
Oct 29, 2024
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
36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jobs:
run: pnpm run e2e:setup

- name: Run Playwright tests
uses: docker://mcr.microsoft.com/playwright:v1.47.2-jammy
uses: docker://mcr.microsoft.com/playwright:v1.48.2-jammy
with:
# Fix for Firefox, HOME=/root is required to avoid permission issues
# https://github.com/microsoft/playwright/issues/6500
Expand Down
2 changes: 1 addition & 1 deletion .slugignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/resources
/tests
.env.example
.eslintrc.json
eslint.config.js
.prettierignore
.prettierrc
CONTRIBUTING.md
Expand Down
3 changes: 0 additions & 3 deletions apps/backend/db/migrations/20170304184220_add_constraints.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable quotes */

/**
* @param {import('knex').Knex} knex
*/
Expand Down Expand Up @@ -44,7 +42,6 @@ export const down = async (knex) => {
.raw(`DROP TYPE job_status`)
.raw(`DROP TYPE service_type`)
.table("repositories", (table) => {
// @ts-ignore
table.dropForeign("organizationId");
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable quotes, max-len */

/**
* @param {import('knex').Knex} knex
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable quotes */

/**
* @param {import('knex').Knex} knex
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable quotes */

/**
* @param {import('knex').Knex} knex
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export const up = async (knex) => {
*/
export const down = async (knex) => {
await knex.schema.alterTable("accounts", function (table) {
// @ts-ignore
table.dropUnique("userId");
// @ts-ignore
table.dropUnique("organizationId");
table.dropUnique(["userId"]);
table.dropUnique(["organizationId"]);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ export const up = async (knex) => {
]);
};

/**
* @param {import('knex').Knex} knex
*/
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
export const down = async (knex) => {};
export const down = async () => {};
50 changes: 25 additions & 25 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"setup": "pnpm run db:create && pnpm run db:load",
"check-types": "tsc --noEmit",
"check-format": "prettier --check --cache --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
"lint": "eslint --ignore-path=../../.gitignore .",
"lint": "eslint .",
"db:check-structure": "knex-scripts check-structure",
"db:create": "knex-scripts create",
"db:drop": "knex-scripts drop",
Expand All @@ -30,22 +30,22 @@
"@apollo/server": "^4.11.0",
"@argos/tsconfig": "workspace:*",
"@argos/util": "workspace:*",
"@aws-sdk/client-s3": "^3.637.0",
"@aws-sdk/s3-request-presigner": "^3.637.0",
"@gitbeaker/rest": "^40.1.3",
"@graphql-tools/schema": "^10.0.6",
"@aws-sdk/client-s3": "^3.679.0",
"@aws-sdk/s3-request-presigner": "^3.679.0",
"@gitbeaker/rest": "^41.1.0",
"@graphql-tools/schema": "^10.0.7",
"@octokit/auth-app": "^7.1.0",
"@octokit/core": "^6.1.2",
"@octokit/openapi-types": "^22.2.0",
"@octokit/plugin-retry": "^7.1.1",
"@octokit/rest": "^21.0.2",
"@octokit/webhooks": "^13.3.0",
"@octokit/webhooks-types": "^7.5.1",
"@octokit/webhooks-types": "^7.6.1",
"@react-email/components": "^0.0.25",
"@react-email/render": "^1.0.1",
"@sentry/node": "^8.27.0",
"@sentry/node": "^8.35.0",
"@sindresorhus/slugify": "^2.2.1",
"@slack/bolt": "^3.21.1",
"@slack/bolt": "^4.0.1",
"ajv": "^8.17.1",
"amqplib": "^0.10.4",
"auth-header": "^1.0.0",
Expand All @@ -55,38 +55,38 @@
"cookies": "^0.9.1",
"cors": "^2.8.5",
"dataloader": "^2.2.2",
"discord.js": "^14.16.0",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-rate-limit": "^7.4.0",
"google-auth-library": "^9.14.0",
"discord.js": "^14.16.3",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"express-rate-limit": "^7.4.1",
"google-auth-library": "^9.14.2",
"graphql": "^16.9.0",
"graphql-scalars": "^1.23.0",
"graphql-tag": "^2.12.6",
"helmet": "^7.1.0",
"helmet": "^8.0.0",
"jsonwebtoken": "^9.0.2",
"knex": "^3.1.0",
"lodash-es": "^4.17.21",
"minimatch": "^10.0.1",
"mime": "^4.0.4",
"minimatch": "^10.0.1",
"moment": "^2.30.1",
"morgan": "^1.10.0",
"objection": "^3.1.4",
"odiff-bin": "^3.1.1",
"odiff-bin": "^3.1.2",
"p-retry": "^6.2.0",
"p-timeout":"^6.1.2",
"path-to-regexp": "^8.0.0",
"pg": "^8.12.0",
"p-timeout": "^6.1.3",
"path-to-regexp": "^8.2.0",
"pg": "^8.13.1",
"rate-limit-redis": "^4.2.0",
"react": "^18.3.1",
"redis": "^4.7.0",
"resend": "^4.0.0",
"sharp": "^0.33.5",
"stripe": "^16.9.0",
"stripe": "^17.2.1",
"tmp": "^0.2.3",
"yaml": "^2.5.0",
"yaml": "^2.6.0",
"zod": "^3.23.8",
"zod-openapi": "^2.19.0"
"zod-openapi": "^3.2.0"
},
"devDependencies": {
"@types/amqplib": "^0.10.5",
Expand All @@ -95,14 +95,14 @@
"@types/convict": "^6.1.6",
"@types/cookies": "^0.9.0",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/express": "^4.0.0",
"@types/jsonwebtoken": "^9.0.6",
"@types/lodash-es": "^4.17.12",
"@types/morgan": "^1.9.9",
"@types/react": "^18.3.5",
"@types/react": "^18.3.12",
"@types/supertest": "^6.0.2",
"@types/tmp": "^0.2.6",
"concurrently": "^8.2.2",
"concurrently": "^9.0.1",
"factory-girl-ts": "^2.3.1",
"knex-scripts": "^0.3.6",
"moment": "^2.30.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { updateBuild } from "./handlers/updateBuild.js";
import { schema } from "./schema.js";
import { errorHandler, registerHandler } from "./util.js";

const router = Router();
const router: Router = Router();

// CORS
router.use(
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/api/test-util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Router } from "express";
import { Express, Router } from "express";

import { createTestApp } from "@/web/test-util.js";

Expand All @@ -7,7 +7,7 @@ import { CreateAPIHandler, registerHandler } from "./util";
/**
* Create a test app with the given handler.
*/
export function createTestHandlerApp(create: CreateAPIHandler) {
export function createTestHandlerApp(create: CreateAPIHandler): Express {
const router = Router();
registerHandler(router, create);
return createTestApp(router);
Expand Down
50 changes: 23 additions & 27 deletions apps/backend/src/api/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import type {
Response,
Router,
} from "express";
import express from "express";
import { json } from "express";
import { z, ZodError, ZodType } from "zod";
import {
ZodOpenApiOperationObject,
ZodOpenApiPathItemObject,
} from "zod-openapi";

import { asyncHandler } from "@/web/util.js";
import { asyncHandler, boom } from "@/web/util.js";

import { zodSchema } from "./schema.js";

Expand Down Expand Up @@ -90,23 +90,31 @@ function convertPath(path: string) {
return path.replace(/{([^}]+)}/g, ":$1");
}

const DetailsSchema = z.array(z.object({ message: z.string() }));

export const errorHandler: ErrorRequestHandler = (
error: unknown,
_req,
res,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_next,
) => {
if (
const details =
error instanceof Error && "details" in error
? DetailsSchema.safeParse(error.details).data
: undefined;

const statusCode =
error instanceof Error &&
"statusCode" in error &&
typeof error.statusCode === "number"
) {
res.status(error.statusCode).json({ error: error.message });
return;
}
? error.statusCode
: 500;

res.status(500).json({ error: "Internal server error" });
const message =
error instanceof Error ? error.message : "Internal server error";

res.status(statusCode).json({ error: message, details });
};

type HandlerParams<T> = (T | T[])[];
Expand Down Expand Up @@ -148,8 +156,8 @@ function handler<TMethod extends "get" | "post" | "put">(
convertPath(path),
// Temporary increase the limit
// we should find a way to split the upload in several requests
express.json({ limit: "3mb" }),
asyncHandler((req, res, next) => {
json({ limit: "3mb" }),
asyncHandler((req, _res, next) => {
const ctx: RequestCtx<ZodOpenApiOperationObject> = {
params: null,
query: null,
Expand Down Expand Up @@ -180,30 +188,18 @@ function handler<TMethod extends "get" | "post" | "put">(
const errorMessages = error.errors.map((issue: any) => ({
message: `${issue.path.join(".")} is ${issue.message}`,
}));
res
.status(400)
.json({ error: "Invalid request", details: errorMessages });
return;
throw boom(400, "Invalid request", {
cause: error,
details: errorMessages,
});
}
throw error;
}

next();
}),
...wrappedHandlers,
Sentry.expressErrorHandler({
// shouldHandleError: (error: unknown) => {
// if (
// error instanceof Error &&
// "statusCode" in error &&
// typeof error.statusCode === "number" &&
// error.statusCode < 500
// ) {
// return false;
// }
// return true;
// },
}),
Sentry.expressErrorHandler(),
errorHandler,
);
};
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/build/createBuildDiffs.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe("#createBuildDiffs", () => {
await build
.$query()
.patchAndFetch({ baseScreenshotBucketId: baseBucket.id });
// @ts-ignore
[
classicDiffBaseScreenshot,
classicDiffCompareScreenshot,
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/build/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function getBuildLabel(
case "check": {
return getBuildStatusLabel(status);
}
// eslint-disable-next-line no-fallthrough
case null:
case undefined:
return getBuildStatusLabel(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export const GithubStrategy: MergeBaseStrategy<{
if (checkErrorStatus(404, error)) {
const notFoundError = new Error(
`"${args.sha}" not found on repository "${args.ctx.repo}"`,
);
// @ts-ignore
) as Error & { retryable: boolean };
notFoundError.retryable = false;
throw notFoundError;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const config = convict({
apiKey: {
doc: "Stripe API key",
format: String,
default: "",
default: "no-api-key",
env: "STRIPE_API_KEY",
},
pricingTableId: {
Expand Down
5 changes: 2 additions & 3 deletions apps/backend/src/database/models/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ export class Build extends Model {
}
}

override $toDatabaseJson(...args: any[]) {
// @ts-ignore
const json = super.$toDatabaseJson(...args);
override $formatDatabaseJson(json: Pojo): Pojo {
json = super.$formatDatabaseJson(json);
if (json["number"] === -1) {
json["number"] = this.$knex().raw(
'(select coalesce(max(number),0) + 1 as number from builds where "projectId" = ?)',
Expand Down
Loading