From a03f1dc2ac25579df30e8cb59d2703110c3e564d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 22:37:41 +0000 Subject: lint: Lint and format the entire repo with the new configs --- apps/mobile/lib/providers.tsx | 12 +++++------- apps/mobile/lib/session.ts | 2 +- apps/mobile/lib/settings.ts | 9 +++++---- apps/mobile/lib/storage-state.ts | 6 +++--- apps/mobile/lib/trpc.ts | 3 ++- apps/mobile/lib/utils.ts | 3 ++- 6 files changed, 18 insertions(+), 17 deletions(-) (limited to 'apps/mobile/lib') diff --git a/apps/mobile/lib/providers.tsx b/apps/mobile/lib/providers.tsx index 1717afb2..036e8ae2 100644 --- a/apps/mobile/lib/providers.tsx +++ b/apps/mobile/lib/providers.tsx @@ -1,13 +1,12 @@ +import { useEffect, useState } from "react"; +import { ToastProvider } from "@/components/ui/Toast"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { httpBatchLink } from "@trpc/client"; -import { useEffect, useState } from "react"; import superjson from "superjson"; import useAppSettings, { getAppSettings } from "./settings"; import { api } from "./trpc"; -import { ToastProvider } from "@/components/ui/Toast"; - function getTRPCClient(address: string) { return api.createClient({ links: [ @@ -16,10 +15,9 @@ function getTRPCClient(address: string) { async headers() { const settings = await getAppSettings(); return { - Authorization: - settings && settings.apiKey - ? `Bearer ${settings.apiKey}` - : undefined, + Authorization: settings?.apiKey + ? `Bearer ${settings.apiKey}` + : undefined, }; }, transformer: superjson, diff --git a/apps/mobile/lib/session.ts b/apps/mobile/lib/session.ts index e2ab245b..071748b9 100644 --- a/apps/mobile/lib/session.ts +++ b/apps/mobile/lib/session.ts @@ -10,7 +10,7 @@ export function useSession() { const logout = useCallback(() => { setSettings({ ...settings, apiKey: undefined }); - }, [settings]); + }, [settings, setSettings]); return { isLoggedIn, diff --git a/apps/mobile/lib/settings.ts b/apps/mobile/lib/settings.ts index 21f40528..13de067e 100644 --- a/apps/mobile/lib/settings.ts +++ b/apps/mobile/lib/settings.ts @@ -4,14 +4,15 @@ import { useStorageState } from "./storage-state"; const SETTING_NAME = "settings"; -export type Settings = { +export interface Settings { apiKey?: string; address: string; -}; +} export default function useAppSettings() { - let [[isLoading, settings], setSettings] = - useStorageState(SETTING_NAME); + const [settingsState, setSettings] = useStorageState(SETTING_NAME); + const [isLoading] = settingsState; + let [, settings] = settingsState; settings ||= { address: "https://demo.hoarder.app", diff --git a/apps/mobile/lib/storage-state.ts b/apps/mobile/lib/storage-state.ts index 4988f0e0..f45ddfe5 100644 --- a/apps/mobile/lib/storage-state.ts +++ b/apps/mobile/lib/storage-state.ts @@ -1,5 +1,5 @@ -import * as SecureStore from "expo-secure-store"; import * as React from "react"; +import * as SecureStore from "expo-secure-store"; type UseStateHook = [[boolean, T | null], (value: T | null) => void]; @@ -8,7 +8,7 @@ function useAsyncState( ): UseStateHook { return React.useReducer( ( - state: [boolean, T | null], + _state: [boolean, T | null], action: T | null = null, ): [boolean, T | null] => [false, action], initialValue, @@ -34,7 +34,7 @@ export function useStorageState(key: string): UseStateHook { setState(null); return null; } - setState(JSON.parse(value)); + setState(JSON.parse(value) as T); }); }, [key]); diff --git a/apps/mobile/lib/trpc.ts b/apps/mobile/lib/trpc.ts index 6b428bd9..9b025df1 100644 --- a/apps/mobile/lib/trpc.ts +++ b/apps/mobile/lib/trpc.ts @@ -1,4 +1,5 @@ -import type { AppRouter } from "@hoarder/trpc/routers/_app"; import { createTRPCReact } from "@trpc/react-query"; +import type { AppRouter } from "@hoarder/trpc/routers/_app"; + export const api = createTRPCReact(); diff --git a/apps/mobile/lib/utils.ts b/apps/mobile/lib/utils.ts index 365058ce..88283f01 100644 --- a/apps/mobile/lib/utils.ts +++ b/apps/mobile/lib/utils.ts @@ -1,4 +1,5 @@ -import { type ClassValue, clsx } from "clsx"; +import type { ClassValue } from "clsx"; +import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { -- cgit v1.2.3-70-g09d2