diff --git a/package.json b/package.json index 2bcacb8..e6bb83c 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ "preview": "vite preview", "tsc": "tsc --noEmit", "lint": "run-p tsc lint:*", - "lint:format": "prettier --check --loglevel warn src/**/*.{js,jsx,ts,tsx,css}", + "lint:format": "prettier --check --log-level warn src/**/*.{js,jsx,ts,tsx,css}", "lint:js": "eslint --max-warnings 0 src/", "fix": "run-s fix:*", - "fix:format": "prettier --write --loglevel warn src/**/*.{js,jsx,ts,tsx,css}", + "fix:format": "prettier --write --log-level warn src/**/*.{js,jsx,ts,tsx,css}", "fix:js": "eslint --fix src/", "exec-ts": "node --loader esbuild-register/loader -r esbuild-register" }, @@ -56,5 +56,8 @@ "typescript": "^5.3.3", "vite": "^4.4.9", "vite-plugin-babel": "^1.2.0" + }, + "prettier": { + "printWidth": 120 } } diff --git a/src/components/CopyNeventsButton.tsx b/src/components/CopyNeventsButton.tsx index 61485cf..91e2061 100644 --- a/src/components/CopyNeventsButton.tsx +++ b/src/components/CopyNeventsButton.tsx @@ -1,23 +1,13 @@ import { CopyIcon } from "@chakra-ui/icons"; -import { - IconButton, - IconButtonProps, - Tooltip, - useClipboard, -} from "@chakra-ui/react"; +import { IconButton, IconButtonProps, Tooltip, useClipboard } from "@chakra-ui/react"; import { neventEncode } from "nostr-tools/nip19"; import { clearPostSelection, useSelectedPostIds } from "../states/Posts"; -type CopyNeventsButtonProps = Omit< - IconButtonProps, - "aria-label" | "icon" | "onClick" ->; +type CopyNeventsButtonProps = Omit; export const CopyNeventsButton: React.FC = (props) => { const selectedIds = useSelectedPostIds("created-at-asc"); - const lineSeparatedIds = selectedIds - .map((id) => neventEncode({ id })) - .join("\n"); + const lineSeparatedIds = selectedIds.map((id) => neventEncode({ id })).join("\n"); const { onCopy } = useClipboard(lineSeparatedIds); return selectedIds.length > 0 ? ( diff --git a/src/components/CopyToClipboardButton.tsx b/src/components/CopyToClipboardButton.tsx index e4da493..a12e3d7 100644 --- a/src/components/CopyToClipboardButton.tsx +++ b/src/components/CopyToClipboardButton.tsx @@ -1,10 +1,5 @@ import { CheckIcon, CopyIcon } from "@chakra-ui/icons"; -import { - Box, - PlacementWithLogical, - Tooltip, - useClipboard, -} from "@chakra-ui/react"; +import { Box, PlacementWithLogical, Tooltip, useClipboard } from "@chakra-ui/react"; type TooltipProps = { label: string; @@ -17,27 +12,16 @@ type CopyToClipboardButtonProps = { children?: React.ReactNode; }; -export const CopyToClipboardButton: React.FC = ({ - valueToCopy, - tooltip, - children, -}) => { +export const CopyToClipboardButton: React.FC = ({ valueToCopy, tooltip, children }) => { const { onCopy, hasCopied } = useClipboard(valueToCopy, 500); const body = ( - {hasCopied ? ( - - ) : ( - children ?? - )} + {hasCopied ? : children ?? } ); return tooltip ? ( - + {body} ) : ( diff --git a/src/components/HiddenMenu.tsx b/src/components/HiddenMenu.tsx index 8830b8d..0681e97 100644 --- a/src/components/HiddenMenu.tsx +++ b/src/components/HiddenMenu.tsx @@ -1,12 +1,4 @@ -import { - Button, - Menu, - MenuButton, - MenuGroup, - MenuItemOption, - MenuList, - MenuOptionGroup, -} from "@chakra-ui/react"; +import { Button, Menu, MenuButton, MenuGroup, MenuItemOption, MenuList, MenuOptionGroup } from "@chakra-ui/react"; import { useAtom } from "jotai"; import { PostDisplayMode, postDisplayModeAtom } from "../states/Config"; @@ -27,9 +19,7 @@ export const HiddenMenu = () => { onChange={(v) => setPostDispMode(v as PostDisplayMode)} > Normal - - Pubkey Hex Color Icon - + Pubkey Hex Color Icon diff --git a/src/components/LoginPane.tsx b/src/components/LoginPane.tsx index 62c2b15..9149290 100644 --- a/src/components/LoginPane.tsx +++ b/src/components/LoginPane.tsx @@ -1,12 +1,4 @@ -import { - Alert, - AlertIcon, - AlertTitle, - Button, - Center, - HStack, - Text, -} from "@chakra-ui/react"; +import { Alert, AlertIcon, AlertTitle, Button, Center, HStack, Text } from "@chakra-ui/react"; import { useAtomValue, useSetAtom } from "jotai"; import { nip07ExtAtom } from "../states/Nip07Ext"; import { myPubkeyAtom } from "../states/Profiles"; diff --git a/src/components/Post.tsx b/src/components/Post.tsx index e614ee9..ea74f4f 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -1,14 +1,5 @@ import { ExternalLinkIcon } from "@chakra-ui/icons"; -import { - Avatar, - Box, - Card, - Grid, - GridItem, - HStack, - Text, - Tooltip, -} from "@chakra-ui/react"; +import { Avatar, Box, Card, Grid, GridItem, HStack, Text, Tooltip } from "@chakra-ui/react"; import { format, fromUnixTime } from "date-fns"; import { atom, useAtom, useAtomValue } from "jotai"; import { neventEncode, noteEncode, npubEncode } from "nostr-tools/nip19"; @@ -32,9 +23,7 @@ type PostProps = { export const Post: React.FC = ({ id }) => { const post = usePost(id); const [isSelected, toggleSelection] = useAtom(postSelectionAtomFamily(id)); - const profile = useAtomValue( - post ? profileAtomFamily(post.pubkey) : undefAtom - ); + const profile = useAtomValue(post ? profileAtomFamily(post.pubkey) : undefAtom); const noteId = post?.id ? noteEncode(post.id) : undefined; const nevent = post?.id ? neventEncode({ id: post.id }) : undefined; @@ -70,9 +59,7 @@ export const Post: React.FC = ({ id }) => { {post.content} - - {format(fromUnixTime(post.created_at), "M/d HH:mm:ss")} - + {format(fromUnixTime(post.created_at), "M/d HH:mm:ss")} @@ -154,11 +141,7 @@ const OpenViaNosTxButton: React.FC = ({ noteId }) => { return ( - + diff --git a/src/components/PostTimeline.tsx b/src/components/PostTimeline.tsx index 3264870..49df2df 100644 --- a/src/components/PostTimeline.tsx +++ b/src/components/PostTimeline.tsx @@ -2,10 +2,7 @@ import { LinkIcon } from "@chakra-ui/icons"; import { Box, Flex, HStack, Text } from "@chakra-ui/react"; import { useAtomValue } from "jotai"; import { PostQuery, usePostIds } from "../states/Posts"; -import { - useOngoingWaybackQuery, - waybackQueryInputsAtom, -} from "../states/WaybackQuery"; +import { useOngoingWaybackQuery, waybackQueryInputsAtom } from "../states/WaybackQuery"; import { WaybackQuery, WaybackQueryInputs } from "../types/WaybackQuery"; import { CopyNeventsButton } from "./CopyNeventsButton"; import { CopyToClipboardButton } from "./CopyToClipboardButton"; @@ -15,9 +12,7 @@ type PostTimelineProps = { postQuery: PostQuery; }; -const shareLinkFromQueryInputs = ( - qin: WaybackQueryInputs | undefined -): string => { +const shareLinkFromQueryInputs = (qin: WaybackQueryInputs | undefined): string => { const url = new URL(location.href); if (qin) { url.search = WaybackQueryInputs.toURLQuery(qin); @@ -54,14 +49,7 @@ export const PostTimeline: React.FC = ({ postQuery }) => { {postIds.map((id) => ( ))} - + ); }; diff --git a/src/components/WaybackQueryForm.tsx b/src/components/WaybackQueryForm.tsx index 3b6648b..f23ea18 100644 --- a/src/components/WaybackQueryForm.tsx +++ b/src/components/WaybackQueryForm.tsx @@ -18,14 +18,7 @@ import { VStack, } from "@chakra-ui/react"; import { SingleDatepicker } from "chakra-dayzed-datepicker"; -import { - addMinutes, - differenceInMilliseconds, - format, - getUnixTime, - startOfMinute, - subHours, -} from "date-fns"; +import { addMinutes, differenceInMilliseconds, format, getUnixTime, startOfMinute, subHours } from "date-fns"; import { useSetAtom } from "jotai"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { waybackQueryInputsAtom } from "../states/WaybackQuery"; @@ -35,9 +28,7 @@ import { WaybackQuery, WaybackQueryInputs } from "../types/WaybackQuery"; const getNow = () => new Date(); const jaDayNames = "日月火水木金土".split(""); -const jaMonthNames = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map( - (i) => `${i}月` -); +const jaMonthNames = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((i) => `${i}月`); const formatQueryFromInputs = (i: WaybackQueryInputs | undefined): string => { if (i === undefined) { @@ -85,11 +76,7 @@ export const WaybackQueryForm: React.FC = () => { {formatQueryFromInputs(queryInputs)} -