From 41173127c0edc8b1e7fc22beb1c17707b523fadb Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Mon, 5 Aug 2024 16:03:49 -0400 Subject: [PATCH] code formatting --- src/components/organisms/TaskEdit.tsx | 2 +- src/components/organisms/TaskForm.spec.tsx | 10 +++++----- src/components/pages/Account.spec.tsx | 2 +- src/components/pages/Register.spec.tsx | 16 ++++++++-------- src/components/pages/Register.tsx | 2 +- src/components/pages/Tasks.spec.tsx | 8 ++++---- src/lib/api/useAddTask.ts | 2 +- src/lib/api/useEditTask.ts | 2 +- src/lib/api/useMe.ts | 15 +++++++++------ src/lib/api/useUpdatePassword.ts | 2 +- src/lib/api/useUpdateTask.ts | 2 +- src/lib/browser.tsx | 6 +++--- src/lib/createListItems.tsx | 2 +- src/lib/setCookie.ts | 2 +- src/lib/test/makeResponse.tsx | 2 +- src/lib/test/queries.tsx | 2 +- src/lib/test/renderWithQueryProvider.tsx | 4 ++-- src/lib/test/withMutedReactQueryLogger.tsx | 2 +- src/lib/useDifferenceToNow.spec.ts | 8 ++++---- src/lib/useDocumentTitle.ts | 2 +- src/lib/useFilters.tsx | 4 ++-- src/lib/useIsDue.spec.ts | 10 +++++----- src/lib/usePref.ts | 6 +++--- src/serviceWorker.js | 10 +++++----- src/tr_constants.ts | 8 ++++---- src/window.d.ts | 2 +- vite.config.ts | 4 ++-- 27 files changed, 70 insertions(+), 67 deletions(-) diff --git a/src/components/organisms/TaskEdit.tsx b/src/components/organisms/TaskEdit.tsx index 67c6645e..2c12e3bb 100644 --- a/src/components/organisms/TaskEdit.tsx +++ b/src/components/organisms/TaskEdit.tsx @@ -45,7 +45,7 @@ const TaskEdit = ({ onSuccess: () => { setIsOpen(false); }, - } + }, ); } diff --git a/src/components/organisms/TaskForm.spec.tsx b/src/components/organisms/TaskForm.spec.tsx index de49ecdc..b33931d8 100644 --- a/src/components/organisms/TaskForm.spec.tsx +++ b/src/components/organisms/TaskForm.spec.tsx @@ -56,7 +56,7 @@ const renderComponent = (props: RenderComponentProps = {}) => { onSubmit, isLoading, }} - /> + />, ); return { @@ -92,7 +92,7 @@ describe('TaskForm', () => { await userEvent.type( await screen.findByLabelText('Due Time *'), - '{backspace}{backspace}am' + '{backspace}{backspace}am', ); expect(onChange).toBeCalled(); @@ -121,7 +121,7 @@ describe('TaskForm', () => { await userEvent.type( await screen.findByLabelText('Due Date *'), - '{backspace}2{enter}' + '{backspace}2{enter}', ); expect(onChange).toBeCalledWith({ @@ -141,13 +141,13 @@ describe('TaskForm', () => { await userEvent.type( await screen.findByLabelText('Due Time *'), - '{backspace}M{enter}' + '{backspace}M{enter}', ); expect(onChange).toBeCalledWith( expect.objectContaining({ due: '1/1/2020, 11:59 PM', - }) + }), ); }); }); diff --git a/src/components/pages/Account.spec.tsx b/src/components/pages/Account.spec.tsx index 47ff2269..4b3aafe7 100644 --- a/src/components/pages/Account.spec.tsx +++ b/src/components/pages/Account.spec.tsx @@ -39,7 +39,7 @@ describe('account page', () => { renderWithQueryProvider(); expect( - await screen.findByText('Enable Beeminder integration') + await screen.findByText('Enable Beeminder integration'), ).toBeInTheDocument(); }); diff --git a/src/components/pages/Register.spec.tsx b/src/components/pages/Register.spec.tsx index baa5afa8..7f4706c4 100644 --- a/src/components/pages/Register.spec.tsx +++ b/src/components/pages/Register.spec.tsx @@ -25,11 +25,11 @@ async function fillForm() { await userEvent.type(await screen.findByLabelText(/Email/), 'the_email'); await userEvent.type( await screen.findByLabelText(/^Password/), - 'the_password' + 'the_password', ); await userEvent.type( await screen.findByLabelText(/Retype Password/), - 'the_password' + 'the_password', ); await waitFor(() => { @@ -44,8 +44,8 @@ async function fillForm() { await userEvent.click( await screen.findByLabelText( - "I have read and agree to TaskRatchet's privacy policy and terms of service." - ) + "I have read and agree to TaskRatchet's privacy policy and terms of service.", + ), ); await waitFor(() => { @@ -92,7 +92,7 @@ describe('registration page', () => { 'the_email', 'the_password', 'the_timezone', - 'session' + 'session', ); }); @@ -115,7 +115,7 @@ describe('registration page', () => { await userEvent.type( await screen.findByLabelText('How did you hear about us?'), - 'the_referral' + 'the_referral', ); await userEvent.click(await screen.findByText('Add payment method')); @@ -187,8 +187,8 @@ describe('registration page', () => { await userEvent.click( await screen.findByLabelText( - "I have read and agree to TaskRatchet's privacy policy and terms of service." - ) + "I have read and agree to TaskRatchet's privacy policy and terms of service.", + ), ); await userEvent.click(await screen.findByText('Add payment method')); diff --git a/src/components/pages/Register.tsx b/src/components/pages/Register.tsx index 112025b8..3ab63dfd 100644 --- a/src/components/pages/Register.tsx +++ b/src/components/pages/Register.tsx @@ -54,7 +54,7 @@ const Register = (): JSX.Element => { email, password, timezone, - checkoutSession.id + checkoutSession.id, ); if (response.ok) { diff --git a/src/components/pages/Tasks.spec.tsx b/src/components/pages/Tasks.spec.tsx index 49bc0b89..2108e46d 100644 --- a/src/components/pages/Tasks.spec.tsx +++ b/src/components/pages/Tasks.spec.tsx @@ -147,7 +147,7 @@ describe('tasks page', () => { await clickCheckbox(); await waitFor(() => - expect(updateTask).toBeCalledWith('3', { complete: true }) + expect(updateTask).toBeCalledWith('3', { complete: true }), ); }); @@ -182,7 +182,7 @@ describe('tasks page', () => { await userEvent.click(getAddButton()); await waitFor(() => - expect(toast).toBeCalledWith('Error: Failed to add task') + expect(toast).toBeCalledWith('Error: Failed to add task'), ); }); }); @@ -471,7 +471,7 @@ describe('tasks page', () => { renderTasksPage(); expect( - await screen.findByText((s) => s.indexOf('May') !== -1) + await screen.findByText((s) => s.indexOf('May') !== -1), ).toBeInTheDocument(); }); @@ -647,7 +647,7 @@ describe('tasks page', () => { expect(addTask).toBeCalledWith( expect.objectContaining({ task: 'task1', - }) + }), ); }); }); diff --git a/src/lib/api/useAddTask.ts b/src/lib/api/useAddTask.ts index e45cd0bf..502e1d0d 100644 --- a/src/lib/api/useAddTask.ts +++ b/src/lib/api/useAddTask.ts @@ -9,7 +9,7 @@ interface Input { } export function useAddTask( - onSave: (t: TaskType) => void + onSave: (t: TaskType) => void, ): UseMutationResult { const queryClient = useQueryClient(); diff --git a/src/lib/api/useEditTask.ts b/src/lib/api/useEditTask.ts index e9db939e..2db46183 100644 --- a/src/lib/api/useEditTask.ts +++ b/src/lib/api/useEditTask.ts @@ -20,6 +20,6 @@ export default function useEditTask(): UseMutationResult< onSettled: async () => { await queryClient.refetchQueries('tasks'); }, - } + }, ); } diff --git a/src/lib/api/useMe.ts b/src/lib/api/useMe.ts index e4cefb92..faab6a41 100644 --- a/src/lib/api/useMe.ts +++ b/src/lib/api/useMe.ts @@ -5,7 +5,7 @@ import { useEffect } from 'react'; import { User, getMe } from '@taskratchet/sdk'; export function useMe( - queryOptions: UseQueryOptions | undefined = {} + queryOptions: UseQueryOptions | undefined = {}, ): QueryObserverResult { const result = useQuery({ queryKey: 'me', @@ -18,13 +18,16 @@ export function useMe( useEffect(() => { if (!data) return; - const metadata = Object.keys(data).reduce((prev, key) => { - const value = data[key as keyof User]; + const metadata = Object.keys(data).reduce( + (prev, key) => { + const value = data[key as keyof User]; - prev[key] = typeof value === 'string' ? value : JSON.stringify(value); + prev[key] = typeof value === 'string' ? value : JSON.stringify(value); - return prev; - }, {} as Record); + return prev; + }, + {} as Record, + ); H.identify(data.id, metadata); }, [data]); diff --git a/src/lib/api/useUpdatePassword.ts b/src/lib/api/useUpdatePassword.ts index 69dc452a..ee815bb0 100644 --- a/src/lib/api/useUpdatePassword.ts +++ b/src/lib/api/useUpdatePassword.ts @@ -7,7 +7,7 @@ export function useUpdatePassword(): { } { const { mutate, isLoading } = useMutation( (variables: { oldPass: string; newPass: string }) => - updatePassword(variables.oldPass, variables.newPass) + updatePassword(variables.oldPass, variables.newPass), ); return { diff --git a/src/lib/api/useUpdateTask.ts b/src/lib/api/useUpdateTask.ts index f472a028..5fa62667 100644 --- a/src/lib/api/useUpdateTask.ts +++ b/src/lib/api/useUpdateTask.ts @@ -48,7 +48,7 @@ export function useUpdateTask(): (id: string, data: TaskInput) => void { onSettled: async () => { await queryClient.invalidateQueries('tasks'); }, - } + }, ); return (id: string, data: TaskInput): void => { diff --git a/src/lib/browser.tsx b/src/lib/browser.tsx index 64369072..a379c076 100644 --- a/src/lib/browser.tsx +++ b/src/lib/browser.tsx @@ -13,8 +13,8 @@ const getScrollableParent = function (el: Element | null): Element { return !el || el === document.body ? document.body : isScrollable(el) - ? el - : getScrollableParent(el.parentElement); + ? el + : getScrollableParent(el.parentElement); }; export function getLanguages(): string[] { @@ -76,7 +76,7 @@ export function getUrlParams(): ParsedQuery { export function scrollIntoView( el: Element, - options: { offset?: number } = {} + options: { offset?: number } = {}, ): void { const { offset = 0 } = options; const pos = el.getBoundingClientRect().top; diff --git a/src/lib/createListItems.tsx b/src/lib/createListItems.tsx index 36646742..506184f3 100644 --- a/src/lib/createListItems.tsx +++ b/src/lib/createListItems.tsx @@ -14,7 +14,7 @@ type Entries = (TaskType | string)[]; export default function createListItems( sortedTasks: TaskType[], - newTask: TaskType | undefined + newTask: TaskType | undefined, ): { entries: Entries; nextHeadingIndex: number | undefined; diff --git a/src/lib/setCookie.ts b/src/lib/setCookie.ts index 41fcc9c9..d38044f4 100644 --- a/src/lib/setCookie.ts +++ b/src/lib/setCookie.ts @@ -1,7 +1,7 @@ export const setCookie = ( key: string, value: unknown, - numberOfDays: number + numberOfDays: number, ): void => { const now = new Date(); now.setTime(now.getTime() + numberOfDays * 60 * 60 * 24 * 1000); diff --git a/src/lib/test/makeResponse.tsx b/src/lib/test/makeResponse.tsx index 3dd82a97..4772fd42 100644 --- a/src/lib/test/makeResponse.tsx +++ b/src/lib/test/makeResponse.tsx @@ -2,7 +2,7 @@ export const makeResponse = ( args: { ok?: boolean; json?: Record; - } = {} + } = {}, ): Partial => { const { ok = true, json = null } = args; diff --git a/src/lib/test/queries.tsx b/src/lib/test/queries.tsx index 078e1afb..b3e4817d 100644 --- a/src/lib/test/queries.tsx +++ b/src/lib/test/queries.tsx @@ -1,7 +1,7 @@ import { screen, waitFor } from '@testing-library/react'; export async function findTaskCheckbox( - task = 'the_task' + task = 'the_task', ): Promise { const desc = await screen.findByText(task); let checkbox; diff --git a/src/lib/test/renderWithQueryProvider.tsx b/src/lib/test/renderWithQueryProvider.tsx index ef4e48bc..3d2ab7a5 100644 --- a/src/lib/test/renderWithQueryProvider.tsx +++ b/src/lib/test/renderWithQueryProvider.tsx @@ -4,7 +4,7 @@ import { render, RenderResult } from '@testing-library/react'; import { createTheme, ThemeProvider } from '@mui/material/styles'; export function renderWithQueryProvider( - ui: ReactElement + ui: ReactElement, ): RenderResult & { queryClient: QueryClient } { const queryClient = new QueryClient({ defaultOptions: { @@ -29,7 +29,7 @@ export function renderWithQueryProvider( const view = render( {ui} - + , ); return { diff --git a/src/lib/test/withMutedReactQueryLogger.tsx b/src/lib/test/withMutedReactQueryLogger.tsx index 62197e23..37aa559e 100644 --- a/src/lib/test/withMutedReactQueryLogger.tsx +++ b/src/lib/test/withMutedReactQueryLogger.tsx @@ -1,7 +1,7 @@ import { setLogger } from 'react-query'; export async function withMutedReactQueryLogger( - callback: () => Promise + callback: () => Promise, ): Promise { setLogger({ log: () => { diff --git a/src/lib/useDifferenceToNow.spec.ts b/src/lib/useDifferenceToNow.spec.ts index c553f7e1..55f30cd4 100644 --- a/src/lib/useDifferenceToNow.spec.ts +++ b/src/lib/useDifferenceToNow.spec.ts @@ -9,7 +9,7 @@ describe('useDifferenceToNow', () => { const result = useDifferenceToNow( makeTask({ due_timestamp: 1623873540, - }) + }), ); expect(result).toEqual('in 1h'); @@ -21,7 +21,7 @@ describe('useDifferenceToNow', () => { const result = useDifferenceToNow( makeTask({ due_timestamp: 1623869940, - }) + }), ); expect(result).toEqual('1h ago'); @@ -33,7 +33,7 @@ describe('useDifferenceToNow', () => { const result = useDifferenceToNow( makeTask({ due_timestamp: 1623873540 * 2, - }) + }), ); expect(result).toEqual('in 51y 5mo'); @@ -45,7 +45,7 @@ describe('useDifferenceToNow', () => { const result = useDifferenceToNow( makeTask({ due_timestamp: 1623873540, - }) + }), ); expect(result).toEqual('in 1h'); diff --git a/src/lib/useDocumentTitle.ts b/src/lib/useDocumentTitle.ts index 0c16e1e5..584777b5 100644 --- a/src/lib/useDocumentTitle.ts +++ b/src/lib/useDocumentTitle.ts @@ -14,7 +14,7 @@ function useDocumentTitle(title: string, prevailOnUnmount = false) { document.title = defaultTitle.current; } }, - [prevailOnUnmount] + [prevailOnUnmount], ); } diff --git a/src/lib/useFilters.tsx b/src/lib/useFilters.tsx index 69f035cc..8f25f253 100644 --- a/src/lib/useFilters.tsx +++ b/src/lib/useFilters.tsx @@ -40,7 +40,7 @@ export default function useFilters(): { const { pref: filters, setPref: setFilters } = usePref( 'filters', - defaultFilters + defaultFilters, ); const toggleFilter = useCallback( @@ -50,7 +50,7 @@ export default function useFilters(): { [filter]: !filters[filter], }); }, - [filters, setFilters] + [filters, setFilters], ); return { diff --git a/src/lib/useIsDue.spec.ts b/src/lib/useIsDue.spec.ts index bf9163da..5929bd91 100644 --- a/src/lib/useIsDue.spec.ts +++ b/src/lib/useIsDue.spec.ts @@ -9,7 +9,7 @@ describe('useIsDue', () => { const result = useIsDue( makeTask({ due_timestamp: 1623869940, - }) + }), ); expect(result).toBeTruthy(); @@ -21,7 +21,7 @@ describe('useIsDue', () => { const result = useIsDue( makeTask({ due_timestamp: 1623869940 + 24 * 60 * 60, - }) + }), ); expect(result).toBeFalsy(); @@ -33,7 +33,7 @@ describe('useIsDue', () => { const result = useIsDue( makeTask({ due_timestamp: 1623869940 - 1, - }) + }), ); expect(result).toBeFalsy(); @@ -46,7 +46,7 @@ describe('useIsDue', () => { makeTask({ due_timestamp: 1623869940, complete: true, - }) + }), ); expect(result).toBeFalsy(); @@ -59,7 +59,7 @@ describe('useIsDue', () => { makeTask({ due_timestamp: 1623869940, status: 'expired', - }) + }), ); expect(result).toBeFalsy(); diff --git a/src/lib/usePref.ts b/src/lib/usePref.ts index ae6f40c6..61c3cc5f 100644 --- a/src/lib/usePref.ts +++ b/src/lib/usePref.ts @@ -18,7 +18,7 @@ export function usePref(id: string, defaultValue: T): PrefResult { }, { initialData: () => getPrefFromLocalStorage(id) ?? defaultValue, - } + }, ); const setPref = useCallback( @@ -31,7 +31,7 @@ export function usePref(id: string, defaultValue: T): PrefResult { // Invalidate this pref so callers will re-ensure the data as needed void queryClient.invalidateQueries(queryKey).then(() => refetch()); }, - [id, queryKey, queryClient, refetch] + [id, queryKey, queryClient, refetch], ); return { @@ -52,7 +52,7 @@ function getPrefFromLocalStorage(id: string) { } const prefEnvelope: PrefEnvelope = JSON.parse( - prefString + prefString, ) as PrefEnvelope; return prefEnvelope.pref; diff --git a/src/serviceWorker.js b/src/serviceWorker.js index 492ac5c3..471bf8d3 100644 --- a/src/serviceWorker.js +++ b/src/serviceWorker.js @@ -16,8 +16,8 @@ const isLocalhost = Boolean( window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/, + ), ); export function register(config) { @@ -43,7 +43,7 @@ export function register(config) { navigator.serviceWorker.ready.then(() => { console.log( 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit https://bit.ly/CRA-PWA' + 'worker. To learn more, visit https://bit.ly/CRA-PWA', ); }); } else { @@ -71,7 +71,7 @@ function registerValidSW(swUrl, config) { // content until all client tabs are closed. console.log( 'New content is available and will be used when all ' + - 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.', ); // Execute callback @@ -121,7 +121,7 @@ function checkValidServiceWorker(swUrl, config) { }) .catch(() => { console.log( - 'No internet connection found. App is running in offline mode.' + 'No internet connection found. App is running in offline mode.', ); }); } diff --git a/src/tr_constants.ts b/src/tr_constants.ts index e0472b8c..88d1ce54 100644 --- a/src/tr_constants.ts +++ b/src/tr_constants.ts @@ -5,10 +5,10 @@ export const IS_LOCAL = !IS_PRODUCTION && !IS_STAGING; export const API1_BASE = IS_PRODUCTION ? 'https://api.taskratchet.com/api1/' : IS_STAGING - ? 'https://taskratchet-api-node-c3yk2gl5eq-uc.a.run.app/api1/' - : 'http://localhost:8080/api1/'; + ? 'https://taskratchet-api-node-c3yk2gl5eq-uc.a.run.app/api1/' + : 'http://localhost:8080/api1/'; export const API2_BASE = IS_PRODUCTION ? 'https://api.taskratchet.com/api2/' : IS_STAGING - ? 'https://taskratchet-api-node-c3yk2gl5eq-uc.a.run.app/api2/' - : 'http://localhost:8080/api2/'; + ? 'https://taskratchet-api-node-c3yk2gl5eq-uc.a.run.app/api2/' + : 'http://localhost:8080/api2/'; diff --git a/src/window.d.ts b/src/window.d.ts index 073e979f..2288ea90 100644 --- a/src/window.d.ts +++ b/src/window.d.ts @@ -2,7 +2,7 @@ interface Window { FreshworksWidget: (...props: unknown[]) => void; Stripe: (key: string) => { redirectToCheckout: ( - options: unknown + options: unknown, ) => Promise<{ error: { message: string } }>; }; stripe_key: string; diff --git a/vite.config.ts b/vite.config.ts index 52324f16..725bdf78 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -31,10 +31,10 @@ export default defineConfig(({ mode }) => { __FIREBASE_DATABASE_URL__: JSON.stringify(env.VITE_FIREBASE_DATABASE_URL), __FIREBASE_PROJECT_ID__: JSON.stringify(env.VITE_FIREBASE_PROJECT_ID), __FIREBASE_STORAGE_BUCKET__: JSON.stringify( - env.VITE_FIREBASE_STORAGE_BUCKET + env.VITE_FIREBASE_STORAGE_BUCKET, ), __FIREBASE_MESSAGING_SENDER_ID__: JSON.stringify( - env.VITE_FIREBASE_MESSAGING_SENDER_ID + env.VITE_FIREBASE_MESSAGING_SENDER_ID, ), __FIREBASE_APP_ID__: JSON.stringify(env.VITE_FIREBASE_APP_ID), },