mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-17 18:08:26 -05:00
Fix ESLint complaints
This commit is contained in:
parent
cd5d212ec4
commit
1ea4ff72fd
13
.eslintrc.js
13
.eslintrc.js
|
|
@ -1,6 +1,17 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ["./tsconfig.json"],
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ BracketPaths("Following winners", () => {
|
|||
|
||||
let latest: Match = bracket16.winners[0];
|
||||
let rounds = 0;
|
||||
let roundIds = new Set();
|
||||
const roundIds = new Set();
|
||||
while (latest) {
|
||||
rounds++;
|
||||
roundIds.add(latest.id);
|
||||
|
|
@ -114,7 +114,7 @@ BracketPaths("Following losers", () => {
|
|||
let latest: Match = bracket16.winners[0];
|
||||
let rounds = 0;
|
||||
let countWinnerDestNoLoserDest = 0;
|
||||
let roundIds = new Set();
|
||||
const roundIds = new Set();
|
||||
while (latest) {
|
||||
rounds++;
|
||||
roundIds.add(latest.id);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ TournamentRoundsForDB("Generates rounds correctly", () => {
|
|||
const roundsCounted = countRounds(bracket);
|
||||
let max = -Infinity;
|
||||
let min = Infinity;
|
||||
let uniqueParticipants = new Set<string>();
|
||||
const uniqueParticipants = new Set<string>();
|
||||
|
||||
for (const round of bracketForDb) {
|
||||
max = Math.max(max, round.position);
|
||||
|
|
|
|||
|
|
@ -377,7 +377,9 @@ function resolveSide(
|
|||
const otherNumber = matchNumbers?.find((num) => num !== currentMatch.number);
|
||||
invariant(
|
||||
otherNumber,
|
||||
`no otherNumber; matchNumbers length is not 2 was: ${matchNumbers?.length}`
|
||||
`no otherNumber; matchNumbers length is not 2 was: ${
|
||||
matchNumbers?.length ?? "NO_LENGTH"
|
||||
}`
|
||||
);
|
||||
|
||||
if (otherNumber > currentMatch.number) return "upperTeam";
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export function generateMapListForRounds({
|
|||
result = shuffle(result);
|
||||
}
|
||||
|
||||
let resultWithNoNull: Mode[] = [];
|
||||
const resultWithNoNull: Mode[] = [];
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
const element = result[i];
|
||||
// Is SZ
|
||||
|
|
@ -149,7 +149,7 @@ export function generateMapListForRounds({
|
|||
}
|
||||
|
||||
function resolveMaps(modes: Mode[]) {
|
||||
let result: string[] = [];
|
||||
const result: string[] = [];
|
||||
for (const mode of modes) {
|
||||
mapGenerator.next();
|
||||
const nextMap = mapGenerator.next({
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export const loader: LoaderFunction = ({ context }) => {
|
|||
return { user: user ?? null, baseURL };
|
||||
};
|
||||
|
||||
export let unstable_shouldReload = () => false;
|
||||
export const unstable_shouldReload = () => false;
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
useLocation,
|
||||
} from "remix";
|
||||
import invariant from "tiny-invariant";
|
||||
import { z } from "zod";
|
||||
import { Button } from "~/components/Button";
|
||||
import { Catcher } from "~/components/Catcher";
|
||||
import {
|
||||
|
|
@ -32,6 +33,9 @@ export const action: ActionFunction = async ({ request, context, params }) => {
|
|||
typeof tournamentId === "string",
|
||||
"Invalid type for tournament id."
|
||||
);
|
||||
const parsedParams = z
|
||||
.object({ organization: z.string(), tournament: z.string() })
|
||||
.parse(params);
|
||||
|
||||
const user = requireUser(context);
|
||||
|
||||
|
|
@ -41,7 +45,9 @@ export const action: ActionFunction = async ({ request, context, params }) => {
|
|||
tournamentId: tournamentId,
|
||||
});
|
||||
|
||||
return redirect(`/to/${params.organization}/${params.tournament}/teams`);
|
||||
return redirect(
|
||||
`/to/${parsedParams.organization}/${parsedParams.tournament}/teams`
|
||||
);
|
||||
};
|
||||
|
||||
const INVITE_CODE_LENGTH = 36;
|
||||
|
|
@ -210,11 +216,12 @@ function Contents({ data }: { data: Data }) {
|
|||
</Form>
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
default: {
|
||||
const exhaustive: never = data;
|
||||
throw new Error(
|
||||
`Unexpected join team status code: ${JSON.stringify(exhaustive)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ export const loader: LoaderFunction = async ({ params, context }) => {
|
|||
);
|
||||
|
||||
const user = requireUser(context);
|
||||
let [ownTeam, trustingUsers] = await Promise.all([
|
||||
const [ownTeam, trustingUsersAll] = await Promise.all([
|
||||
ownTeamWithInviteCode({
|
||||
organizationNameForUrl: params.organization,
|
||||
tournamentNameForUrl: params.tournament,
|
||||
|
|
@ -156,7 +156,7 @@ export const loader: LoaderFunction = async ({ params, context }) => {
|
|||
getTrustingUsers(user.id),
|
||||
]);
|
||||
|
||||
trustingUsers = trustingUsers.filter(({ trustGiver }) => {
|
||||
const trustingUsers = trustingUsersAll.filter(({ trustGiver }) => {
|
||||
return !ownTeam.members.some(({ member }) => member.id === trustGiver.id);
|
||||
});
|
||||
|
||||
|
|
@ -323,8 +323,10 @@ function CopyToClipboardButton({
|
|||
<button
|
||||
className="tournament__manage-roster__input__button"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(urlWithInviteCode);
|
||||
setShowCopied(true);
|
||||
navigator.clipboard
|
||||
.writeText(urlWithInviteCode)
|
||||
.then(() => setShowCopied(true))
|
||||
.catch((e) => console.error(e));
|
||||
}}
|
||||
type="button"
|
||||
data-cy="copy-to-clipboard-button"
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export default function MapPoolTab() {
|
|||
<div className="map-pool__mode-images-container">
|
||||
{modesShort.map(
|
||||
(mode) =>
|
||||
modesPerStage(mapPool)[stage]?.includes(mode as Mode) && (
|
||||
modesPerStage(mapPool)[stage]?.includes(mode) && (
|
||||
<img
|
||||
key={mode}
|
||||
className="map-pool__mode-image"
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ function RoundsCollection({
|
|||
return (
|
||||
<li
|
||||
className="tournament__start__map-row"
|
||||
key={"" + stageI + stage.id}
|
||||
key={`${stageI}${stage.id}`}
|
||||
>
|
||||
<img
|
||||
src={`/img/modes/${stage.mode}.webp`}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { PrismaClient } from "@prisma/client";
|
|||
let db: PrismaClient;
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var __db: PrismaClient | undefined;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { json, useLocation } from "remix";
|
|||
import { z } from "zod";
|
||||
|
||||
export function makeTitle(endOfTitle?: string) {
|
||||
return endOfTitle ? `sendou.ink | ${endOfTitle}` : "sendou.ink";
|
||||
return endOfTitle ? `sendou.ink | ${endOfTitle}` : "sendou.ink";
|
||||
}
|
||||
|
||||
/** Get logged in user from context. Throws with 401 error if no user found. */
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ type MockUser = "sendou";
|
|||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable<Subject> {
|
||||
interface Chainable {
|
||||
getCy(id: string): Chainable<JQuery<HTMLElement>>;
|
||||
seed(variation?: "check-in"): void;
|
||||
logIn(user: MockUser): void;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import { PrismaClient } from "@prisma/client";
|
||||
import { z } from "zod";
|
||||
const prisma = new PrismaClient();
|
||||
import { seed } from "./script";
|
||||
|
||||
const legalVariations = ["check-in", "match"];
|
||||
|
||||
const variation = process.argv[2]?.startsWith("-v=")
|
||||
const maybeVariation = process.argv[2]?.startsWith("-v=")
|
||||
? process.argv[2].split("-v=")[1]
|
||||
: undefined;
|
||||
if (variation !== undefined && !legalVariations.includes(variation)) {
|
||||
throw Error("Unknown variation");
|
||||
}
|
||||
const variation = z
|
||||
.enum(["check-in", "match"])
|
||||
.optional()
|
||||
.parse(maybeVariation);
|
||||
|
||||
seed(variation as any)
|
||||
seed(variation)
|
||||
.then(() => {
|
||||
console.log(
|
||||
`🌱 All done with seeding${variation ? ` (variation: ${variation})` : ""}`
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user