From 1251bf19bc41855a909b039107a4a73ac09012ef Mon Sep 17 00:00:00 2001 From: DrMint Date: Sat, 23 Apr 2022 22:08:22 +0200 Subject: [PATCH] Fixed all lint alert --- src/components/Library/ScanSet.tsx | 5 ++++- src/components/Library/ScanSetCover.tsx | 14 ++++++++------ src/components/OrderableList.tsx | 1 + src/components/Panels/MainPanel.tsx | 2 -- src/components/Post.tsx | 2 ++ src/components/ThumbnailPreview.tsx | 10 ++++++---- src/pages/archives/videos/c/[uid].tsx | 4 ++-- src/pages/contents/[slug]/index.tsx | 2 ++ src/pages/dev/checkup.tsx | 5 ++++- src/pages/library/[slug]/scans.tsx | 2 +- 10 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/components/Library/ScanSet.tsx b/src/components/Library/ScanSet.tsx index ab7f2b3..22411d4 100644 --- a/src/components/Library/ScanSet.tsx +++ b/src/components/Library/ScanSet.tsx @@ -85,6 +85,7 @@ export default function ScanSet(props: Props): JSX.Element { scanLocales ) ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [appLayout.preferredLanguages]); useEffect(() => { @@ -92,6 +93,7 @@ export default function ScanSet(props: Props): JSX.Element { const selectedScanSet = scanSet[selectedScanIndex]; selectedScanSet?.pages?.data.sort((a, b) => { function isInteger(value: string): boolean { + // eslint-disable-next-line require-unicode-regexp return /^\d+$/.test(value); } function getFileName(path: string): string { @@ -115,6 +117,7 @@ export default function ScanSet(props: Props): JSX.Element { }); setSelectedScan(selectedScanSet); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedScanIndex]); return ( @@ -136,7 +139,7 @@ export default function ScanSet(props: Props): JSX.Element {
{content?.data?.attributes?.slug && ( - )} diff --git a/src/components/Library/ScanSetCover.tsx b/src/components/Library/ScanSetCover.tsx index 50540e2..3fab3ad 100644 --- a/src/components/Library/ScanSetCover.tsx +++ b/src/components/Library/ScanSetCover.tsx @@ -63,26 +63,28 @@ export default function ScanSetCover(props: Props): JSX.Element { scanLocales ) ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [appLayout.preferredLanguages]); useEffect(() => { if (selectedScanIndex !== undefined) setSelectedScan(images[selectedScanIndex]); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedScanIndex]); const coverImages: UploadImageFragment[] = []; if (selectedScan?.obi_belt?.full?.data?.attributes) - coverImages.push(selectedScan.obi_belt?.full?.data?.attributes); + coverImages.push(selectedScan.obi_belt.full.data.attributes); if (selectedScan?.obi_belt?.inside_full?.data?.attributes) - coverImages.push(selectedScan.obi_belt?.inside_full?.data?.attributes); + coverImages.push(selectedScan.obi_belt.inside_full.data.attributes); if (selectedScan?.dust_jacket?.full?.data?.attributes) - coverImages.push(selectedScan.dust_jacket?.full?.data?.attributes); + coverImages.push(selectedScan.dust_jacket.full.data.attributes); if (selectedScan?.dust_jacket?.inside_full?.data?.attributes) - coverImages.push(selectedScan.dust_jacket?.inside_full?.data?.attributes); + coverImages.push(selectedScan.dust_jacket.inside_full.data.attributes); if (selectedScan?.cover?.full?.data?.attributes) - coverImages.push(selectedScan.cover?.full?.data?.attributes); + coverImages.push(selectedScan.cover.full.data.attributes); if (selectedScan?.cover?.inside_full?.data?.attributes) - coverImages.push(selectedScan.cover?.inside_full?.data?.attributes); + coverImages.push(selectedScan.cover.inside_full.data.attributes); if (coverImages.length > 0) { return ( diff --git a/src/components/OrderableList.tsx b/src/components/OrderableList.tsx index 0489f03..c079bd2 100644 --- a/src/components/OrderableList.tsx +++ b/src/components/OrderableList.tsx @@ -12,6 +12,7 @@ export default function OrderableList(props: Props): JSX.Element { useEffect(() => { props.onChange?.(items); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [items]); function updateOrder(sourceIndex: number, targetIndex: number) { diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index 64f8c04..00de67e 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -6,7 +6,6 @@ import { useAppLayout } from "contexts/AppLayoutContext"; import { useMediaDesktop } from "hooks/useMediaQuery"; import Markdown from "markdown-to-jsx"; import Link from "next/link"; -import { useRouter } from "next/router"; import { AppStaticProps } from "queries/getAppStaticProps"; interface Props { @@ -15,7 +14,6 @@ interface Props { export default function MainPanel(props: Props): JSX.Element { const { langui } = props; - const router = useRouter(); const isDesktop = useMediaDesktop(); const appLayout = useAppLayout(); diff --git a/src/components/Post.tsx b/src/components/Post.tsx index cfa4e8a..9de74b9 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -89,11 +89,13 @@ export default function Post(props: Props): JSX.Element { translationLocales ) ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [appLayout.preferredLanguages]); useEffect(() => { if (selectedTranslationIndex !== undefined) setSelectedTranslation(post?.translations?.[selectedTranslationIndex]); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedTranslationIndex]); const thumbnail = diff --git a/src/components/ThumbnailPreview.tsx b/src/components/ThumbnailPreview.tsx index 94e8c2e..630451a 100644 --- a/src/components/ThumbnailPreview.tsx +++ b/src/components/ThumbnailPreview.tsx @@ -34,10 +34,12 @@ interface Props { author?: string; position: "Bottom" | "Top"; }; - hoverlay?: { - __typename: "Video"; - duration: number; - }; + hoverlay?: + | { + __typename: "Video"; + duration: number; + } + | { __typename: "anotherHoverlayName" }; } export default function ThumbnailPreview(props: Props): JSX.Element { diff --git a/src/pages/archives/videos/c/[uid].tsx b/src/pages/archives/videos/c/[uid].tsx index abeb2b7..3e3194d 100644 --- a/src/pages/archives/videos/c/[uid].tsx +++ b/src/pages/archives/videos/c/[uid].tsx @@ -103,12 +103,12 @@ export async function getStaticProps( ): Promise<{ notFound: boolean } | { props: Props }> { const sdk = getReadySdk(); const channel = await sdk.getVideoChannel({ - channel: context.params?.uid?.toString() ?? "", + channel: context.params?.uid ? context.params.uid.toString() : "", }); if (!channel.videoChannels?.data[0].attributes) return { notFound: true }; const props: Props = { ...(await getAppStaticProps(context)), - channel: channel.videoChannels?.data[0].attributes, + channel: channel.videoChannels.data[0].attributes, }; return { props: props, diff --git a/src/pages/contents/[slug]/index.tsx b/src/pages/contents/[slug]/index.tsx index 16d50fb..ac54a17 100644 --- a/src/pages/contents/[slug]/index.tsx +++ b/src/pages/contents/[slug]/index.tsx @@ -81,6 +81,7 @@ export default function Content(props: Props): JSX.Element { textSetLocales ) ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [appLayout.preferredLanguages]); useEffect(() => { @@ -88,6 +89,7 @@ export default function Content(props: Props): JSX.Element { setSelectedTextSet(content?.text_set?.[selectedTextSetIndex]); if (selectedTextSetIndex !== undefined) setSelectedTitle(content?.titles?.[selectedTextSetIndex]); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedTextSetIndex]); const subPanel = ( diff --git a/src/pages/dev/checkup.tsx b/src/pages/dev/checkup.tsx index b4e78e2..d0f2fae 100644 --- a/src/pages/dev/checkup.tsx +++ b/src/pages/dev/checkup.tsx @@ -61,7 +61,7 @@ function prettyTestWritter( level, `${process.env.NEXT_PUBLIC_URL_SELF}/${locale}${asPath}`, locale, - subCategory?.join(" -> "), + subCategory.join(" -> "), message, process.env.NEXT_PUBLIC_URL_CMS + url, ]; @@ -75,6 +75,7 @@ function prettyTestWritter( } } +// eslint-disable-next-line @typescript-eslint/no-unused-vars function useTestingContent(props: { content: Exclude< GetContentTextQuery["contents"], @@ -183,6 +184,7 @@ function useTestingContent(props: { } } +// eslint-disable-next-line @typescript-eslint/no-unused-vars function useTestingLibrary(props: { item: Exclude< GetLibraryItemQuery["libraryItems"], @@ -509,6 +511,7 @@ function useTestingLibrary(props: { } } +// eslint-disable-next-line @typescript-eslint/no-unused-vars function useTestingChronology(props: { chronologyItems: Exclude< GetChronologyItemsQuery["chronologyItems"], diff --git a/src/pages/library/[slug]/scans.tsx b/src/pages/library/[slug]/scans.tsx index 41478fc..cab0072 100644 --- a/src/pages/library/[slug]/scans.tsx +++ b/src/pages/library/[slug]/scans.tsx @@ -137,7 +137,7 @@ export async function getStaticProps( ): Promise<{ notFound: boolean } | { props: Props }> { const sdk = getReadySdk(); const item = await sdk.getLibraryItemScans({ - slug: context.params?.slug?.toString() ?? "", + slug: context.params?.slug ? context.params.slug.toString() : "", language_code: context.locale ?? "en", }); if (!item.libraryItems) return { notFound: true };