🐛 Fix linting issues (#1642)

This commit is contained in:
Luke Vella 2025-03-27 12:02:40 +00:00 committed by GitHub
parent ba84b40776
commit 6b914610d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 155 additions and 174 deletions

View file

@ -19,7 +19,7 @@ export async function middleware(request: NextRequest) {
return;
}
const locale = await getPreferredLocale(request);
const locale = getPreferredLocale(request);
request.nextUrl.pathname = `/${locale}${pathname}`;
if (locale === "en") {

View file

@ -1,4 +1,3 @@
import type { NextPage } from "next";
import type React from "react";
export type ReactTag = keyof JSX.IntrinsicElements;
@ -7,19 +6,6 @@ export type PropsOf<TTag extends ReactTag> = TTag extends React.ElementType
? React.ComponentProps<TTag>
: never;
// eslint-disable-next-line @typescript-eslint/ban-types
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: React.ReactElement) => React.ReactNode;
};
// eslint-disable-next-line @typescript-eslint/ban-types
export type PropsWithClassName<TProps extends Record<string, unknown> = {}> =
React.PropsWithChildren<TProps> & {
className?: string;
};
export type IconComponent = React.ComponentType<PropsWithClassName>;
export type Post = {
slug: string;
title: string;

View file

@ -1,42 +0,0 @@
"use client";
import { cn } from "@rallly/ui";
import { Link } from "lucide-react";
import { usePathname } from "next/navigation";
import type { IconComponent } from "@/types";
export function MenuItem({
href,
children,
icon: Icon,
}: {
href: string;
icon: IconComponent;
children: React.ReactNode;
}) {
const pathname = usePathname();
const isCurrent = pathname === href;
return (
<Link
href={href}
className={cn(
isCurrent
? "bg-gray-200 text-indigo-600"
: "hover:text-primary text-gray-700",
"group flex items-center gap-x-3 rounded-md px-3 py-2 text-sm font-semibold leading-6",
)}
>
<Icon
className={cn(
isCurrent
? "text-indigo-600"
: "text-gray-400 group-hover:text-indigo-600",
"size-5 shrink-0",
)}
aria-hidden="true"
/>
{children}
</Link>
);
}

View file

@ -1,10 +1,6 @@
"use client";
import { Badge } from "@rallly/ui/badge";
import { z } from "zod";
import { Trans } from "@/components/trans";
const brandLabels = {
visa: "Visa",
mastercard: "Mastercard",

View file

@ -18,9 +18,8 @@ import { PollDetailsForm } from "@/components/forms/poll-details-form";
import { useUpdatePollMutation } from "@/components/poll/mutations";
import { usePoll } from "@/components/poll-context";
import { Trans } from "@/components/trans";
import type { NextPageWithLayout } from "@/types";
const Page: NextPageWithLayout = () => {
const Page = () => {
const { poll } = usePoll();
const urlId = poll.adminUrlId;
const { mutate: updatePollMutation, isLoading: isUpdating } =

View file

@ -5,7 +5,7 @@ async function getDatabaseStatus() {
try {
await prisma.$connect();
return "connected";
} catch (e) {
} catch {
return "disconnected";
}
}

View file

@ -33,7 +33,7 @@ export const withAuth = (
if (session) {
isLegacySession = true;
}
} catch (e) {
} catch {
isExpiredLegacySession = true;
}
}

View file

@ -1,3 +1,4 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { cn } from "@rallly/ui";
import { Button } from "@rallly/ui/button";
import type { DialogProps } from "@rallly/ui/dialog";
@ -118,6 +119,7 @@ export const FinalizePollForm = ({
selectedOptionId: options[0].id,
notify: "all",
},
resolver: zodResolver(formSchema),
});
return (

View file

@ -1,3 +1,4 @@
import { zodResolver } from "@hookform/resolvers/zod";
import {
Dialog,
DialogContent,
@ -108,6 +109,7 @@ export const VotingForm = ({ children }: React.PropsWithChildren) => {
optionId: option.id,
})),
},
resolver: zodResolver(formSchema),
});
return (

View file

@ -1,3 +1,4 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { Button } from "@rallly/ui/button";
import { Form, FormField, FormItem, FormLabel } from "@rallly/ui/form";
import { ArrowUpRight } from "lucide-react";
@ -24,6 +25,7 @@ export const LanguagePreference = () => {
defaultValues: {
language: i18n.language,
},
resolver: zodResolver(formSchema),
});
const { updatePreferences } = usePreferences();

View file

@ -36,7 +36,7 @@ export const createSSRHelper = async () => {
ctx: await createContext(),
transformer: superjson,
});
} catch (error) {
} catch {
return redirect("/login");
}
};

View file

@ -1,4 +1,3 @@
import type { NextPage } from "next";
import type React from "react";
export type ReactTag = keyof JSX.IntrinsicElements;
@ -7,16 +6,15 @@ export type PropsOf<TTag extends ReactTag> = TTag extends React.ElementType
? React.ComponentProps<TTag>
: never;
// eslint-disable-next-line @typescript-eslint/ban-types
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: React.ReactElement) => React.ReactNode;
isAuthRequired?: boolean;
};
// eslint-disable-next-line @typescript-eslint/ban-types
export type PropsWithClassName<TProps extends Record<string, unknown> = {}> =
export type PropsWithClassName<TProps extends Record<string, unknown>> =
React.PropsWithChildren<TProps> & {
className?: string;
};
export type IconComponent = React.ComponentType<PropsWithClassName>;
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export type IconComponent<TProps extends Record<string, unknown> = {}> =
React.ComponentType<
React.PropsWithChildren<TProps> & {
className?: string;
}
>;

View file

@ -26,7 +26,7 @@ export function getBrowserTimeZone() {
function getTimeZoneOffset(timeZone: string) {
try {
return dayjs().tz(timeZone).utcOffset();
} catch (e) {
} catch {
console.error(`Failed to resolve timezone ${timeZone}`);
return 0;
}

View file

@ -19,7 +19,7 @@ class LocalStorage {
localStorage.setItem(testKey, testKey);
localStorage.removeItem(testKey);
return true;
} catch (e) {
} catch {
return false;
}
}

View file

@ -1,8 +1,11 @@
import { defaultLocale } from "@rallly/languages";
import { defaultLocale, supportedLngs } from "@rallly/languages";
import { headers } from "next/headers";
export function getLocaleFromPath() {
const headersList = headers();
const pathname = headersList.get("x-pathname") || defaultLocale;
return pathname.split("/")[1];
const localeFromPath = pathname.split("/")[1];
return supportedLngs.includes(localeFromPath)
? localeFromPath
: defaultLocale;
}