From 18aaef98540f4aba38a3441b528a777aaa2ba621 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Wed, 12 Jan 2022 23:04:02 +0200 Subject: [PATCH] Fix lint --- .../$organization.$tournament/bracket.$id.tsx | 20 +++++++++---------- app/services/bracket.ts | 10 ++++++---- app/utils/hooks.ts | 1 + server/events.ts | 6 +++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/routes/to/$organization.$tournament/bracket.$id.tsx b/app/routes/to/$organization.$tournament/bracket.$id.tsx index a0b151d2c..1cbf982cb 100644 --- a/app/routes/to/$organization.$tournament/bracket.$id.tsx +++ b/app/routes/to/$organization.$tournament/bracket.$id.tsx @@ -1,22 +1,22 @@ -import { ActionFunction, json, useLoaderData, useMatches } from "remix"; import type { LinksFunction, LoaderFunction } from "remix"; -import { EliminationBracket } from "~/components/tournament/EliminationBracket"; -import styles from "~/styles/tournament-bracket.css"; +import { ActionFunction, json, useMatches } from "remix"; import invariant from "tiny-invariant"; -import type { FindTournamentByNameForUrlI } from "~/services/tournament"; -import { bracketById, reportScore, undoLastScore } from "~/services/bracket"; -import type { BracketModified } from "~/services/bracket"; -import { useEvents, useUser } from "~/utils/hooks"; -import { BracketActions } from "~/components/tournament/BracketActions"; import { z } from "zod"; +import { BracketActions } from "~/components/tournament/BracketActions"; +import { EliminationBracket } from "~/components/tournament/EliminationBracket"; +import { BEST_OF_OPTIONS, TOURNAMENT_TEAM_ROSTER_MIN_SIZE } from "~/constants"; +import { useBracketDataWithEvents } from "~/hooks/useBracketDataWithEvents"; +import type { BracketModified } from "~/services/bracket"; +import { bracketById, reportScore, undoLastScore } from "~/services/bracket"; +import type { FindTournamentByNameForUrlI } from "~/services/tournament"; +import styles from "~/styles/tournament-bracket.css"; import { parseRequestFormData, requireEvents, requireUser, safeJSONParse, } from "~/utils"; -import { BEST_OF_OPTIONS, TOURNAMENT_TEAM_ROSTER_MIN_SIZE } from "~/constants"; -import { useBracketDataWithEvents } from "~/hooks/useBracketDataWithEvents"; +import { useUser } from "~/utils/hooks"; export const links: LinksFunction = () => { return [{ rel: "stylesheet", href: styles }]; diff --git a/app/services/bracket.ts b/app/services/bracket.ts index c9c6e0d6f..4d6b6e24d 100644 --- a/app/services/bracket.ts +++ b/app/services/bracket.ts @@ -259,16 +259,18 @@ export async function reportScore({ reporterId: userId, winner: winnerTeam.order, }); + const upperParticipant = match.participants.find( (p) => p.order === "UPPER" - )!; + ); const lowerParticipant = match.participants.find( (p) => p.order === "LOWER" - )!; + ); + return [ match.position, - upperParticipant.team.name, - lowerParticipant.team.name, + upperParticipant?.team.name ?? null, + lowerParticipant?.team.name ?? null, newScore[0], newScore[1], ]; diff --git a/app/utils/hooks.ts b/app/utils/hooks.ts index 399a4e582..746e36805 100644 --- a/app/utils/hooks.ts +++ b/app/utils/hooks.ts @@ -31,6 +31,7 @@ export const useEvents = ( }); source.addEventListener("message", (e) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument handleEvent(JSON.parse(e.data)); }); diff --git a/server/events.ts b/server/events.ts index 6330eecfe..747632015 100644 --- a/server/events.ts +++ b/server/events.ts @@ -4,8 +4,8 @@ import { v4 as uuidv4 } from "uuid"; export type BracketData = [ matchNumber: number, - teamUpper: string, - teamLower: string, + teamUpper: string | null, + teamLower: string | null, scoreUpper: number, scoreLower: number ]; @@ -70,7 +70,7 @@ const sendEvent = ({ data, }: { res: Response; - data: Array; + data: Array; }) => { res.write(`data: ${JSON.stringify(data)}\n\n`); };