From 12d9eafcd9488f29e93b25034df402a04439d288 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Thu, 17 Nov 2022 22:36:53 -0800 Subject: [PATCH] lint --- client/.eslintrc.json | 7 +- client/app/(auth)/components/index.tsx | 2 +- client/app/(auth)/signin/page.tsx | 2 +- client/app/(auth)/signup/page.tsx | 2 +- .../components/file-dropdown/index.tsx | 4 +- .../app/(posts)/components/preview/index.tsx | 4 +- .../new/components/drag-and-drop/index.tsx | 10 +- .../edit-document/formatting-icons/index.tsx | 2 +- .../edit-document/index.tsx | 6 +- .../(posts)/new/components/post.module.css | 14 --- .../(posts)/new/components/title/index.tsx | 25 ++-- .../new/components/title/title.module.css | 18 +++ .../post-page/view-document/index.tsx | 2 +- client/app/(posts)/post/[id]/page.tsx | 5 +- client/app/admin/components/post-table.tsx | 12 +- client/app/admin/page.tsx | 2 +- client/app/components/button/index.tsx | 6 +- client/app/components/header/controls.tsx | 8 +- client/app/components/header/index.tsx | 6 +- client/app/components/home.tsx | 2 +- client/app/components/input/index.tsx | 17 ++- client/app/components/popover/index.tsx | 33 +++--- client/app/components/post-list/index.tsx | 4 +- client/app/components/post-list/list-item.tsx | 12 +- client/app/components/skeleton/index.tsx | 10 +- client/app/components/theme/ThemeProvider.tsx | 42 +++---- .../theme/ThemeServerContextProvider.tsx | 28 +++-- client/app/components/theme/theme.tsx | 6 +- client/app/layout.tsx | 2 +- client/app/mine/page.tsx | 8 +- .../settings/components/sections/password.tsx | 2 +- .../settings/components/sections/profile.tsx | 4 +- client/app/styles/globals.css | 9 +- client/lib/config.ts | 12 +- client/lib/constants.ts | 4 +- client/lib/server/auth.ts | 2 +- client/lib/server/session.ts | 8 +- client/package.json | 3 +- client/pnpm-lock.yaml | 109 ++++++++++-------- 39 files changed, 223 insertions(+), 231 deletions(-) create mode 100644 client/app/(posts)/new/components/title/title.module.css diff --git a/client/.eslintrc.json b/client/.eslintrc.json index c685e93e..bffb357a 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -1,8 +1,3 @@ { - "extends": "next/core-web-vitals", - "settings": { - "next": { - "rootDir": "client/" - } - } + "extends": "next/core-web-vitals" } diff --git a/client/app/(auth)/components/index.tsx b/client/app/(auth)/components/index.tsx index 1110a99c..0aab279f 100644 --- a/client/app/(auth)/components/index.tsx +++ b/client/app/(auth)/components/index.tsx @@ -70,7 +70,7 @@ const Auth = ({ onClick={(e) => { e.preventDefault() signIn("github", { - callbackUrl: "/", + callbackUrl: "/" }) }} > diff --git a/client/app/(auth)/signin/page.tsx b/client/app/(auth)/signin/page.tsx index a8ac70fc..b18f16b8 100644 --- a/client/app/(auth)/signin/page.tsx +++ b/client/app/(auth)/signin/page.tsx @@ -1,5 +1,5 @@ import Auth from "../components" export default function SignInPage() { - return () + return } diff --git a/client/app/(auth)/signup/page.tsx b/client/app/(auth)/signup/page.tsx index c7e6a786..b305301c 100644 --- a/client/app/(auth)/signup/page.tsx +++ b/client/app/(auth)/signup/page.tsx @@ -7,5 +7,5 @@ const getPasscode = async () => { export default async function SignUpPage() { const requiresPasscode = await getPasscode() - return () + return } diff --git a/client/app/(posts)/components/file-dropdown/index.tsx b/client/app/(posts)/components/file-dropdown/index.tsx index 60aeb0dd..f1a77399 100644 --- a/client/app/(posts)/components/file-dropdown/index.tsx +++ b/client/app/(posts)/components/file-dropdown/index.tsx @@ -53,7 +53,9 @@ const FileDropdown = ({ files }: { files: File[] }) => {
- Jump to {files.length} {files.length === 1 ? "file" : "files"} + + Jump to {files.length} {files.length === 1 ? "file" : "files"} + {content} diff --git a/client/app/(posts)/components/preview/index.tsx b/client/app/(posts)/components/preview/index.tsx index fd668fd2..384d9477 100644 --- a/client/app/(posts)/components/preview/index.tsx +++ b/client/app/(posts)/components/preview/index.tsx @@ -52,7 +52,9 @@ const MarkdownPreview = ({ return ( <> {isLoading ? ( - <> + <> + + ) : ( )} diff --git a/client/app/(posts)/new/components/drag-and-drop/index.tsx b/client/app/(posts)/new/components/drag-and-drop/index.tsx index 52ea49d1..8e31e082 100644 --- a/client/app/(posts)/new/components/drag-and-drop/index.tsx +++ b/client/app/(posts)/new/components/drag-and-drop/index.tsx @@ -1,4 +1,4 @@ -import { useMediaQuery, useTheme, useToasts } from "@geist-ui/core/dist" +import { useMediaQuery, useTheme, useToasts } from "@geist-ui/core/dist" import { useDropzone } from "react-dropzone" import styles from "./drag-and-drop.module.css" import generateUUID from "@lib/generate-uuid" @@ -78,9 +78,7 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) { {file.name}:
    {errors.map((e) => ( -
  • - {e.message} -
  • +
  • {e.message}
  • ))}
@@ -98,7 +96,9 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) { > {!isDragActive && ( -

Drag some files here, or {verb} to select files

+

+ Drag some files here, or {verb} to select files +

)} {isDragActive &&

Release to drop the files here

} diff --git a/client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx b/client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx index 02ec4cb8..381a8f6d 100644 --- a/client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx +++ b/client/app/(posts)/new/components/edit-document-list/edit-document/formatting-icons/index.tsx @@ -14,7 +14,7 @@ import ButtonGroup from "@components/button-group" // TODO: clean up const FormattingIcons = ({ - textareaRef, + textareaRef }: { textareaRef?: RefObject }) => { diff --git a/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx b/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx index c27f55a3..3c8225a3 100644 --- a/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx +++ b/client/app/(posts)/new/components/edit-document-list/edit-document/index.tsx @@ -1,8 +1,4 @@ -import { - ChangeEvent, - memo, - useCallback, -} from "react" +import { ChangeEvent, memo, useCallback } from "react" import styles from "./document.module.css" import Trash from "@geist-ui/icons/trash" import Button from "@components/button" diff --git a/client/app/(posts)/new/components/post.module.css b/client/app/(posts)/new/components/post.module.css index 155b476e..22c7f6d0 100644 --- a/client/app/(posts)/new/components/post.module.css +++ b/client/app/(posts)/new/components/post.module.css @@ -17,26 +17,12 @@ flex: 1; } -.title { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - margin-bottom: var(--gap); -} - .description { width: 100%; margin-bottom: var(--gap); } - @media screen and (max-width: 650px) { - .title { - align-items: flex-start; - flex-direction: column; - } - .buttons { flex-direction: column; margin: 0; diff --git a/client/app/(posts)/new/components/title/index.tsx b/client/app/(posts)/new/components/title/index.tsx index 2b093342..838b5d69 100644 --- a/client/app/(posts)/new/components/title/index.tsx +++ b/client/app/(posts)/new/components/title/index.tsx @@ -1,8 +1,7 @@ -import { ChangeEvent, memo, useEffect, useState } from "react" +import type { ChangeEvent } from "react" -import ShiftBy from "@components/shift-by" -import styles from "../post.module.css" import Input from "@components/input" +import styles from "./title.module.css" const titlePlaceholders = [ "How to...", @@ -20,26 +19,22 @@ type props = { } const Title = ({ onChange, title }: props) => { - const [placeholder, setPlaceholder] = useState(titlePlaceholders[0]) - useEffect(() => { - // set random placeholder on load - setPlaceholder( - titlePlaceholders[Math.floor(Math.random() * titlePlaceholders.length)] - ) - }, []) + const placeholder = + titlePlaceholders[Math.floor(Math.random() * titlePlaceholders.length)] return (
-

Drift

+

Drift

) } -export default memo(Title) +export default Title diff --git a/client/app/(posts)/new/components/title/title.module.css b/client/app/(posts)/new/components/title/title.module.css new file mode 100644 index 00000000..03d21077 --- /dev/null +++ b/client/app/(posts)/new/components/title/title.module.css @@ -0,0 +1,18 @@ +.title { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + margin-bottom: var(--gap); +} + +@media screen and (max-width: 650px) { + .title { + align-items: flex-start; + flex-direction: column; + } +} + +.labelAndInput { + font-size: 1.2rem; +} diff --git a/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx index c7b5bbb4..034d7211 100644 --- a/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx +++ b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx @@ -86,7 +86,7 @@ const Document = ({ { return { post, isAuthor: isAuthorOrAdmin } } - if ( - (post.visibility === "private") && - !isAuthorOrAdmin - ) { + if (post.visibility === "private" && !isAuthorOrAdmin) { return notFound() } diff --git a/client/app/admin/components/post-table.tsx b/client/app/admin/components/post-table.tsx index 329879ea..b61ec8ad 100644 --- a/client/app/admin/components/post-table.tsx +++ b/client/app/admin/components/post-table.tsx @@ -1,17 +1,13 @@ -'use client'; +"use client" import SettingsGroup from "@components/settings-group" import { Fieldset, useToasts } from "@geist-ui/core/dist" import byteToMB from "@lib/byte-to-mb" -import { PostWithFiles } from "@lib/server/prisma"; +import { PostWithFiles } from "@lib/server/prisma" import Table from "rc-table" -import { useMemo } from "react" +import { useMemo } from "react" import ActionDropdown from "./action-dropdown" -const PostTable = ({ - posts, -}: { - posts: PostWithFiles[] -}) => { +const PostTable = ({ posts }: { posts: PostWithFiles[] }) => { const tablePosts = useMemo( () => posts?.map((post) => { diff --git a/client/app/admin/page.tsx b/client/app/admin/page.tsx index 0b1e2969..3180f6d0 100644 --- a/client/app/admin/page.tsx +++ b/client/app/admin/page.tsx @@ -26,7 +26,7 @@ const AdminPage = async () => { display: "flex", flexDirection: "column", alignItems: "center", - gap: "var(--gap)", + gap: "var(--gap)" }} > diff --git a/client/app/components/button/index.tsx b/client/app/components/button/index.tsx index 5e0fadff..786beb91 100644 --- a/client/app/components/button/index.tsx +++ b/client/app/components/button/index.tsx @@ -48,7 +48,11 @@ const Button = forwardRef( {iconLeft} )} - {children ? children : {iconLeft || iconRight}} + {children ? ( + children + ) : ( + {iconLeft || iconRight} + )} {children && iconRight && ( {iconRight} diff --git a/client/app/components/header/controls.tsx b/client/app/components/header/controls.tsx index 0fa00a0d..e7cc9636 100644 --- a/client/app/components/header/controls.tsx +++ b/client/app/components/header/controls.tsx @@ -17,13 +17,7 @@ const Controls = () => { return (
- Light diff --git a/client/app/components/header/index.tsx b/client/app/components/header/index.tsx index 4b6c8683..ccfb81db 100644 --- a/client/app/components/header/index.tsx +++ b/client/app/components/header/index.tsx @@ -1,10 +1,6 @@ "use client" -import { - Page, - useBodyScroll, - useMediaQuery -} from "@geist-ui/core/dist" +import { Page, useBodyScroll, useMediaQuery } from "@geist-ui/core/dist" import { useEffect, useState } from "react" import styles from "./header.module.css" diff --git a/client/app/components/home.tsx b/client/app/components/home.tsx index 846a4b0b..4e9b55a6 100644 --- a/client/app/components/home.tsx +++ b/client/app/components/home.tsx @@ -1,5 +1,5 @@ "use client" -import { Tabs, Textarea } from "@geist-ui/core/dist" +import { Tabs, Textarea } from "@geist-ui/core/dist" import Image from "next/image" import styles from "./home.module.css" // TODO:components/new-post/ move these styles diff --git a/client/app/components/input/index.tsx b/client/app/components/input/index.tsx index 764b7e31..8c6d3504 100644 --- a/client/app/components/input/index.tsx +++ b/client/app/components/input/index.tsx @@ -1,3 +1,4 @@ +import clsx from "clsx" import React from "react" import styles from "./input.module.css" @@ -5,12 +6,12 @@ type Props = React.HTMLProps & { label?: string width?: number | string height?: number | string + labelClassName?: string } // eslint-disable-next-line react/display-name const Input = React.forwardRef( - ({ label, className, width, height, ...props }, ref) => { - const classes = [styles.input, styles.withLabel, className].join(" ") + ({ label, className, width, height, labelClassName, ...props }, ref) => { return (
( height }} > - {label && } + {label && ( + + )} + return } Popover.Trigger = React.forwardRef< - HTMLButtonElement, - PopoverPrimitive.PopoverTriggerProps + HTMLButtonElement, + PopoverPrimitive.PopoverTriggerProps >(function PopoverTrigger({ ...props }, ref) { - return + return }) Popover.Portal = PopoverPrimitive.Portal Popover.Content = React.forwardRef< - HTMLDivElement, - PopoverPrimitive.PopoverContentProps + HTMLDivElement, + PopoverPrimitive.PopoverContentProps >(function PopoverContent({ className, ...props }, ref) { - return ( - - ) + return ( + + ) }) diff --git a/client/app/components/post-list/index.tsx b/client/app/components/post-list/index.tsx index f66ea527..bf8a9e99 100644 --- a/client/app/components/post-list/index.tsx +++ b/client/app/components/post-list/index.tsx @@ -89,7 +89,7 @@ const PostList = ({ const deletePost = useCallback( (postId: string) => async () => { const res = await fetch(`/api/post/${postId}`, { - method: "DELETE", + method: "DELETE" }) if (!res.ok) { @@ -112,7 +112,7 @@ const PostList = ({ style={{ maxWidth: 300 }} />
- {!posts &&

Failed to load.

} + {!posts &&

Failed to load.

} {!posts?.length && searching && (
  • diff --git a/client/app/components/post-list/list-item.tsx b/client/app/components/post-list/list-item.tsx index f49ccdf6..46482589 100644 --- a/client/app/components/post-list/list-item.tsx +++ b/client/app/components/post-list/list-item.tsx @@ -62,10 +62,18 @@ const ListItem = ({ )} -