feat: use eslint-plugin-react

This commit is contained in:
DIYgod
2023-06-08 17:02:09 +01:00
parent 083a7ac106
commit b1405a614b
77 changed files with 471 additions and 304 deletions
+8 -2
View File
@@ -34,13 +34,19 @@ export const Badge = ({
)
}
export const AchievementItem: React.FC<{
export const AchievementItem = ({
group,
layoutId,
size,
characterId,
isOwner,
}: {
group: AchievementSection["groups"][number]
layoutId: string
size?: number
characterId?: number
isOwner: boolean
}> = ({ group, layoutId, size, characterId, isOwner }) => {
}) => {
const date = useDate()
const { t } = useTranslation("common")
+9 -2
View File
@@ -12,14 +12,21 @@ import { cn } from "~/lib/utils"
import type { AchievementSection } from "~/models/site.model"
import { useMintAchievement } from "~/queries/site"
export const AchievementModal: React.FC<{
export const AchievementModal = ({
opened,
setOpened,
group,
layoutId,
isOwner,
characterId,
}: {
opened: boolean
setOpened: (value: boolean) => void
group: AchievementSection["groups"][number]
layoutId: string
isOwner: boolean
characterId?: number
}> = ({ opened, setOpened, group, layoutId, isOwner, characterId }) => {
}) => {
const date = useDate()
const { t } = useTranslation("common")
+5 -2
View File
@@ -10,10 +10,13 @@ import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
import { cn } from "~/lib/utils"
import { useGetGreenfieldId } from "~/queries/site"
export const BlockchainInfo: React.FC<{
export const BlockchainInfo = ({
site,
page,
}: {
site?: ExpandedCharacter
page?: ExpandedNote
}> = ({ site, page }) => {
}) => {
const { t } = useTranslation("common")
const ipfs = (page ? page.metadata?.uri : site?.metadata?.uri) || ""
+9 -9
View File
@@ -8,15 +8,7 @@ import { useTranslation } from "~/lib/i18n/client"
import { cn } from "~/lib/utils"
import { useGetCharacterCard } from "~/queries/site"
export const CharacterCard: React.FC<{
siteId?: string
address?: string
open?: boolean
setButtonLoading?: (loading: boolean) => void
hideFollowButton?: boolean
simple?: boolean
style?: "flat" | "normal"
}> = ({
export const CharacterCard = ({
siteId,
address,
open,
@@ -24,6 +16,14 @@ export const CharacterCard: React.FC<{
hideFollowButton,
simple,
style,
}: {
siteId?: string
address?: string
open?: boolean
setButtonLoading?: (loading: boolean) => void
hideFollowButton?: boolean
simple?: boolean
style?: "flat" | "normal"
}) => {
const date = useDate()
const { t } = useTranslation("common")
+5 -2
View File
@@ -19,10 +19,13 @@ import { CharacterCard } from "~/components/common/CharacterCard"
import { Portal } from "./Portal"
export const CharacterFloatCard: React.FC<{
export const CharacterFloatCard = ({
siteId,
children,
}: {
siteId?: string
children: JSX.Element
}> = ({ siteId, children }) => {
}) => {
const [open, setOpen] = useState(false)
const { x, y, refs, strategy, context } = useFloating({
+9 -2
View File
@@ -9,7 +9,14 @@ import { Button } from "../ui/Button"
import CharacterListItem from "./CharacterListItem"
import { PortalProvider } from "./Portal"
export const CharacterList: React.FC<{
export const CharacterList = ({
open,
setOpen,
hasMore,
loadMore,
list,
title,
}: {
open: boolean
setOpen: (open: boolean) => void
hasMore: boolean
@@ -18,7 +25,7 @@ export const CharacterList: React.FC<{
list: any[]
} | null)[]
title: string
}> = ({ open, setOpen, hasMore, loadMore, list, title }) => {
}) => {
const { t } = useTranslation("common")
const flattenList = list?.reduce(
(acc, cur) => acc.concat(cur?.list || []),
+5 -2
View File
@@ -11,10 +11,13 @@ import { Avatar } from "../ui/Avatar"
import { UniLink } from "../ui/UniLink"
import { FollowingButton } from "./FollowingButton"
const CharacterListItem: React.FC<{
const CharacterListItem = ({
character,
sub,
}: {
character: ExpandedCharacter
sub: any
}> = ({ character, sub }) => {
}) => {
return (
<div className="py-3 flex items-center justify-between space-x-2 text-sm px-5">
<div className="flex flex-1 overflow-hidden space-x-2">
+5 -2
View File
@@ -9,10 +9,13 @@ import { ExpandedNote } from "~/lib/types"
import { cn } from "~/lib/utils"
import { useGetComments } from "~/queries/page"
export const Comment: React.FC<{
export const Comment = ({
page,
className,
}: {
page?: ExpandedNote
className?: string
}> = ({ page, className }) => {
}) => {
const comments = useGetComments({
characterId: page?.characterId,
noteId: page?.noteId,
+8 -8
View File
@@ -17,7 +17,14 @@ import { CodeMirrorEditor } from "../ui/CodeMirror"
import { Input } from "../ui/Input"
import { EmojiPicker } from "./EmojiPicker"
export const CommentInput: React.FC<{
export const CommentInput = ({
characterId,
noteId,
originalCharacterId,
originalNoteId,
onSubmitted,
comment,
}: {
characterId?: number
noteId?: number
originalCharacterId?: number
@@ -26,13 +33,6 @@ export const CommentInput: React.FC<{
comment?: NoteEntity & {
character?: CharacterEntity | null
}
}> = ({
characterId,
noteId,
originalCharacterId,
originalNoteId,
onSubmitted,
comment,
}) => {
const account = useAccountState((s) => s.computed.account)
const commentPage = useCommentPage()
+8 -2
View File
@@ -20,7 +20,13 @@ import { getSiteLink } from "~/lib/helpers"
import { useTranslation } from "~/lib/i18n/client"
import { cn } from "~/lib/utils"
export const CommentItem: React.FC<{
export const CommentItem = ({
comment,
originalCharacterId,
originalNoteId,
depth,
className,
}: {
comment: NoteEntity & {
character?: CharacterEntity | null
}
@@ -28,7 +34,7 @@ export const CommentItem: React.FC<{
originalNoteId?: number
depth: number
className?: string
}> = ({ comment, originalCharacterId, originalNoteId, depth, className }) => {
}) => {
const [replyOpen, setReplyOpen] = useState(false)
const [editOpen, setEditOpen] = useState(false)
+9 -9
View File
@@ -47,15 +47,7 @@ type HeaderLinkType = {
}
)
export const ConnectButton: React.FC<{
left?: boolean
variant?: Variant
variantColor?: VariantColor
size?: "base" | "sm"
hideNotification?: boolean
mobileSimplification?: boolean
hideName?: boolean
}> = ({
export const ConnectButton = ({
left,
variant,
variantColor,
@@ -63,6 +55,14 @@ export const ConnectButton: React.FC<{
hideNotification,
mobileSimplification,
hideName,
}: {
left?: boolean
variant?: Variant
variantColor?: VariantColor
size?: "base" | "sm"
hideNotification?: boolean
mobileSimplification?: boolean
hideName?: boolean
}) => {
let avatarSize
let sizeDecrease
+4 -2
View File
@@ -3,9 +3,11 @@ import { useTranslation } from "react-i18next"
import { useIsDark } from "~/hooks/useDarkMode"
export const EmojiPicker: React.FC<{
export const EmojiPicker = ({
onEmojiSelect,
}: {
onEmojiSelect: (e: any) => void
}> = ({ onEmojiSelect }) => {
}) => {
const ref = useRef<any>()
const isDark = useIsDark()
+7 -2
View File
@@ -10,12 +10,17 @@ import { useTranslation } from "~/lib/i18n/client"
import { getSubscriptionsFromList } from "~/models/site.model"
import { useSubscribeToSites } from "~/queries/site"
export const FollowAllButton: React.FC<{
export const FollowAllButton = ({
size,
characterIds = [],
siteIds = [],
className,
}: {
size?: "sm" | "xl"
characterIds?: number[]
siteIds?: string[]
className?: string
}> = ({ size, characterIds = [], siteIds = [], className }) => {
}) => {
const subscribeToSites = useSubscribeToSites()
const { t } = useTranslation("index")
const account = useAccountState((s) => s.computed.account)
+8 -2
View File
@@ -14,13 +14,19 @@ import {
useUnsubscribeFromSite,
} from "~/queries/site"
export const FollowingButton: React.FC<{
export const FollowingButton = ({
site,
variant,
className,
size,
loadingStatusChange,
}: {
site?: ExpandedCharacter
variant?: Variant
className?: string
size?: "sm" | "xl"
loadingStatusChange?: (status: boolean) => void
}> = ({ site, variant, className, size, loadingStatusChange }) => {
}) => {
const subscribeToSite = useSubscribeToSite()
const unsubscribeFromSite = useUnsubscribeFromSite()
const { t, i18n } = useTranslation("common")
+5 -2
View File
@@ -8,10 +8,13 @@ import {
useGetSiteToSubscriptions,
} from "~/queries/site"
export const FollowingCount: React.FC<{
export const FollowingCount = ({
characterId,
disableList,
}: {
characterId?: number
disableList?: boolean
}> = ({ characterId, disableList }) => {
}) => {
let [isFollowListOpen, setIsFollowListOpen] = useState(false)
let [isToFollowListOpen, setIsToFollowListOpen] = useState(false)
const { t } = useTranslation("common")
+8 -2
View File
@@ -7,13 +7,19 @@ import { Image } from "~/components/ui/Image"
import LogoLottieJSON from "../../../public/assets/logo.json"
export const Logo: React.FC<{
export const Logo = ({
type,
width,
height,
loop,
autoplay,
}: {
type: "svg" | "png" | "lottie"
width?: number
height?: number
loop?: boolean
autoplay?: boolean
}> = ({ type, width, height, loop, autoplay }) => {
}) => {
const ref = useRef<LottieRefCurrentProps>(null)
switch (type) {
+13 -13
View File
@@ -10,19 +10,7 @@ import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
import { cn, scrollTo } from "~/lib/utils"
import { renderPageContent } from "~/markdown"
export const PageContent: React.FC<{
content?: string
className?: string
toc?: boolean
inputRef?: MutableRefObject<HTMLDivElement | null>
onScroll?: (scrollTop: number) => void
onMouseEnter?: () => void
parsedContent?: ReturnType<typeof renderPageContent>
isComment?: boolean
page?: ExpandedNote
site?: ExpandedCharacter
withActions?: boolean
}> = ({
export const PageContent = ({
className,
content,
toc,
@@ -34,6 +22,18 @@ export const PageContent: React.FC<{
page,
site,
withActions,
}: {
content?: string
className?: string
toc?: boolean
inputRef?: MutableRefObject<HTMLDivElement | null>
onScroll?: (scrollTop: number) => void
onMouseEnter?: () => void
parsedContent?: ReturnType<typeof renderPageContent>
isComment?: boolean
page?: ExpandedNote
site?: ExpandedCharacter
withActions?: boolean
}) => {
useCodeCopy()
+7 -2
View File
@@ -6,12 +6,17 @@ import { useTranslation } from "~/lib/i18n/client"
import { ExpandedCharacter } from "~/lib/types"
import { cn } from "~/lib/utils"
export const PatronButton: React.FC<{
export const PatronButton = ({
site,
className,
size,
loadingStatusChange,
}: {
site?: ExpandedCharacter
className?: string
size?: "sm" | "xl"
loadingStatusChange?: (status: boolean) => void
}> = ({ site, className, size, loadingStatusChange }) => {
}) => {
const { t } = useTranslation("common")
const [open, setOpen] = useState(false)
+7 -2
View File
@@ -18,12 +18,17 @@ import { Tabs } from "../ui/Tabs"
import { UniLink } from "../ui/UniLink"
import { CharacterFloatCard } from "./CharacterFloatCard"
export const PatronModal: React.FC<{
export const PatronModal = ({
site,
page,
open,
setOpen,
}: {
site?: ExpandedCharacter
page?: ExpandedNote
open: boolean
setOpen: (open: boolean) => void
}> = ({ site, page, open, setOpen }) => {
}) => {
const { t } = useTranslation("common")
const tipCharacter = useTipCharacter()
const tips = useGetTips(
+5 -2
View File
@@ -7,10 +7,13 @@ import { useCheckComment, useGetComments } from "~/queries/page"
import { Button } from "../ui/Button"
export const ReactionComment: React.FC<{
export const ReactionComment = ({
characterId,
noteId,
}: {
characterId?: number
noteId?: number
}> = ({ characterId, noteId }) => {
}) => {
const { t } = useTranslation("common")
const comments = useGetComments({
+7 -2
View File
@@ -20,12 +20,17 @@ import {
import { AvatarStack } from "../ui/AvatarStack"
import { Button } from "../ui/Button"
export const ReactionLike: React.FC<{
export const ReactionLike = ({
size,
characterId,
noteId,
vertical,
}: {
size?: "sm" | "base"
characterId?: number
noteId?: number
vertical?: boolean
}> = ({ size, characterId, noteId, vertical }) => {
}) => {
const toggleLikePage = useToggleLikePage()
const { t, i18n } = useTranslation("common")
+7 -2
View File
@@ -18,12 +18,17 @@ import { useCheckMint, useGetMints, useMintPage } from "~/queries/page"
import { AvatarStack } from "../ui/AvatarStack"
import { Button } from "../ui/Button"
export const ReactionMint: React.FC<{
export const ReactionMint = ({
size,
noteId,
characterId,
vertical,
}: {
size?: "sm" | "base"
noteId?: number
characterId?: number
vertical?: boolean
}> = ({ size, noteId, characterId, vertical }) => {
}) => {
const mintPage = useMintPage()
const { t, i18n } = useTranslation("common")
+8 -2
View File
@@ -15,13 +15,19 @@ import { useGetTips } from "~/queries/site"
import { AvatarStack } from "../ui/AvatarStack"
import { Button } from "../ui/Button"
export const ReactionTip: React.FC<{
export const ReactionTip = ({
characterId,
noteId,
site,
page,
vertical,
}: {
characterId?: number
noteId?: number
site?: ExpandedCharacter
page?: ExpandedNote
vertical?: boolean
}> = ({ characterId, noteId, site, page, vertical }) => {
}) => {
const { t } = useTranslation("common")
const account = useAccountState((s) => s.computed.account)
+5 -2
View File
@@ -6,10 +6,13 @@ import { useForm } from "react-hook-form"
import { useTranslation } from "~/lib/i18n/client"
import { cn } from "~/lib/utils"
export const SearchInput: React.FC<{
export const SearchInput = ({
noBorder,
onSubmit,
}: {
noBorder?: boolean
onSubmit?: (value?: string) => void
}> = ({ noBorder, onSubmit }) => {
}) => {
const router = useRouter()
const searchParams = useSearchParams()
const { t } = useTranslation("common")
+5 -2
View File
@@ -1,9 +1,12 @@
import { toGateway } from "~/lib/ipfs-parser"
const Style: React.FC<{
const Style = ({
content,
children,
}: {
content?: string
children?: React.ReactNode[]
}> = ({ content, children }) => {
}) => {
let css = content
if (!css && typeof children?.[0] === "string") {
css = children[0].trim()
+1 -3
View File
@@ -4,9 +4,7 @@ import { useEffect, useState } from "react"
import { useDate } from "~/hooks/useDate"
export const Time: React.FC<{
isoString?: string
}> = ({ isoString }) => {
export const Time = ({ isoString }: { isoString?: string }) => {
const date = useDate()
const [isMounted, setIsMounted] = useState(false)
+1 -3
View File
@@ -16,9 +16,7 @@ const icons: {
},
}
export const Titles: React.FC<{
characterId?: number
}> = ({ characterId }) => {
export const Titles = ({ characterId }: { characterId?: number }) => {
if (!characterId) {
return null
}