From c87ff82aad10ab88a224bac4a390563f6f302e69 Mon Sep 17 00:00:00 2001 From: Carl Vitullo Date: Thu, 26 Dec 2024 19:14:06 -0500 Subject: [PATCH] Revert "Upgrade to react-router@7, eslint@9, version bump the rest (#101)" This reverts commit 89f7ae21cd2a01d5e35007006659ae35ac00606b. --- .eslintignore | 4 + .eslintrc.js | 22 + .gitignore | 3 +- .husky/pre-push | 2 + .lintstagedrc.js | 2 +- Dockerfile | 3 +- app/commands/convene.tsx | 11 +- app/commands/reacord/ModResponse.tsx | 4 +- app/commands/setupTickets.ts | 4 +- app/components/login.tsx | 4 +- app/components/logout.tsx | 14 +- app/db.d.ts | 7 +- app/db.server.ts | 2 +- app/discord/activityTracker.ts | 9 +- app/discord/api.ts | 2 +- app/discord/client.server.ts | 2 +- app/discord/deployCommands.server.ts | 16 +- app/entry.client.tsx | 6 +- app/entry.server.tsx | 22 + app/helpers/discordCommands.ts | 21 +- app/helpers/{env.server.ts => env.ts} | 0 app/helpers/modResponse.ts | 4 +- app/index.ts | 70 +- app/models/activity.server.ts | 4 +- app/models/discord.server.ts | 33 +- app/models/session.server.ts | 82 +- app/root.tsx | 47 +- app/routes.ts | 15 - app/routes/__auth.tsx | 11 +- app/routes/__auth/dashboard.tsx | 21 +- app/routes/__auth/login.tsx | 4 +- app/routes/__auth/test.tsx | 4 +- app/routes/auth.tsx | 6 +- app/routes/discord-oauth.tsx | 2 +- app/routes/healthcheck.tsx | 2 +- app/routes/logout.tsx | 8 +- app/server.ts | 11 - app/styles/tailwind.css | 398 +- app/utils.ts | 8 +- cypress.json | 1 + cypress/.eslintrc.js | 6 + cypress/e2e/smoke.ts | 43 + cypress/fixtures/example.json | 5 + cypress/plugins/index.ts | 25 + cypress/support/commands.ts | 77 + cypress/support/create-user.ts | 47 + cypress/support/delete-user.ts | 22 + cypress/support/index.ts | 2 + cypress/tsconfig.json | 31 + eslint.config.js | 56 - kysely.config.ts | 8 +- mocks/README.md | 7 + mocks/index.js | 3 + mocks/start.ts | 9 + package-lock.json | 44243 +++++++++++++++++------- package.json | 104 +- postcss.config.mjs | 5 - react-router.config.ts | 4 - remix.config.js | 8 + remix.env.d.ts | 1 + tailwind.config.js | 2 +- test/setup-test-env.ts | 3 + tsconfig.json | 20 +- vite.config.ts | 11 - 64 files changed, 33526 insertions(+), 12107 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 app/entry.server.tsx rename app/helpers/{env.server.ts => env.ts} (100%) delete mode 100644 app/routes.ts delete mode 100644 app/server.ts create mode 100644 cypress.json create mode 100644 cypress/.eslintrc.js create mode 100644 cypress/e2e/smoke.ts create mode 100644 cypress/fixtures/example.json create mode 100644 cypress/plugins/index.ts create mode 100644 cypress/support/commands.ts create mode 100644 cypress/support/create-user.ts create mode 100644 cypress/support/delete-user.ts create mode 100644 cypress/support/index.ts create mode 100644 cypress/tsconfig.json delete mode 100644 eslint.config.js create mode 100644 mocks/README.md create mode 100644 mocks/index.js create mode 100644 mocks/start.ts delete mode 100644 postcss.config.mjs delete mode 100644 react-router.config.ts create mode 100644 remix.config.js create mode 100644 remix.env.d.ts delete mode 100644 vite.config.ts diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..6eb8b7f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +build +# Hack fix to override default behavior for ignore files linted by name +# https://github.com/eslint/eslint/issues/15010 +!.* diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..7b0c443 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,22 @@ +/** + * @type {import('@types/eslint').Linter.BaseConfig} + */ +module.exports = { + extends: [ + "@remix-run/eslint-config", + "@remix-run/eslint-config/node", + "@remix-run/eslint-config/jest-testing-library", + "prettier", + ], + // we're using vitest which has a very similar API to jest + // (so the linting plugins work nicely), but it we have to explicitly + // set the jest version. + settings: { + jest: { + version: 27, + }, + }, + rules: { + "react/style-prop-object": 0, + }, +}; diff --git a/.gitignore b/.gitignore index d5d5c9c..1a66c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ yarn.lock *.log k8s-context *.sqlite3 +/cypress/screenshots +/cypress/videos tsconfig.tsbuildinfo -.react-router diff --git a/.husky/pre-push b/.husky/pre-push index ac246e5..f0bc84e 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,2 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" npm run validate diff --git a/.lintstagedrc.js b/.lintstagedrc.js index aca557a..a78214d 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -1,4 +1,4 @@ -export default { +module.exports = { "**/*.[tj]s?(x)": ["eslint --fix --max-warnings=0", "prettier --check"], "migrations/*.[tj]s": [ "npm run start:migrate", diff --git a/Dockerfile b/Dockerfile index 02c31a4..a521841 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /app COPY package.json package-lock.json ./ RUN npm install -COPY vite.config.ts tailwind.config.js kysely.config.ts tsconfig.json .eslint* .prettierignore ./ +COPY remix.config.js tailwind.config.js kysely.config.ts tsconfig.json .eslint* .prettierignore ./ COPY app ./app RUN npm run build @@ -20,6 +20,7 @@ ADD package.json package-lock.json ./ RUN npm prune --production COPY --from=build /app/build ./build +COPY --from=build /app/public ./public COPY kysely.config.ts ./ COPY migrations ./migrations diff --git a/app/commands/convene.tsx b/app/commands/convene.tsx index b035a29..1ab45e2 100644 --- a/app/commands/convene.tsx +++ b/app/commands/convene.tsx @@ -82,7 +82,7 @@ export const handler = async ( staff, extra: "✅ Restricted", }), - applyRestriction(message.member), + applyRestriction(message.member!), message.reply( "After a vote by the mods, this member has had restrictions applied to them", ), @@ -96,7 +96,7 @@ export const handler = async ( staff, extra: "✅ Kicked", }), - kick(message.member), + kick(message.member!), message.reply( "After a vote by the mods, this member has been kicked from the server to cool off", ), @@ -110,13 +110,13 @@ export const handler = async ( staff, extra: "✅ Banned", }), - ban(message.member), + ban(message.member!), message.reply( "After a vote by the mods, this member has been permanently banned", ), ]); return; - case resolutions.nudge: { + case resolutions.nudge: const [thread] = await Promise.all([ originalChannel.threads.create({ name: message.author.username, @@ -145,7 +145,6 @@ This isn't a formal warning, but your message concerned the moderators enough th ${quoteAndEscape(message.content)}`); return; - } case resolutions.warning: reportUser({ reason: ReportReasons.mod, @@ -173,7 +172,7 @@ This isn't a formal warning, but your message concerned the moderators enough th staff, extra: "✅ Timed out overnight", }); - timeout(message.member); + timeout(message.member!); return; } diff --git a/app/commands/reacord/ModResponse.tsx b/app/commands/reacord/ModResponse.tsx index ab484a0..e68fc7b 100644 --- a/app/commands/reacord/ModResponse.tsx +++ b/app/commands/reacord/ModResponse.tsx @@ -1,4 +1,4 @@ -import type { ComponentEventUser } from "reacord"; +import type { UserInfo } from "reacord"; import { Button } from "reacord"; import type { Resolution } from "~/helpers/modResponse"; @@ -17,7 +17,7 @@ export const ModResponse = ({ modRoleId, }: { votesRequired?: number; - onVote: (result: { vote: Resolution; user: ComponentEventUser }) => void; + onVote: (result: { vote: Resolution; user: UserInfo }) => void; onResolve: (result: Resolution) => Promise; modRoleId: string; }) => { diff --git a/app/commands/setupTickets.ts b/app/commands/setupTickets.ts index 9b2fe9e..a7b885e 100644 --- a/app/commands/setupTickets.ts +++ b/app/commands/setupTickets.ts @@ -15,7 +15,7 @@ import { import { REST } from "@discordjs/rest"; import { Routes, TextInputStyle } from "discord-api-types/v10"; -import { discordToken } from "~/helpers/env.server"; +import { discordToken } from "~/helpers/env"; import { SETTINGS, fetchSettings } from "~/models/guilds.server"; import { format } from "date-fns"; import type { @@ -114,7 +114,7 @@ export default [ await thread.send({ content: "When you’ve finished, please close the ticket.", components: [ - // @ts-expect-error Types for this are super busted + // @ts-ignore new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId(`close-ticket||${user.id}`) diff --git a/app/components/login.tsx b/app/components/login.tsx index b9acffd..8008232 100644 --- a/app/components/login.tsx +++ b/app/components/login.tsx @@ -1,4 +1,4 @@ -import { Form } from "react-router"; +import { Form } from "@remix-run/react"; import type { ButtonHTMLAttributes } from "react"; interface LoginProps extends ButtonHTMLAttributes { @@ -8,7 +8,7 @@ interface LoginProps extends ButtonHTMLAttributes { export function Login({ children = "Log in with Discord", - // errors, + errors, redirectTo, ...props }: LoginProps) { diff --git a/app/components/logout.tsx b/app/components/logout.tsx index a29e919..bad0755 100644 --- a/app/components/logout.tsx +++ b/app/components/logout.tsx @@ -1,9 +1,17 @@ -import { Form } from "react-router"; +import { Form } from "@remix-run/react"; import type { ButtonHTMLAttributes } from "react"; -type LoginProps = ButtonHTMLAttributes; +interface LoginProps extends ButtonHTMLAttributes { + errors?: { [k: string]: string }; + redirectTo?: string; +} -export function Logout({ children = "Log out", ...props }: LoginProps) { +export function Logout({ + children = "Log out", + errors, + redirectTo, + ...props +}: LoginProps) { return (