mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-30 22:49:03 +02:00
🐛 Fix linting issues (#1642)
This commit is contained in:
parent
ba84b40776
commit
6b914610d9
18 changed files with 155 additions and 174 deletions
|
@ -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") {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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 } =
|
||||
|
|
|
@ -5,7 +5,7 @@ async function getDatabaseStatus() {
|
|||
try {
|
||||
await prisma.$connect();
|
||||
return "connected";
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return "disconnected";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ export const withAuth = (
|
|||
if (session) {
|
||||
isLegacySession = true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
isExpiredLegacySession = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ export const createSSRHelper = async () => {
|
|||
ctx: await createContext(),
|
||||
transformer: superjson,
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return redirect("/login");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
>;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class LocalStorage {
|
|||
localStorage.setItem(testKey, testKey);
|
||||
localStorage.removeItem(testKey);
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue