From 0610a6acfaa73cec253b6582f013d638121b8e79 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Wed, 17 Apr 2024 19:14:10 -0400 Subject: [PATCH] warning fixes --- Frontend/src/app/(pages)/page.tsx | 1 + .../app/(pages)/player/[[...slug]]/page.tsx | 2 +- Frontend/src/app/components/embed.tsx | 63 ++++++++++--------- .../src/app/components/github-star-button.tsx | 10 ++- .../src/app/components/minecraft-button.tsx | 61 +++++++++--------- .../app/components/player/player-search.tsx | 3 +- Frontend/src/app/config.ts | 4 +- Frontend/src/app/layout.tsx | 4 +- Frontend/src/app/lib/utils.ts | 4 +- 9 files changed, 81 insertions(+), 71 deletions(-) diff --git a/Frontend/src/app/(pages)/page.tsx b/Frontend/src/app/(pages)/page.tsx index 4fd605a..bba5e07 100644 --- a/Frontend/src/app/(pages)/page.tsx +++ b/Frontend/src/app/(pages)/page.tsx @@ -1,6 +1,7 @@ import FeaturedContent from "@/components/landing/featured-content"; import Hero from "@/components/landing/hero"; import StatisticCounters from "@/components/landing/statistic-counters"; +import { ReactElement } from "react"; /** * The landing page. diff --git a/Frontend/src/app/(pages)/player/[[...slug]]/page.tsx b/Frontend/src/app/(pages)/player/[[...slug]]/page.tsx index c07572d..1a2052e 100644 --- a/Frontend/src/app/(pages)/player/[[...slug]]/page.tsx +++ b/Frontend/src/app/(pages)/player/[[...slug]]/page.tsx @@ -114,7 +114,7 @@ export const generateMetadata = async ({ const trimQuery = (query: string | undefined): string | undefined => { // Limit the query to 36 chars if (query && query.length > 36) { - query = query.substr(0, 36); + query = query.substring(0, 36); } return query; }; diff --git a/Frontend/src/app/components/embed.tsx b/Frontend/src/app/components/embed.tsx index e738adc..cfdcabc 100644 --- a/Frontend/src/app/components/embed.tsx +++ b/Frontend/src/app/components/embed.tsx @@ -1,20 +1,23 @@ import { Metadata } from "next"; +/** + * Props for an embed. + */ type EmbedProps = { - /** - * The title of the embed. - */ - title: string; + /** + * The title of the embed. + */ + title: string; - /** - * The description of the embed. - */ - description: string; + /** + * The description of the embed. + */ + description: string; - /** - * The optional thumbnail image of the embed. - */ - thumbnail?: string; + /** + * The optional thumbnail image of the embed. + */ + thumbnail?: string; }; /** @@ -24,24 +27,24 @@ type EmbedProps = { * @returns the embed jsx */ const Embed = ({ - title, - description, - thumbnail = "", + title, + description, + thumbnail = "", }: EmbedProps): Metadata => { - return { - title: title, - openGraph: { - title: `${title}`, - description: description, - images: [ - { - url: thumbnail, - }, - ], - }, - twitter: { - card: "summary", - }, - }; + return { + title: title, + openGraph: { + title: `${title}`, + description: description, + images: [ + { + url: thumbnail, + }, + ], + }, + twitter: { + card: "summary", + }, + }; }; export default Embed; diff --git a/Frontend/src/app/components/github-star-button.tsx b/Frontend/src/app/components/github-star-button.tsx index 1c85ab0..2af46ab 100644 --- a/Frontend/src/app/components/github-star-button.tsx +++ b/Frontend/src/app/components/github-star-button.tsx @@ -2,8 +2,14 @@ import MinecraftButton from "@/components/minecraft-button"; import { Skeleton } from "@/components/ui/skeleton"; import { StarIcon } from "@heroicons/react/24/outline"; import Link from "next/link"; -import { Suspense } from "react"; +import { ReactElement, Suspense } from "react"; +/** + * The button to display the amount + * of stars the GitHub repository has. + * + * @returns the component jsx + */ const GitHubStarButton = async (): Promise => { return ( => { * * @returns the star count jsx */ -const GitHubStarCount = async (): Promise => { +const GitHubStarCount = async (): Promise => { const stars: number = await getStarCount(); // Get the repo star count return ( {stars} diff --git a/Frontend/src/app/components/minecraft-button.tsx b/Frontend/src/app/components/minecraft-button.tsx index c12251f..fc00ecc 100644 --- a/Frontend/src/app/components/minecraft-button.tsx +++ b/Frontend/src/app/components/minecraft-button.tsx @@ -1,19 +1,20 @@ import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; +import { ButtonHTMLAttributes, ReactElement, ReactNode } from "react"; /** * Props for this button. */ type MinecraftButtonProps = { - /** - * The class name to apply to this button. - */ - className?: string; + /** + * The class name to apply to this button. + */ + className?: string; - /** - * The children of this button. - */ - children: React.ReactNode; + /** + * The children of this button. + */ + children: ReactNode; }; /** @@ -22,27 +23,27 @@ type MinecraftButtonProps = { * @returns the button jsx */ const MinecraftButton = ({ - className, - children, - ...props -}: React.ButtonHTMLAttributes & - MinecraftButtonProps): JSX.Element => ( - + className, + children, + ...props +}: ButtonHTMLAttributes & + MinecraftButtonProps): ReactElement => ( + ); export default MinecraftButton; diff --git a/Frontend/src/app/components/player/player-search.tsx b/Frontend/src/app/components/player/player-search.tsx index 60fdc72..a576fd8 100644 --- a/Frontend/src/app/components/player/player-search.tsx +++ b/Frontend/src/app/components/player/player-search.tsx @@ -3,6 +3,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { redirect } from "next/navigation"; +import { ReactElement } from "react"; /** * A component for searching for a player. @@ -15,7 +16,7 @@ const PlayerSearch = ({ }: { query: string | undefined; }): ReactElement => { - const handleRedirect = async (form: FormData) => { + const handleRedirect = async (form: FormData): Promise => { "use server"; redirect(`/player/${form.get("query")}`); }; diff --git a/Frontend/src/app/config.ts b/Frontend/src/app/config.ts index 1600248..c282611 100644 --- a/Frontend/src/app/config.ts +++ b/Frontend/src/app/config.ts @@ -1,7 +1,5 @@ -import { Config } from "@/types/config"; - /** * The configuration for this app. */ -const config: Config = require("@/configJson"); +import config from "@/configJson"; export default config; diff --git a/Frontend/src/app/layout.tsx b/Frontend/src/app/layout.tsx index 7b197d4..7cd7676 100644 --- a/Frontend/src/app/layout.tsx +++ b/Frontend/src/app/layout.tsx @@ -8,7 +8,7 @@ import ThemeProvider from "@/provider/theme-provider"; import type { Metadata, Viewport } from "next"; import PlausibleProvider from "next-plausible"; import "./globals.css"; -import { ReactElement } from "react"; +import { ReactElement, ReactNode } from "react"; /** * Site metadata & viewport. @@ -25,7 +25,7 @@ export const viewport: Viewport = config.viewport; const RootLayout = ({ children, }: Readonly<{ - children: React.ReactNode; + children: ReactNode; }>): ReactElement => { const analyticsDomain: string | undefined = config.analyticsDomain; return ( diff --git a/Frontend/src/app/lib/utils.ts b/Frontend/src/app/lib/utils.ts index 3200be2..98e6921 100644 --- a/Frontend/src/app/lib/utils.ts +++ b/Frontend/src/app/lib/utils.ts @@ -1,6 +1,6 @@ import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; -export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); +export function cn(...inputs: ClassValue[]): string { + return twMerge(clsx(inputs)); }