Eslint changes and linting (no-mix-spaces)
This commit is contained in:
parent
371dae25d9
commit
c51ca39fa7
22 changed files with 103 additions and 87 deletions
|
@ -7,5 +7,8 @@
|
|||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"root": true,
|
||||
"ignorePatterns": ["node_modules/", "__tests__/"]
|
||||
"ignorePatterns": ["node_modules/", "__tests__/"],
|
||||
"rules": {
|
||||
"no-mixed-spaces-and-tabs": ["off"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"dev": "next dev --port 3000",
|
||||
"build": "next build",
|
||||
"start": "next start --port 3000",
|
||||
"lint": "next lint && prettier --list-different --config .prettierrc '{components,lib,app,pages}/**/*.{ts,tsx}' --write",
|
||||
"lint": "next lint && prettier --list-different --config .prettierrc 'src/{components,lib,app,pages}/**/*.{ts,tsx}' --write",
|
||||
"analyze": "cross-env ANALYZE=true next build",
|
||||
"find:unused": "next-unused",
|
||||
"prisma": "prisma",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Input from "@components/input"
|
||||
import { ChangeEvent, memo } from "react"
|
||||
import { ChangeEvent } from "react"
|
||||
|
||||
import styles from "../post.module.css"
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ const Post = ({
|
|||
title: doc.title,
|
||||
content: doc.content,
|
||||
id: doc.id
|
||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
||||
}))
|
||||
: [emptyDoc]
|
||||
|
||||
|
@ -285,7 +284,6 @@ const Post = ({
|
|||
}
|
||||
])
|
||||
}}
|
||||
type="default"
|
||||
style={{
|
||||
flex: 1
|
||||
}}
|
||||
|
|
|
@ -13,7 +13,7 @@ export const PostButtons = ({
|
|||
files,
|
||||
loading,
|
||||
postId,
|
||||
parentId,
|
||||
parentId
|
||||
}: {
|
||||
title: string
|
||||
files?: Pick<PostWithFiles, "files">["files"]
|
||||
|
|
|
@ -21,9 +21,9 @@ export const PostTitle = ({
|
|||
visibility,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
loading,
|
||||
// authorId
|
||||
}: TitleProps) => {
|
||||
loading
|
||||
}: // authorId
|
||||
TitleProps) => {
|
||||
return (
|
||||
<span className={styles.title}>
|
||||
<h1
|
||||
|
|
|
@ -22,7 +22,8 @@ const PasswordModalPage = ({ setPost, postId, authorId }: Props) => {
|
|||
? undefined
|
||||
: session?.user && session?.user?.id === authorId
|
||||
const [isPasswordModalOpen, setIsPasswordModalOpen] = useState(false)
|
||||
const onSubmit = useCallback(async (password: string) => {
|
||||
const onSubmit = useCallback(
|
||||
async (password: string) => {
|
||||
const res = await fetch(`/api/post/${postId}?password=${password}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
@ -50,7 +51,9 @@ const PasswordModalPage = ({ setPost, postId, authorId }: Props) => {
|
|||
setPost(data.post)
|
||||
}
|
||||
}
|
||||
}, [postId, setPost, setToast])
|
||||
},
|
||||
[postId, setPost, setToast]
|
||||
)
|
||||
|
||||
const onClose = () => {
|
||||
setIsPasswordModalOpen(false)
|
||||
|
|
|
@ -21,11 +21,9 @@ type SharedProps = {
|
|||
type Props = (
|
||||
| {
|
||||
skeleton?: true
|
||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
||||
}
|
||||
| {
|
||||
skeleton?: false
|
||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
||||
}
|
||||
) &
|
||||
SharedProps
|
||||
|
|
|
@ -6,7 +6,7 @@ type BadgeProps = {
|
|||
} & React.HTMLAttributes<HTMLDivElement>
|
||||
|
||||
const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(
|
||||
({ type, children, ...rest}: BadgeProps, ref) => {
|
||||
({ type, children, ...rest }: BadgeProps, ref) => {
|
||||
return (
|
||||
<div className={styles.container} {...rest}>
|
||||
<div className={`${styles.badge} ${styles[type]}`} ref={ref}>
|
||||
|
|
|
@ -15,7 +15,11 @@ type Props = {
|
|||
visibility: string
|
||||
}
|
||||
|
||||
const VisibilityControl = ({ authorId, postId, visibility: postVisibility }: Props) => {
|
||||
const VisibilityControl = ({
|
||||
authorId,
|
||||
postId,
|
||||
visibility: postVisibility
|
||||
}: Props) => {
|
||||
const { data: session } = useSession()
|
||||
const isAuthor = session?.user && session?.user?.id === authorId
|
||||
const [visibility, setVisibility] = useState<string>(postVisibility)
|
||||
|
@ -23,7 +27,7 @@ const VisibilityControl = ({ authorId, postId, visibility: postVisibility }: Pro
|
|||
const [isSubmitting, setSubmitting] = useState<string | null>()
|
||||
const [passwordModalVisible, setPasswordModalVisible] = useState(false)
|
||||
const { setToast } = useToasts()
|
||||
const router = useRouter();
|
||||
const router = useRouter()
|
||||
|
||||
const sendRequest = useCallback(
|
||||
async (visibility: string, password?: string) => {
|
||||
|
@ -43,7 +47,6 @@ const VisibilityControl = ({ authorId, postId, visibility: postVisibility }: Pro
|
|||
message: "Visibility updated",
|
||||
type: "success"
|
||||
})
|
||||
|
||||
} else {
|
||||
setToast({
|
||||
message: "An error occurred",
|
||||
|
@ -84,10 +87,12 @@ const VisibilityControl = ({ authorId, postId, visibility: postVisibility }: Pro
|
|||
|
||||
return (
|
||||
<>
|
||||
<ButtonGroup style={{
|
||||
<ButtonGroup
|
||||
style={{
|
||||
maxWidth: 600,
|
||||
margin: "var(--gap) auto",
|
||||
}}>
|
||||
margin: "var(--gap) auto"
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
disabled={visibility === "private"}
|
||||
onClick={() => onSubmit("private")}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import styles from "./button.module.css"
|
||||
import { forwardRef, Ref } from "react"
|
||||
import { forwardRef } from "react"
|
||||
import clsx from "clsx"
|
||||
import { Spinner } from "@components/spinner"
|
||||
|
||||
type Props = React.HTMLProps<HTMLButtonElement> & {
|
||||
type Props = React.DetailedHTMLProps<
|
||||
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
HTMLButtonElement
|
||||
> & {
|
||||
children?: React.ReactNode
|
||||
buttonType?: "primary" | "secondary"
|
||||
className?: string
|
||||
|
@ -25,7 +28,6 @@ const Button = forwardRef<HTMLButtonElement, Props>(
|
|||
onClick,
|
||||
className,
|
||||
buttonType = "primary",
|
||||
type = "button",
|
||||
disabled = false,
|
||||
iconRight,
|
||||
iconLeft,
|
||||
|
@ -41,11 +43,10 @@ const Button = forwardRef<HTMLButtonElement, Props>(
|
|||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
className={clsx(
|
||||
styles.button,
|
||||
type === "primary" || (type === "secondary" && styles[type]),
|
||||
className
|
||||
)}
|
||||
className={clsx(styles.button, className, {
|
||||
[styles.primary]: buttonType === "primary",
|
||||
[styles.secondary]: buttonType === "secondary"
|
||||
})}
|
||||
disabled={disabled || loading}
|
||||
onClick={onClick}
|
||||
style={{ height, width, margin, padding }}
|
||||
|
|
|
@ -17,7 +17,7 @@ type InputProps = Omit<Props, "onChange" | "value" | "label" | "aria-label"> &
|
|||
| {
|
||||
onChange: Props["onChange"]
|
||||
value: Props["value"]
|
||||
} // if onChange or value is passed, we require both
|
||||
}
|
||||
| {
|
||||
onChange?: never
|
||||
value?: never
|
||||
|
@ -64,6 +64,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|||
ref={ref}
|
||||
id={labelId}
|
||||
className={clsx(styles.input, label && styles.withLabel, className)}
|
||||
required={required}
|
||||
{...props}
|
||||
style={{
|
||||
width,
|
||||
|
|
|
@ -92,7 +92,8 @@ const ListItem = ({
|
|||
<ExpirationBadge postExpirationDate={post.expiresAt} />
|
||||
</div>
|
||||
</span>
|
||||
{!hideActions ? <span className={styles.buttons}>
|
||||
{!hideActions ? (
|
||||
<span className={styles.buttons}>
|
||||
{post.parentId && (
|
||||
<Tooltip content={"View parent"}>
|
||||
<Button
|
||||
|
@ -118,7 +119,8 @@ const ListItem = ({
|
|||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</span> : null}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{post.description && (
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export async function copyToClipboard(text: string ) {
|
||||
export async function copyToClipboard(text: string) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
}
|
||||
|
|
|
@ -24,4 +24,4 @@ export default async function Mine() {
|
|||
)
|
||||
}
|
||||
|
||||
export const revalidate = 0;
|
||||
export const revalidate = 0
|
||||
|
|
|
@ -68,7 +68,9 @@ export default async function Page() {
|
|||
<div>
|
||||
<h2>Recent public posts</h2>
|
||||
<Suspense
|
||||
fallback={<PostList skeleton hideSearch initialPosts={JSON.stringify({})} />}
|
||||
fallback={
|
||||
<PostList skeleton hideSearch initialPosts={JSON.stringify({})} />
|
||||
}
|
||||
>
|
||||
{/* @ts-expect-error because of async RSC */}
|
||||
<PublicPostList getPostsPromise={getPostsPromise} />
|
||||
|
|
|
@ -5,7 +5,10 @@ import Input from "@components/input"
|
|||
import Note from "@components/note"
|
||||
import { Spinner } from "@components/spinner"
|
||||
import { useToasts } from "@components/toasts"
|
||||
import { SerializedApiToken, useApiTokens } from "src/app/hooks/swr/use-api-tokens"
|
||||
import {
|
||||
SerializedApiToken,
|
||||
useApiTokens
|
||||
} from "src/app/hooks/swr/use-api-tokens"
|
||||
import { copyToClipboard } from "src/app/lib/copy-to-clipboard"
|
||||
import { useSession } from "next-auth/react"
|
||||
import { useState } from "react"
|
||||
|
|
|
@ -146,7 +146,7 @@ export const authOptions: NextAuthOptions = {
|
|||
if (config.enable_admin && totalUsers === 1) {
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id: user.id,
|
||||
id: user.id
|
||||
},
|
||||
data: {
|
||||
role: "admin"
|
||||
|
@ -161,7 +161,7 @@ export const authOptions: NextAuthOptions = {
|
|||
},
|
||||
data: {
|
||||
username: user.name,
|
||||
displayName: user.name,
|
||||
displayName: user.name
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ async function handleGet(req: NextApiRequest, res: NextApiResponse<unknown>) {
|
|||
post: {
|
||||
id: post.id,
|
||||
visibility: post.visibility,
|
||||
authorId: post.authorId,
|
||||
authorId: post.authorId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export default async function handle(
|
|||
expiresAt: true,
|
||||
name: true
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
console.log(tokens)
|
||||
|
||||
|
|
Loading…
Reference in a new issue