From 214127af43680e9617ebe6dafcaf65942d9db0f4 Mon Sep 17 00:00:00 2001 From: Timothy Miller Date: Tue, 7 Nov 2023 23:12:35 -0500 Subject: [PATCH] Fixed lint warnings --- .prettierrc | 7 ------- apps/next/package.json | 2 +- apps/next/pages/404.tsx | 4 ++-- apps/next/pages/500.tsx | 4 ++-- apps/next/pages/_app.tsx | 4 ++-- apps/next/pages/_offline.tsx | 4 ++-- apps/next/pages/password-reset/index.tsx | 2 +- .../pages/password-reset/update-password/index.tsx | 2 +- apps/next/tamagui.config.ts | 3 --- apps/next/utils/auth.ts | 4 ++-- biome.json | 9 ++++++++- package.json | 8 ++++---- packages/api/drizzle.config.ts | 4 ++-- packages/api/src/context.ts | 2 +- packages/api/src/db/schema.ts | 4 ++-- packages/api/src/db/studio.ts | 6 +++--- packages/api/src/router.ts | 6 +++--- packages/api/src/routes/auth.ts | 2 +- packages/api/src/routes/cars.ts | 2 +- packages/api/src/routes/hello.ts | 2 +- packages/api/src/routes/user.ts | 4 ++-- packages/api/src/trpc.ts | 4 ++-- packages/api/src/worker.ts | 6 +++--- packages/app/features/data-fetching/screen.tsx | 2 +- packages/app/features/home/screen.tsx | 10 +++++----- packages/app/features/password-reset/screen.tsx | 2 +- .../password-reset/update-password/screen.tsx | 2 +- packages/app/features/sign-in/SignUpSignIn.tsx | 6 +++--- packages/app/features/sign-in/screen.native.tsx | 14 +++++++------- packages/app/features/sign-in/screen.tsx | 8 ++++---- packages/app/features/sign-up/screen.native.tsx | 14 +++++++------- packages/app/features/sign-up/screen.tsx | 8 ++++---- packages/app/package.json | 4 ++-- packages/app/provider/auth/index.tsx | 4 ++-- packages/app/provider/auth/index.web.tsx | 4 ++-- packages/app/provider/index.tsx | 12 ++++++------ packages/app/provider/tamagui/index.tsx | 2 +- packages/app/provider/theme/index.tsx | 14 +++++++------- packages/app/provider/theme/index.web.tsx | 2 +- packages/app/utils/env.ts | 2 +- .../app/utils/supabase/hooks/useAuthRedirect.ts | 4 ++-- .../utils/supabase/hooks/useAuthRedirect.web.ts | 2 +- .../supabase/hooks/useSessionContext.native.ts | 2 +- packages/app/utils/trpc/index.tsx | 6 +++--- packages/app/utils/trpc/index.web.ts | 4 ++-- packages/ui/src/MyComponent.tsx | 2 +- packages/ui/src/PasswordReset.tsx | 6 +++--- packages/ui/src/ThemeToggle.tsx | 4 ++-- packages/ui/src/cars/CarListItem.tsx | 4 ++-- packages/ui/src/libs/number.ts | 2 +- packages/ui/src/list/index.tsx | 2 +- packages/ui/src/list/index.web.tsx | 4 ++-- packages/ui/src/tamagui.config.ts | 4 ++-- 53 files changed, 124 insertions(+), 127 deletions(-) delete mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 991770add..000000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "trailingComma": "es5", - "semi": false, - "singleQuote": true, - "arrowParens": "always", - "printWidth": 100 -} diff --git a/apps/next/package.json b/apps/next/package.json index 70608fe95..9c0ee17dd 100644 --- a/apps/next/package.json +++ b/apps/next/package.json @@ -18,9 +18,9 @@ "@tsndr/cloudflare-worker-jwt": "^2.2.5", "app": "*", "million": "2.6.4", - "pattycake": "^0.0.2", "next": "14.0.1", "next-superjson-plugin": "^0.5.9", + "pattycake": "^0.0.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-native": "^0.72.6", diff --git a/apps/next/pages/404.tsx b/apps/next/pages/404.tsx index 8d21246f0..b501d1b74 100644 --- a/apps/next/pages/404.tsx +++ b/apps/next/pages/404.tsx @@ -1,8 +1,8 @@ import { Anchor, Button, H1, Paragraph, XStack, YStack } from '@t4/ui' +import { RotateCw } from '@tamagui/lucide-icons' import Head from 'next/head' import { useRouter } from 'next/router' import { SolitoImage } from 'solito/image' -import { RotateCw } from '@tamagui/lucide-icons' const customerCareEmail = process.env.NEXT_PUBLIC_CUSTOMER_CARE_EMAIL @@ -20,7 +20,7 @@ export default function Page() { Your changes were saved, but we could not load the page you requested because it was not found on our server. Please try connecting again. If the issue keeps happening,{' '} - + contact Customer Care . diff --git a/apps/next/pages/500.tsx b/apps/next/pages/500.tsx index e5b848287..75ca778b8 100644 --- a/apps/next/pages/500.tsx +++ b/apps/next/pages/500.tsx @@ -1,8 +1,8 @@ import { Anchor, Button, H1, Paragraph, XStack, YStack } from '@t4/ui' +import { RotateCw } from '@tamagui/lucide-icons' import Head from 'next/head' import { useRouter } from 'next/router' import { SolitoImage } from 'solito/image' -import { RotateCw } from '@tamagui/lucide-icons' const customerCareEmail = process.env.NEXT_PUBLIC_CUSTOMER_CARE_EMAIL @@ -20,7 +20,7 @@ export default function Page() { Your changes were saved, but we could not connect to the server due to a technical issue on our end. Please try connecting again. If the issue keeps happening,{' '} - + contact Customer Care . diff --git a/apps/next/pages/_app.tsx b/apps/next/pages/_app.tsx index 5c5afc526..39a31ca9e 100644 --- a/apps/next/pages/_app.tsx +++ b/apps/next/pages/_app.tsx @@ -1,15 +1,15 @@ if (typeof requestAnimationFrame === 'undefined') { - globalThis['requestAnimationFrame'] = setImmediate + globalThis.requestAnimationFrame = setImmediate } import '@tamagui/core/reset.css' import '@tamagui/font-inter/css/400.css' import '@tamagui/font-inter/css/700.css' +import type { Session } from '@supabase/supabase-js' import { Provider } from 'app/provider' import { trpc } from 'app/utils/trpc/index.web' import Head from 'next/head' import type { SolitoAppProps } from 'solito' -import type { Session } from '@supabase/supabase-js' if (process.env.NODE_ENV === 'production') { require('../public/tamagui.css') diff --git a/apps/next/pages/_offline.tsx b/apps/next/pages/_offline.tsx index f24ac4641..4350d3f53 100644 --- a/apps/next/pages/_offline.tsx +++ b/apps/next/pages/_offline.tsx @@ -1,8 +1,8 @@ import { Anchor, Button, H1, Paragraph, XStack, YStack } from '@t4/ui' +import { RotateCw } from '@tamagui/lucide-icons' import Head from 'next/head' import { useRouter } from 'next/router' import { SolitoImage } from 'solito/image' -import { RotateCw } from '@tamagui/lucide-icons' const customerCareEmail = process.env.NEXT_PUBLIC_CUSTOMER_CARE_EMAIL @@ -20,7 +20,7 @@ export default function Page() { Your changes were saved, but we could not connect to the server because you are offline. Please try connecting again. If the issue keeps happening,{' '} - + contact Customer Care . diff --git a/apps/next/pages/password-reset/index.tsx b/apps/next/pages/password-reset/index.tsx index 884f49236..fd74cf65c 100644 --- a/apps/next/pages/password-reset/index.tsx +++ b/apps/next/pages/password-reset/index.tsx @@ -1,5 +1,5 @@ -import Head from 'next/head' import { PasswordResetScreen } from 'app/features/password-reset/screen' +import Head from 'next/head' export default function Page() { return ( diff --git a/apps/next/pages/password-reset/update-password/index.tsx b/apps/next/pages/password-reset/update-password/index.tsx index 120a76e20..46c1450af 100644 --- a/apps/next/pages/password-reset/update-password/index.tsx +++ b/apps/next/pages/password-reset/update-password/index.tsx @@ -1,5 +1,5 @@ -import Head from 'next/head' import { UpdatePasswordScreen } from 'app/features/password-reset/update-password/screen' +import Head from 'next/head' export default function Page() { return ( diff --git a/apps/next/tamagui.config.ts b/apps/next/tamagui.config.ts index 087af0e53..88313d938 100644 --- a/apps/next/tamagui.config.ts +++ b/apps/next/tamagui.config.ts @@ -1,6 +1,3 @@ -// don't import from here, that's handled already -// instead this is just setting types for this folder - import { config } from '@t4/ui' type Conf = typeof config diff --git a/apps/next/utils/auth.ts b/apps/next/utils/auth.ts index fc5d07608..2dcf124f1 100644 --- a/apps/next/utils/auth.ts +++ b/apps/next/utils/auth.ts @@ -1,7 +1,7 @@ -import jwt from '@tsndr/cloudflare-worker-jwt' -import type { GetServerSidePropsContext } from 'next/types' import { Session, createPagesServerClient } from '@supabase/auth-helpers-nextjs' +import jwt from '@tsndr/cloudflare-worker-jwt' import { secureCookieOptions } from 'app/utils/supabase/cookies' +import type { GetServerSidePropsContext } from 'next/types' export const verifyToken = async (token: string): Promise => { try { diff --git a/biome.json b/biome.json index 3edd9ec55..8f872bb8c 100644 --- a/biome.json +++ b/biome.json @@ -5,7 +5,7 @@ }, "files": { "ignoreUnknown": true, - "ignore": ["**/node_modules/**", "**/dist/**", "**/build/**", "**/ios/**", "**/.git/**", "**/.vscode/**", "**/.android/**", "**/.DS_Store/**", "**/Thumbs.db/**", "**/.tamagui*", "**/.next*"] + "ignore": ["**/.wrangler/**", "**/tamagui.css", "**/workbox*.js", "**/service-worker.js", "**/fallback*.js", "**/node_modules/**", "**/dist/**", "**/build/**", "**/ios/**", "**/.git/**", "**/.vscode/**", "**/.android/**", "**/.DS_Store/**", "**/Thumbs.db/**", "**/.tamagui*", "**/.next*"] }, "linter": { "enabled": true, @@ -13,6 +13,13 @@ "recommended": true, "style": { "useTemplate": "warn" + }, + "suspicious": { + "noEmptyInterface": "off", + "noExplicitAny": "off" + }, + "security": { + "noDangerouslySetInnerHtml": "off" } } }, diff --git a/package.json b/package.json index fda914d52..68b61976c 100755 --- a/package.json +++ b/package.json @@ -27,7 +27,9 @@ "check-deps": "check-dependency-version-consistency .", "check-types": "tsc --noEmit", "format": "bunx @biomejs/biome format --write ./packages ./apps", - "fix": "manypkg fix", + "lint": "bunx @biomejs/biome lint ./packages ./apps", + "fix": "bunx @biomejs/biome check --apply-unsafe ./packages ./apps", + "deps:fix": "manypkg fix", "postinstall": "bun run build && bun ./.github/scripts/env.ts && bun check-deps && bun format", "clean": "git clean -xdf node_modules && rm bun.lockb", "clean:all": "npm-run-all clean" @@ -38,6 +40,7 @@ ], "dependencies": { "@babel/runtime": "^7.23.2", + "@biomejs/biome": "1.3.3", "@manypkg/cli": "^0.21.0", "@nderscore/tamagui-typescript-plugin": "^0.6.0", "@supabase/supabase-js": "^2.38.4", @@ -46,8 +49,5 @@ "react-native-url-polyfill": "^2.0.0", "typescript": "^5.2.2", "workerd": "1.20231030.0" - }, - "devDependencies": { - "@biomejs/biome": "1.3.3" } } diff --git a/packages/api/drizzle.config.ts b/packages/api/drizzle.config.ts index 9908f9326..981f23b57 100644 --- a/packages/api/drizzle.config.ts +++ b/packages/api/drizzle.config.ts @@ -1,5 +1,5 @@ -import type { Config } from 'drizzle-kit' import * as dotenv from 'dotenv' +import type { Config } from 'drizzle-kit' dotenv.config({ path: './.dev.vars' }) const DATABASE_ID = process.env.DATABASE_ID @@ -10,7 +10,7 @@ if (DATABASE_ID === undefined) { export default { driver: 'better-sqlite', dbCredentials: { - url: './.wrangler/state/v3/d1/' + DATABASE_ID + '/db.sqlite', + url: `./.wrangler/state/v3/d1/${DATABASE_ID}/db.sqlite`, }, schema: './src/db/schema.ts', out: './migrations', diff --git a/packages/api/src/context.ts b/packages/api/src/context.ts index 7024acfdc..09522ffc5 100644 --- a/packages/api/src/context.ts +++ b/packages/api/src/context.ts @@ -1,8 +1,8 @@ import { type inferAsyncReturnType } from '@trpc/server' import { type FetchCreateContextFnOptions } from '@trpc/server/adapters/fetch' +import jwt from '@tsndr/cloudflare-worker-jwt' import { DrizzleD1Database } from 'drizzle-orm/d1' import { createDb } from './db/client' -import jwt from '@tsndr/cloudflare-worker-jwt' interface User { id: string diff --git a/packages/api/src/db/schema.ts b/packages/api/src/db/schema.ts index 2fe870bb9..f3468b531 100644 --- a/packages/api/src/db/schema.ts +++ b/packages/api/src/db/schema.ts @@ -1,5 +1,5 @@ -import { InferSelectModel, InferInsertModel } from 'drizzle-orm' -import { sqliteTable, text, integer, real } from 'drizzle-orm/sqlite-core' +import { InferInsertModel, InferSelectModel } from 'drizzle-orm' +import { integer, real, sqliteTable, text } from 'drizzle-orm/sqlite-core' import { createInsertSchema } from 'drizzle-valibot' // User diff --git a/packages/api/src/db/studio.ts b/packages/api/src/db/studio.ts index 6ffb18940..a5590b623 100644 --- a/packages/api/src/db/studio.ts +++ b/packages/api/src/db/studio.ts @@ -1,9 +1,9 @@ -import * as schema from './schema' -import studio, { Setup } from '@drizzle-team/studio' -import { drizzle } from 'drizzle-orm/bun-sqlite' import { Database } from 'bun:sqlite' import { readdir } from 'node:fs/promises' import { join } from 'node:path' +import studio, { Setup } from '@drizzle-team/studio' +import { drizzle } from 'drizzle-orm/bun-sqlite' +import * as schema from './schema' async function getSqliteFile() { try { diff --git a/packages/api/src/router.ts b/packages/api/src/router.ts index dc27b82ed..9a8d3d9c4 100644 --- a/packages/api/src/router.ts +++ b/packages/api/src/router.ts @@ -1,8 +1,8 @@ -import { router } from './trpc' -import { helloRouter } from './routes/hello' import { authRouter } from './routes/auth' -import { userRouter } from './routes/user' import { carsRouter } from './routes/cars' +import { helloRouter } from './routes/hello' +import { userRouter } from './routes/user' +import { router } from './trpc' export const appRouter = router({ hello: helloRouter, diff --git a/packages/api/src/routes/auth.ts b/packages/api/src/routes/auth.ts index f133aa475..009368102 100644 --- a/packages/api/src/routes/auth.ts +++ b/packages/api/src/routes/auth.ts @@ -1,4 +1,4 @@ -import { router, protectedProcedure, publicProcedure } from '../trpc' +import { protectedProcedure, publicProcedure, router } from '../trpc' export const authRouter = router({ getSession: publicProcedure.query(({ ctx }) => { diff --git a/packages/api/src/routes/cars.ts b/packages/api/src/routes/cars.ts index e5d354cf8..f2ea4f1ef 100644 --- a/packages/api/src/routes/cars.ts +++ b/packages/api/src/routes/cars.ts @@ -1,5 +1,5 @@ import { CarTable } from '../db/schema' -import { router, publicProcedure } from '../trpc' +import { publicProcedure, router } from '../trpc' export const carsRouter = router({ all: publicProcedure.query(async ({ ctx }) => { diff --git a/packages/api/src/routes/hello.ts b/packages/api/src/routes/hello.ts index 1a6eae9b0..fb764536f 100644 --- a/packages/api/src/routes/hello.ts +++ b/packages/api/src/routes/hello.ts @@ -1,5 +1,5 @@ import { parse, string } from 'valibot' -import { router, publicProcedure } from '../trpc' +import { publicProcedure, router } from '../trpc' export const helloRouter = router({ world: publicProcedure diff --git a/packages/api/src/routes/user.ts b/packages/api/src/routes/user.ts index 4a89e16cf..fb982bf74 100644 --- a/packages/api/src/routes/user.ts +++ b/packages/api/src/routes/user.ts @@ -1,7 +1,7 @@ import { eq } from 'drizzle-orm' -import { UserTable, UserSchema, type User } from '../db/schema' -import { router, protectedProcedure } from '../trpc' import { parse } from 'valibot' +import { type User, UserSchema, UserTable } from '../db/schema' +import { protectedProcedure, router } from '../trpc' export const userRouter = router({ current: protectedProcedure.query(async ({ ctx }) => { diff --git a/packages/api/src/trpc.ts b/packages/api/src/trpc.ts index 4eaeafcf1..79655dff4 100644 --- a/packages/api/src/trpc.ts +++ b/packages/api/src/trpc.ts @@ -1,6 +1,6 @@ -import { initTRPC, TRPCError } from '@trpc/server' -import { type Context } from './context' +import { TRPCError, initTRPC } from '@trpc/server' import superJson from 'superjson' +import { type Context } from './context' const t = initTRPC.context().create({ transformer: superJson, diff --git a/packages/api/src/worker.ts b/packages/api/src/worker.ts index 93faf19e1..8797e774b 100644 --- a/packages/api/src/worker.ts +++ b/packages/api/src/worker.ts @@ -1,8 +1,8 @@ -import { Hono } from 'hono' +import { trpcServer } from '@hono/trpc-server' +import { createContext } from '@t4/api/src/context' import { appRouter } from '@t4/api/src/router' +import { Hono } from 'hono' import { cors } from 'hono/cors' -import { createContext } from '@t4/api/src/context' -import { trpcServer } from '@hono/trpc-server' type Bindings = { DB: D1Database diff --git a/packages/app/features/data-fetching/screen.tsx b/packages/app/features/data-fetching/screen.tsx index a2759e2ab..f889c5dea 100644 --- a/packages/app/features/data-fetching/screen.tsx +++ b/packages/app/features/data-fetching/screen.tsx @@ -1,6 +1,6 @@ import { H1, H2, Paragraph, YStack } from '@t4/ui' -import React from 'react' import { trpc } from 'app/utils/trpc' +import React from 'react' import { match } from 'ts-pattern' import { error, loading, success } from '../../utils/trpc/patterns' diff --git a/packages/app/features/home/screen.tsx b/packages/app/features/home/screen.tsx index 5ad7afaaf..968393481 100644 --- a/packages/app/features/home/screen.tsx +++ b/packages/app/features/home/screen.tsx @@ -11,16 +11,16 @@ import { YStack, useToastController, } from '@t4/ui' +import { ThemeToggle } from '@t4/ui/src/ThemeToggle' import { ChevronDown } from '@tamagui/lucide-icons' +import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' +import { useUser } from 'app/utils/supabase/hooks/useUser' +import { trpc } from 'app/utils/trpc' import React, { useState } from 'react' import { Linking } from 'react-native' +import { SolitoImage } from 'solito/image' import { useLink } from 'solito/link' import { useSheetOpen } from '../../atoms/sheet' -import { SolitoImage } from 'solito/image' -import { trpc } from 'app/utils/trpc' -import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' -import { useUser } from 'app/utils/supabase/hooks/useUser' -import { ThemeToggle } from '@t4/ui/src/ThemeToggle' export function HomeScreen() { const utils = trpc.useContext() diff --git a/packages/app/features/password-reset/screen.tsx b/packages/app/features/password-reset/screen.tsx index a9da48708..544f5dc80 100644 --- a/packages/app/features/password-reset/screen.tsx +++ b/packages/app/features/password-reset/screen.tsx @@ -1,7 +1,7 @@ import { YStack, useToastController } from '@t4/ui' -import { useRouter } from 'solito/router' import { PasswordResetComponent } from '@t4/ui/src/PasswordReset' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' +import { useRouter } from 'solito/router' export function PasswordResetScreen() { const { push } = useRouter() diff --git a/packages/app/features/password-reset/update-password/screen.tsx b/packages/app/features/password-reset/update-password/screen.tsx index 65e966014..03e5902fb 100644 --- a/packages/app/features/password-reset/update-password/screen.tsx +++ b/packages/app/features/password-reset/update-password/screen.tsx @@ -1,7 +1,7 @@ import { YStack, useToastController } from '@t4/ui' -import { useRouter } from 'solito/router' import { PasswordResetComponent } from '@t4/ui/src/PasswordReset' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' +import { useRouter } from 'solito/router' export function UpdatePasswordScreen() { const { push } = useRouter() diff --git a/packages/app/features/sign-in/SignUpSignIn.tsx b/packages/app/features/sign-in/SignUpSignIn.tsx index 5126b4277..2aed5349c 100644 --- a/packages/app/features/sign-in/SignUpSignIn.tsx +++ b/packages/app/features/sign-in/SignUpSignIn.tsx @@ -1,8 +1,8 @@ -import { useState } from 'react' -import { YStack, Paragraph, XStack, Button, Input, Stack } from '@t4/ui' -import { Link } from 'solito/link' import { type Provider } from '@supabase/supabase-js' +import { Button, Input, Paragraph, Stack, XStack, YStack } from '@t4/ui' +import { useState } from 'react' import { SolitoImage } from 'solito/image' +import { Link } from 'solito/link' interface Props { type: 'sign-up' | 'sign-in' diff --git a/packages/app/features/sign-in/screen.native.tsx b/packages/app/features/sign-in/screen.native.tsx index 12e4e8a60..bf4b04ed9 100644 --- a/packages/app/features/sign-in/screen.native.tsx +++ b/packages/app/features/sign-in/screen.native.tsx @@ -1,13 +1,13 @@ +import type { Provider } from '@supabase/supabase-js' import { YStack, useToastController } from '@t4/ui' +import { capitalizeWord } from '@t4/ui/src/libs/string' import { SignUpSignInComponent } from 'app/features/sign-in/SignUpSignIn' -import { useRouter } from 'solito/router' -import type { Provider } from '@supabase/supabase-js' +import { initiateAppleSignIn } from 'app/utils/supabase/appleAuth' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' -import * as WebBrowser from 'expo-web-browser' import { getInitialURL } from 'expo-linking' +import * as WebBrowser from 'expo-web-browser' import { Platform } from 'react-native' -import { initiateAppleSignIn } from 'app/utils/supabase/appleAuth' -import { capitalizeWord } from '@t4/ui/src/libs/string' +import { useRouter } from 'solito/router' export const SignInScreen = (): React.ReactNode => { const { replace } = useRouter() @@ -65,7 +65,7 @@ export const SignInScreen = (): React.ReactNode => { supabase.auth._notifyAllSubscribers('SIGNED_IN', session) replace('/') } else { - toast.show(capitalizeWord(provider) + ' sign in failed', { + toast.show(`${capitalizeWord(provider)} sign in failed`, { description: error?.message || 'Something went wrong, please try again.', }) console.log('Supabase session error:', error) @@ -73,7 +73,7 @@ export const SignInScreen = (): React.ReactNode => { }) } } catch (error) { - toast.show(capitalizeWord(provider) + ' sign in failed', { + toast.show(`${capitalizeWord(provider)} sign in failed`, { description: 'Something went wrong, please try again.', }) } finally { diff --git a/packages/app/features/sign-in/screen.tsx b/packages/app/features/sign-in/screen.tsx index 4ea6c0f31..f4c843f27 100644 --- a/packages/app/features/sign-in/screen.tsx +++ b/packages/app/features/sign-in/screen.tsx @@ -1,9 +1,9 @@ +import type { Provider } from '@supabase/supabase-js' import { YStack, useToastController } from '@t4/ui' +import { capitalizeWord } from '@t4/ui/src/libs/string' import { SignUpSignInComponent } from 'app/features/sign-in/SignUpSignIn' -import { useRouter } from 'solito/router' -import type { Provider } from '@supabase/supabase-js' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' -import { capitalizeWord } from '@t4/ui/src/libs/string' +import { useRouter } from 'solito/router' export const SignInScreen = (): React.ReactNode => { const { replace } = useRouter() @@ -22,7 +22,7 @@ export const SignInScreen = (): React.ReactNode => { }) if (error) { - toast.show(capitalizeWord(provider) + ' sign in failed', { + toast.show(`${capitalizeWord(provider)} sign in failed`, { description: error.message, }) console.log('OAuth Sign in failed', error) diff --git a/packages/app/features/sign-up/screen.native.tsx b/packages/app/features/sign-up/screen.native.tsx index 24446b963..0f700642a 100644 --- a/packages/app/features/sign-up/screen.native.tsx +++ b/packages/app/features/sign-up/screen.native.tsx @@ -1,13 +1,13 @@ +import type { Provider } from '@supabase/supabase-js' import { YStack, useToastController } from '@t4/ui' -import { useRouter } from 'solito/router' +import { capitalizeWord } from '@t4/ui/src/libs/string' import { SignUpSignInComponent } from 'app/features/sign-in/SignUpSignIn' -import type { Provider } from '@supabase/supabase-js' +import { initiateAppleSignIn } from 'app/utils/supabase/appleAuth' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' -import * as WebBrowser from 'expo-web-browser' import { getInitialURL } from 'expo-linking' +import * as WebBrowser from 'expo-web-browser' import { Platform } from 'react-native' -import { initiateAppleSignIn } from 'app/utils/supabase/appleAuth' -import { capitalizeWord } from '@t4/ui/src/libs/string' +import { useRouter } from 'solito/router' export const SignUpScreen = (): React.ReactNode => { const { replace } = useRouter() @@ -66,7 +66,7 @@ export const SignUpScreen = (): React.ReactNode => { supabase.auth._notifyAllSubscribers('SIGNED_IN', session) replace('/') } else { - toast.show(capitalizeWord(provider) + ' sign in failed', { + toast.show(`${capitalizeWord(provider)} sign in failed`, { description: error?.message || 'Something went wrong, please try again.', }) console.log('Supabase session error:', error) @@ -74,7 +74,7 @@ export const SignUpScreen = (): React.ReactNode => { }) } } catch (error) { - toast.show(capitalizeWord(provider) + ' sign in failed', { + toast.show(`${capitalizeWord(provider)} sign in failed`, { description: 'Something went wrong, please try again.', }) } finally { diff --git a/packages/app/features/sign-up/screen.tsx b/packages/app/features/sign-up/screen.tsx index 1c9516bf3..eea869c80 100644 --- a/packages/app/features/sign-up/screen.tsx +++ b/packages/app/features/sign-up/screen.tsx @@ -1,9 +1,9 @@ +import type { Provider } from '@supabase/supabase-js' import { YStack, useToastController } from '@t4/ui' -import { useRouter } from 'solito/router' +import { capitalizeWord } from '@t4/ui/src/libs/string' import { SignUpSignInComponent } from 'app/features/sign-in/SignUpSignIn' -import type { Provider } from '@supabase/supabase-js' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' -import { capitalizeWord } from '@t4/ui/src/libs/string' +import { useRouter } from 'solito/router' export const SignUpScreen = (): React.ReactNode => { const { push } = useRouter() @@ -24,7 +24,7 @@ export const SignUpScreen = (): React.ReactNode => { : {}, }) if (error) { - toast.show(capitalizeWord(provider) + ' sign up failed', { + toast.show(`${capitalizeWord(provider)} sign up failed`, { description: error.message, }) return diff --git a/packages/app/package.json b/packages/app/package.json index d8e47c419..5d3e355c2 100755 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -18,7 +18,6 @@ "@tamagui/lucide-icons": "1.75.9", "@tamagui/shorthands": "1.75.9", "@tamagui/themes": "1.75.9", - "ts-pattern": "^5.0.5", "@tanstack/react-query": "^4.36.1", "@trpc/client": "^10.43.0", "@trpc/next": "^10.43.0", @@ -29,7 +28,8 @@ "expo-secure-store": "^12.5.0", "react-native-mmkv": "^2.10.2", "react-native-safe-area-context": "4.7.4", - "solito": "^4.1.3" + "solito": "^4.1.3", + "ts-pattern": "^5.0.5" }, "devDependencies": { "@types/react": "^18.2.34" diff --git a/packages/app/provider/auth/index.tsx b/packages/app/provider/auth/index.tsx index cebbdf6b9..2629573e3 100644 --- a/packages/app/provider/auth/index.tsx +++ b/packages/app/provider/auth/index.tsx @@ -1,7 +1,7 @@ +import { SessionContextProvider } from '@supabase/auth-helpers-react' import { supabase } from 'app/utils/supabase/client' -import { Props } from './index.web' import { AuthStatusChangeHandler } from '../../utils/supabase/components/AuthStatusChangeHandler' -import { SessionContextProvider } from '@supabase/auth-helpers-react' +import { Props } from './index.web' export const AuthProvider = ({ children, initialSession }: Props) => { return ( diff --git a/packages/app/provider/auth/index.web.tsx b/packages/app/provider/auth/index.web.tsx index 02fd1ee4a..fafbc4b08 100644 --- a/packages/app/provider/auth/index.web.tsx +++ b/packages/app/provider/auth/index.web.tsx @@ -1,7 +1,7 @@ -import { createPagesBrowserClient, type Session } from '@supabase/auth-helpers-nextjs' -import { useState } from 'react' +import { type Session, createPagesBrowserClient } from '@supabase/auth-helpers-nextjs' import { SessionContextProvider } from '@supabase/auth-helpers-react' import { secureCookieOptions } from 'app/utils/supabase/cookies' +import { useState } from 'react' import { AuthStatusChangeHandler } from '../../utils/supabase/components/AuthStatusChangeHandler' export interface Props { diff --git a/packages/app/provider/index.tsx b/packages/app/provider/index.tsx index 172876f81..4d210a816 100644 --- a/packages/app/provider/index.tsx +++ b/packages/app/provider/index.tsx @@ -1,12 +1,12 @@ +import { Session } from '@supabase/supabase-js' import { CustomToast, ToastProvider } from '@t4/ui' -import { ToastViewport } from './toast-viewport' -import { TRPCProvider } from './trpc' +import { AuthProvider } from './auth' import { SafeAreaProvider } from './safe-area' -import { TamaguiThemeProvider } from './theme' -import { TamaguiProvider } from './tamagui' import { SolitoImageProvider } from './solito-image' -import { Session } from '@supabase/supabase-js' -import { AuthProvider } from './auth' +import { TamaguiProvider } from './tamagui' +import { TamaguiThemeProvider } from './theme' +import { ToastViewport } from './toast-viewport' +import { TRPCProvider } from './trpc' export function Provider({ children, diff --git a/packages/app/provider/tamagui/index.tsx b/packages/app/provider/tamagui/index.tsx index e0bae3c86..6fa049014 100644 --- a/packages/app/provider/tamagui/index.tsx +++ b/packages/app/provider/tamagui/index.tsx @@ -1,5 +1,5 @@ -import config from '../../tamagui.config' import { TamaguiProvider as TamaguiProviderOG } from '@t4/ui' +import config from '../../tamagui.config' import { useRootTheme } from '../theme' export const TamaguiProvider = ({ children }: { children: React.ReactNode }): React.ReactNode => { diff --git a/packages/app/provider/theme/index.tsx b/packages/app/provider/theme/index.tsx index df6682dc0..ad4262ea5 100644 --- a/packages/app/provider/theme/index.tsx +++ b/packages/app/provider/theme/index.tsx @@ -1,11 +1,11 @@ -import { useForceUpdate } from '@t4/ui' import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native' +import { useForceUpdate } from '@t4/ui' +import { appThemeKey, useAppTheme, useCurrentTheme } from 'app/atoms/theme' +import { ThemeVariant } from 'app/utils/theme' +import { StatusBar } from 'expo-status-bar' import React, { useEffect, useLayoutEffect } from 'react' import { Appearance } from 'react-native' -import { StatusBar } from 'expo-status-bar' import { storage } from '../kv' -import { ThemeVariant } from 'app/utils/theme' -import { appThemeKey, useAppTheme, useCurrentTheme } from 'app/atoms/theme' export const TamaguiThemeProvider = ({ children, @@ -28,14 +28,14 @@ export const TamaguiThemeProvider = ({ return () => { systemThemeChangeListener.remove() } - }, []) + }, [setAppTheme, forceUpdate]) useLayoutEffect(() => { const savedAppTheme = storage.getString(appThemeKey) if (savedAppTheme !== undefined) { setAppTheme(savedAppTheme as ThemeVariant) } - }, []) + }, [setAppTheme]) useEffect(() => { if (appTheme === undefined) { @@ -44,7 +44,7 @@ export const TamaguiThemeProvider = ({ } else { storage.set(appThemeKey, appTheme) } - }, [appTheme]) + }, [appTheme, setAppTheme]) return ( diff --git a/packages/app/provider/theme/index.web.tsx b/packages/app/provider/theme/index.web.tsx index d451ef052..72d3400c7 100644 --- a/packages/app/provider/theme/index.web.tsx +++ b/packages/app/provider/theme/index.web.tsx @@ -1,4 +1,4 @@ -import { NextThemeProvider, useRootTheme, ColorScheme } from '@tamagui/next-theme' +import { ColorScheme, NextThemeProvider, useRootTheme } from '@tamagui/next-theme' export const TamaguiThemeProvider = ({ children, diff --git a/packages/app/utils/env.ts b/packages/app/utils/env.ts index 6fec8f586..38fbe4335 100644 --- a/packages/app/utils/env.ts +++ b/packages/app/utils/env.ts @@ -3,7 +3,7 @@ * Different prefixes for public environments across Expo & Next.js currently block this. */ -import { string, object, parse } from 'valibot' +import { object, parse, string } from 'valibot' const envSchema = object({ NODE_ENV: string(), diff --git a/packages/app/utils/supabase/hooks/useAuthRedirect.ts b/packages/app/utils/supabase/hooks/useAuthRedirect.ts index 5b92dae5b..40b45d871 100644 --- a/packages/app/utils/supabase/hooks/useAuthRedirect.ts +++ b/packages/app/utils/supabase/hooks/useAuthRedirect.ts @@ -2,7 +2,7 @@ import { AuthChangeEvent, Session } from '@supabase/supabase-js' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' import { useEffect } from 'react' import { useRouter } from 'solito/router' -import { useSession, useIsLoadingSession } from './useSessionContext.native' +import { useIsLoadingSession, useSession } from './useSessionContext.native' export const useAuthRedirect = () => { const [, setSession] = useSession() @@ -26,5 +26,5 @@ export const useAuthRedirect = () => { return () => { signOutListener.data.subscription.unsubscribe() } - }, [supabase, router]) + }, [supabase, router, setSession, setLoading]) } diff --git a/packages/app/utils/supabase/hooks/useAuthRedirect.web.ts b/packages/app/utils/supabase/hooks/useAuthRedirect.web.ts index c068b1a5c..3a3ffee78 100644 --- a/packages/app/utils/supabase/hooks/useAuthRedirect.web.ts +++ b/packages/app/utils/supabase/hooks/useAuthRedirect.web.ts @@ -1,8 +1,8 @@ import { AuthChangeEvent } from '@supabase/supabase-js' import { useSupabase } from 'app/utils/supabase/hooks/useSupabase' +import { useRouter as useNextRouter } from 'next/router' import { useEffect } from 'react' import { useRouter } from 'solito/router' -import { useRouter as useNextRouter } from 'next/router' export const useAuthRedirect = () => { const supabase = useSupabase() diff --git a/packages/app/utils/supabase/hooks/useSessionContext.native.ts b/packages/app/utils/supabase/hooks/useSessionContext.native.ts index 9babe1508..852529bb2 100644 --- a/packages/app/utils/supabase/hooks/useSessionContext.native.ts +++ b/packages/app/utils/supabase/hooks/useSessionContext.native.ts @@ -1,5 +1,5 @@ -import { atom, useAtom } from 'jotai' import type { Session } from '@supabase/supabase-js' +import { atom, useAtom } from 'jotai' export const useSessionContext = () => { const [session] = useSession() diff --git a/packages/app/utils/trpc/index.tsx b/packages/app/utils/trpc/index.tsx index 2c2620276..9003fc0f8 100644 --- a/packages/app/utils/trpc/index.tsx +++ b/packages/app/utils/trpc/index.tsx @@ -1,14 +1,14 @@ -import { createTRPCReact } from '@trpc/react-query' import type { AppRouter } from '@t4/api/src/router' +import { createTRPCReact } from '@trpc/react-query' /** * A wrapper for your app that provides the TRPC context. */ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { httpBatchLink } from '@trpc/client' -import { supabase } from '../supabase/client' -import superjson from 'superjson' import { useState } from 'react' +import superjson from 'superjson' +import { supabase } from '../supabase/client' import { replaceLocalhost } from './localhost.native' /** diff --git a/packages/app/utils/trpc/index.web.ts b/packages/app/utils/trpc/index.web.ts index e490130d8..57a678233 100644 --- a/packages/app/utils/trpc/index.web.ts +++ b/packages/app/utils/trpc/index.web.ts @@ -1,6 +1,6 @@ -import { createTRPCNext } from '@trpc/next' -import { httpBatchLink, loggerLink } from '@trpc/client' import type { AppRouter } from '@t4/api/src/router' +import { httpBatchLink, loggerLink } from '@trpc/client' +import { createTRPCNext } from '@trpc/next' import superjson from 'superjson' import { getToken } from '../supabase/cookies' diff --git a/packages/ui/src/MyComponent.tsx b/packages/ui/src/MyComponent.tsx index a72c0512a..5a6c34528 100644 --- a/packages/ui/src/MyComponent.tsx +++ b/packages/ui/src/MyComponent.tsx @@ -1,4 +1,4 @@ -import { styled, YStack, type TamaguiComponent } from 'tamagui' +import { type TamaguiComponent, YStack, styled } from 'tamagui' export const MyComponent: TamaguiComponent = styled(YStack, { name: 'MyComponent', diff --git a/packages/ui/src/PasswordReset.tsx b/packages/ui/src/PasswordReset.tsx index 515fd5fea..83829ab3f 100644 --- a/packages/ui/src/PasswordReset.tsx +++ b/packages/ui/src/PasswordReset.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { YStack, Paragraph, Button, Input } from 'tamagui' +import { Button, Input, Paragraph, YStack } from 'tamagui' interface Props { type: 'email' | 'password' @@ -22,7 +22,7 @@ export const PasswordResetComponent: React.FC = ({ type, handleWithPress backgroundColor='$background' > - {type == 'email' ? 'Reset your password' : 'Change your password'} + {type === 'email' ? 'Reset your password' : 'Change your password'} {/* email or password input */} @@ -57,7 +57,7 @@ export const PasswordResetComponent: React.FC = ({ type, handleWithPress onHoverOut={() => {}} focusStyle={{ scale: 0.975 }} > - {type == 'email' ? 'Reset Password' : 'Change Password'} + {type === 'email' ? 'Reset Password' : 'Change Password'} ) diff --git a/packages/ui/src/ThemeToggle.tsx b/packages/ui/src/ThemeToggle.tsx index f5b9b0c9a..4677a12ea 100644 --- a/packages/ui/src/ThemeToggle.tsx +++ b/packages/ui/src/ThemeToggle.tsx @@ -1,6 +1,6 @@ -import { useState } from 'react' +import { Monitor, Moon, Sun } from '@tamagui/lucide-icons' import { useThemeSetting } from '@tamagui/next-theme' -import { Monitor, Sun, Moon } from '@tamagui/lucide-icons' +import { useState } from 'react' import type { ButtonProps } from 'tamagui' import { Button, useIsomorphicLayoutEffect } from 'tamagui' diff --git a/packages/ui/src/cars/CarListItem.tsx b/packages/ui/src/cars/CarListItem.tsx index 9159e4171..8c3116aa8 100644 --- a/packages/ui/src/cars/CarListItem.tsx +++ b/packages/ui/src/cars/CarListItem.tsx @@ -1,5 +1,5 @@ -import { formatNumber, formatPrice } from '@t4/ui/src/libs/number' import type { Car } from '@t4/api/src/db/schema' +import { formatNumber, formatPrice } from '@t4/ui/src/libs/number' import { SolitoImage } from 'solito/image' import { Paragraph, YStack } from 'tamagui' @@ -17,7 +17,7 @@ export const CarListItem = (item: Car): React.ReactElement => { /> - {item.make + ' ' + item.model} + {`${item.make} ${item.model}`} {item.color} - {item.year} - {formatNumber(item.mileage)} miles -{' '} diff --git a/packages/ui/src/libs/number.ts b/packages/ui/src/libs/number.ts index 982483779..f3a767e0a 100644 --- a/packages/ui/src/libs/number.ts +++ b/packages/ui/src/libs/number.ts @@ -10,7 +10,7 @@ const formatter = new Intl.NumberFormat('en-US', { }) export function formatPrice(number) { - if (typeof number !== 'number' || isNaN(number) || !isFinite(number)) { + if (typeof number !== 'number' || Number.isNaN(number) || !Number.isFinite(number)) { throw new Error('Invalid number value') } diff --git a/packages/ui/src/list/index.tsx b/packages/ui/src/list/index.tsx index 804d1b72c..e17dfaf52 100644 --- a/packages/ui/src/list/index.tsx +++ b/packages/ui/src/list/index.tsx @@ -1,6 +1,6 @@ import { FlashList } from '@shopify/flash-list' -import { useSafeAreaInsets } from 'react-native-safe-area-context' import { useCallback } from 'react' +import { useSafeAreaInsets } from 'react-native-safe-area-context' interface Props { data: any[] diff --git a/packages/ui/src/list/index.web.tsx b/packages/ui/src/list/index.web.tsx index 48df257e9..a33b2b787 100644 --- a/packages/ui/src/list/index.web.tsx +++ b/packages/ui/src/list/index.web.tsx @@ -1,6 +1,6 @@ -import { useSafeAreaInsets } from 'react-native-safe-area-context' import { useVirtualizer } from '@tanstack/react-virtual' import { useRef } from 'react' +import { useSafeAreaInsets } from 'react-native-safe-area-context' interface Props { data: any[] @@ -24,7 +24,7 @@ export const VirtualList = ({ data, renderItem, itemHeight }: Props): React.Reac style={{ paddingTop: top, paddingBottom: bottom, - height: `100%`, + height: '100%', overflow: 'auto', // Make it scroll! }} > diff --git a/packages/ui/src/tamagui.config.ts b/packages/ui/src/tamagui.config.ts index 8a28cf236..3b73a5dc2 100644 --- a/packages/ui/src/tamagui.config.ts +++ b/packages/ui/src/tamagui.config.ts @@ -1,8 +1,8 @@ -import { createTamagui } from 'tamagui' import { createInterFont } from '@tamagui/font-inter' +import { createMedia } from '@tamagui/react-native-media-driver' import { shorthands } from '@tamagui/shorthands' import { themes, tokens } from '@tamagui/themes' -import { createMedia } from '@tamagui/react-native-media-driver' +import { createTamagui } from 'tamagui' import { animations } from './animations'