From 46b78eaac30be26fe40520e97786563344af8403 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 30 Mar 2024 16:26:16 +0000 Subject: format: Add missing lint and format, and format the entire repo --- apps/mobile/app.json | 5 +-- apps/mobile/app/dashboard/(tabs)/_layout.tsx | 4 +- apps/mobile/app/dashboard/(tabs)/index.tsx | 13 +++--- apps/mobile/app/dashboard/(tabs)/lists.tsx | 8 ++-- apps/mobile/app/dashboard/(tabs)/search.tsx | 2 +- apps/mobile/app/dashboard/(tabs)/settings.tsx | 2 +- apps/mobile/app/dashboard/archive.tsx | 7 +++- apps/mobile/app/dashboard/favourites.tsx | 2 +- apps/mobile/app/dashboard/lists/[slug].tsx | 2 +- apps/mobile/app/dashboard/tags/[slug].tsx | 2 +- apps/mobile/app/index.tsx | 18 ++++----- apps/mobile/app/signin.tsx | 4 +- apps/mobile/components/Logo.tsx | 17 ++++---- apps/mobile/components/bookmarks/BookmarkList.tsx | 8 ++-- apps/mobile/components/ui/PageTitle.tsx | 2 +- apps/mobile/index.ts | 2 +- apps/mobile/lib/upload.ts | 48 ++++++++++++----------- apps/mobile/package.json | 1 + apps/mobile/tailwind.config.ts | 1 + 19 files changed, 74 insertions(+), 74 deletions(-) (limited to 'apps/mobile') diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 028286e4..fec59de5 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -39,10 +39,7 @@ "NSExtensionActivationSupportsMovieWithMaxCount": 0, "NSExtensionActivationSupportsText": true }, - "androidIntentFilters": [ - "text/*", - "image/*" - ] + "androidIntentFilters": ["text/*", "image/*"] } ], "expo-secure-store", diff --git a/apps/mobile/app/dashboard/(tabs)/_layout.tsx b/apps/mobile/app/dashboard/(tabs)/_layout.tsx index fe40215e..7967b5c6 100644 --- a/apps/mobile/app/dashboard/(tabs)/_layout.tsx +++ b/apps/mobile/app/dashboard/(tabs)/_layout.tsx @@ -1,8 +1,8 @@ import React, { useEffect } from "react"; +import { Platform } from "react-native"; +import * as NavigationBar from "expo-navigation-bar"; import { Tabs } from "expo-router"; import { ClipboardList, Home, Search, Settings } from "lucide-react-native"; -import { Platform } from "react-native"; -import * as NavigationBar from 'expo-navigation-bar'; export default function TabLayout() { useEffect(() => { diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsx index 804eb0b5..5dccc845 100644 --- a/apps/mobile/app/dashboard/(tabs)/index.tsx +++ b/apps/mobile/app/dashboard/(tabs)/index.tsx @@ -3,21 +3,21 @@ import * as Haptics from "expo-haptics"; import * as ImagePicker from "expo-image-picker"; import { useRouter } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import PageTitle from "@/components/ui/PageTitle"; +import { useToast } from "@/components/ui/Toast"; import useAppSettings from "@/lib/settings"; import { useUploadAsset } from "@/lib/upload"; import { MenuView } from "@react-native-menu/menu"; import { SquarePen } from "lucide-react-native"; -import { useToast } from "@/components/ui/Toast"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; function HeaderRight() { - const {toast} = useToast(); + const { toast } = useToast(); const router = useRouter(); const { settings } = useAppSettings(); const { uploadAsset } = useUploadAsset(settings, { onError: (e) => { - toast({message: e, variant: "destructive"}); + toast({ message: e, variant: "destructive" }); }, }); return ( @@ -69,7 +69,10 @@ function HeaderRight() { shouldOpenOnLongPress={false} > - Haptics.selectionAsync()} /> + Haptics.selectionAsync()} + /> ); diff --git a/apps/mobile/app/dashboard/(tabs)/lists.tsx b/apps/mobile/app/dashboard/(tabs)/lists.tsx index 0350ebd2..767b9256 100644 --- a/apps/mobile/app/dashboard/(tabs)/lists.tsx +++ b/apps/mobile/app/dashboard/(tabs)/lists.tsx @@ -1,10 +1,10 @@ import { useEffect, useState } from "react"; import { FlatList, Pressable, Text, View } from "react-native"; import { Link } from "expo-router"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; import { ChevronRight } from "lucide-react-native"; -import PageTitle from "@/components/ui/PageTitle"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Lists() { const [refreshing, setRefreshing] = useState(false); @@ -51,9 +51,7 @@ export default function Lists() { return ( - } + ListHeaderComponent={} contentContainerStyle={{ gap: 5, }} diff --git a/apps/mobile/app/dashboard/(tabs)/search.tsx b/apps/mobile/app/dashboard/(tabs)/search.tsx index bcaee5af..0a4dcbfd 100644 --- a/apps/mobile/app/dashboard/(tabs)/search.tsx +++ b/apps/mobile/app/dashboard/(tabs)/search.tsx @@ -1,13 +1,13 @@ import { useState } from "react"; import { View } from "react-native"; import BookmarkList from "@/components/bookmarks/BookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import { Input } from "@/components/ui/Input"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; import { keepPreviousData } from "@tanstack/react-query"; import { useDebounce } from "use-debounce"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Search() { const [search, setSearch] = useState(""); diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx index 0dbf7da6..c2db2846 100644 --- a/apps/mobile/app/dashboard/(tabs)/settings.tsx +++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx @@ -1,9 +1,9 @@ import { Text, View } from "react-native"; import { Button } from "@/components/ui/Button"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import PageTitle from "@/components/ui/PageTitle"; import { useSession } from "@/lib/session"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function Dashboard() { const { logout } = useSession(); diff --git a/apps/mobile/app/dashboard/archive.tsx b/apps/mobile/app/dashboard/archive.tsx index e622a3e4..2fe5d274 100644 --- a/apps/mobile/app/dashboard/archive.tsx +++ b/apps/mobile/app/dashboard/archive.tsx @@ -1,11 +1,14 @@ import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; -import PageTitle from "@/components/ui/PageTitle"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; export default function Archive() { return ( - } /> + } + /> ); } diff --git a/apps/mobile/app/dashboard/favourites.tsx b/apps/mobile/app/dashboard/favourites.tsx index 213cc918..abda5cfa 100644 --- a/apps/mobile/app/dashboard/favourites.tsx +++ b/apps/mobile/app/dashboard/favourites.tsx @@ -1,6 +1,6 @@ import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; -import PageTitle from "@/components/ui/PageTitle"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import PageTitle from "@/components/ui/PageTitle"; export default function Favourites() { return ( diff --git a/apps/mobile/app/dashboard/lists/[slug].tsx b/apps/mobile/app/dashboard/lists/[slug].tsx index c0b86a0f..d42cc653 100644 --- a/apps/mobile/app/dashboard/lists/[slug].tsx +++ b/apps/mobile/app/dashboard/lists/[slug].tsx @@ -1,10 +1,10 @@ import { View } from "react-native"; import { Stack, useLocalSearchParams } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function ListView() { const { slug } = useLocalSearchParams(); diff --git a/apps/mobile/app/dashboard/tags/[slug].tsx b/apps/mobile/app/dashboard/tags/[slug].tsx index 26aa47ec..ea1ef63d 100644 --- a/apps/mobile/app/dashboard/tags/[slug].tsx +++ b/apps/mobile/app/dashboard/tags/[slug].tsx @@ -1,10 +1,10 @@ import { View } from "react-native"; import { Stack, useLocalSearchParams } from "expo-router"; import UpdatingBookmarkList from "@/components/bookmarks/UpdatingBookmarkList"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; import PageTitle from "@/components/ui/PageTitle"; import { api } from "@/lib/trpc"; -import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; export default function TagView() { const { slug } = useLocalSearchParams(); diff --git a/apps/mobile/app/index.tsx b/apps/mobile/app/index.tsx index 235b19e4..dbbea97e 100644 --- a/apps/mobile/app/index.tsx +++ b/apps/mobile/app/index.tsx @@ -1,16 +1,16 @@ -import { useIsLoggedIn } from "@/lib/session"; import { Redirect } from "expo-router"; import FullPageSpinner from "@/components/ui/FullPageSpinner"; +import { useIsLoggedIn } from "@/lib/session"; export default function App() { const isLoggedIn = useIsLoggedIn(); - if (isLoggedIn === undefined) { - // Wait until it's loaded - return ; - } else if (isLoggedIn) { - return - } else { - return - } + if (isLoggedIn === undefined) { + // Wait until it's loaded + return ; + } else if (isLoggedIn) { + return ; + } else { + return ; + } } diff --git a/apps/mobile/app/signin.tsx b/apps/mobile/app/signin.tsx index 2255424e..8402bd43 100644 --- a/apps/mobile/app/signin.tsx +++ b/apps/mobile/app/signin.tsx @@ -69,9 +69,7 @@ export default function Signin() { value={settings.address} autoCapitalize="none" keyboardType="url" - onChangeText={(e) => - setSettings({ ...settings, address: e }) - } + onChangeText={(e) => setSettings({ ...settings, address: e })} /> diff --git a/apps/mobile/components/Logo.tsx b/apps/mobile/components/Logo.tsx index 9fdd1083..ba949ed4 100644 --- a/apps/mobile/components/Logo.tsx +++ b/apps/mobile/components/Logo.tsx @@ -1,11 +1,9 @@ -import * as React from "react" -import type { SvgProps} from "react-native-svg"; -import Svg, { Path } from "react-native-svg" +import type { SvgProps } from "react-native-svg"; +import * as React from "react"; +import Svg, { Path } from "react-native-svg"; + const Logo = (props: SvgProps) => ( - + ( transform="translate(-173 -247)" /> -) -export default Logo - +); +export default Logo; diff --git a/apps/mobile/components/bookmarks/BookmarkList.tsx b/apps/mobile/components/bookmarks/BookmarkList.tsx index 9176f66d..7477992d 100644 --- a/apps/mobile/components/bookmarks/BookmarkList.tsx +++ b/apps/mobile/components/bookmarks/BookmarkList.tsx @@ -16,11 +16,11 @@ export default function BookmarkList({ isRefreshing, }: { bookmarks: ZBookmark[]; - onRefresh: () => void, - isRefreshing: boolean, - fetchNextPage?: () => void, + onRefresh: () => void; + isRefreshing: boolean; + fetchNextPage?: () => void; header?: React.ReactElement; - isFetchingNextPage?: boolean, + isFetchingNextPage?: boolean; }) { const flatListRef = useRef(null); useScrollToTop(flatListRef); diff --git a/apps/mobile/components/ui/PageTitle.tsx b/apps/mobile/components/ui/PageTitle.tsx index 1d1a8400..57b19e7d 100644 --- a/apps/mobile/components/ui/PageTitle.tsx +++ b/apps/mobile/components/ui/PageTitle.tsx @@ -1,4 +1,4 @@ -import {Text} from "react-native"; +import { Text } from "react-native"; export default function PageTitle({ title }: { title: string }) { return {title}; diff --git a/apps/mobile/index.ts b/apps/mobile/index.ts index 5b834183..80d3d998 100644 --- a/apps/mobile/index.ts +++ b/apps/mobile/index.ts @@ -1 +1 @@ -import 'expo-router/entry'; +import "expo-router/entry"; diff --git a/apps/mobile/lib/upload.ts b/apps/mobile/lib/upload.ts index d511becc..56b2c7a5 100644 --- a/apps/mobile/lib/upload.ts +++ b/apps/mobile/lib/upload.ts @@ -1,38 +1,40 @@ import { useMutation } from "@tanstack/react-query"; +import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; +import { + zUploadErrorSchema, + zUploadResponseSchema, +} from "@hoarder/trpc/types/uploads"; + import type { Settings } from "./settings"; import { api } from "./trpc"; -import type { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import { zUploadResponseSchema, zUploadErrorSchema } from "@hoarder/trpc/types/uploads"; export function useUploadAsset( settings: Settings, - options: { onSuccess?: (bookmark: ZBookmark) => void; onError?: (e: string) => void }, + options: { + onSuccess?: (bookmark: ZBookmark) => void; + onError?: (e: string) => void; + }, ) { const invalidateAllBookmarks = api.useUtils().bookmarks.getBookmarks.invalidate; - const { - mutate: createBookmark, - isPending: isCreatingBookmark, - } = api.bookmarks.createBookmark.useMutation({ - onSuccess: (d) => { - invalidateAllBookmarks(); - if (options.onSuccess) { - options.onSuccess(d); - } - }, - onError: (e) => { - if (options.onError) { - options.onError(e.message); - } - }, - }); + const { mutate: createBookmark, isPending: isCreatingBookmark } = + api.bookmarks.createBookmark.useMutation({ + onSuccess: (d) => { + invalidateAllBookmarks(); + if (options.onSuccess) { + options.onSuccess(d); + } + }, + onError: (e) => { + if (options.onError) { + options.onError(e.message); + } + }, + }); - const { - mutate: uploadAsset, - isPending: isUploading, - } = useMutation({ + const { mutate: uploadAsset, isPending: isUploading } = useMutation({ mutationFn: async (file: { type: string; name: string; uri: string }) => { const formData = new FormData(); // @ts-expect-error This is a valid api in react native diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 15b2057b..04fd8821 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -8,6 +8,7 @@ "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", + "format": "prettier .", "lint": "eslint .", "typecheck": "tsc --noEmit" }, diff --git a/apps/mobile/tailwind.config.ts b/apps/mobile/tailwind.config.ts index 9eb1eb4a..8d6f3785 100644 --- a/apps/mobile/tailwind.config.ts +++ b/apps/mobile/tailwind.config.ts @@ -1,4 +1,5 @@ import type { Config } from "tailwindcss"; + import base from "@hoarder/tailwind-config/native"; const config = { -- cgit v1.2.3-70-g09d2