Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Aug 5, 2024
1 parent f695789 commit 4117312
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/components/organisms/TaskEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const TaskEdit = ({
onSuccess: () => {
setIsOpen(false);
},
}
},
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/organisms/TaskForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const renderComponent = (props: RenderComponentProps = {}) => {
onSubmit,
isLoading,
}}
/>
/>,
);

return {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('TaskForm', () => {

await userEvent.type(
await screen.findByLabelText('Due Time *'),
'{backspace}{backspace}am'
'{backspace}{backspace}am',
);

expect(onChange).toBeCalled();
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('TaskForm', () => {

await userEvent.type(
await screen.findByLabelText('Due Date *'),
'{backspace}2{enter}'
'{backspace}2{enter}',
);

expect(onChange).toBeCalledWith({
Expand All @@ -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',
})
}),
);
});
});
2 changes: 1 addition & 1 deletion src/components/pages/Account.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('account page', () => {
renderWithQueryProvider(<Account />);

expect(
await screen.findByText('Enable Beeminder integration')
await screen.findByText('Enable Beeminder integration'),
).toBeInTheDocument();
});

Expand Down
16 changes: 8 additions & 8 deletions src/components/pages/Register.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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(() => {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('registration page', () => {
'the_email',
'the_password',
'the_timezone',
'session'
'session',
);
});

Expand All @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Register = (): JSX.Element => {
email,
password,
timezone,
checkoutSession.id
checkoutSession.id,
);

if (response.ok) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/pages/Tasks.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('tasks page', () => {
await clickCheckbox();

await waitFor(() =>
expect(updateTask).toBeCalledWith('3', { complete: true })
expect(updateTask).toBeCalledWith('3', { complete: true }),
);
});

Expand Down Expand Up @@ -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'),
);
});
});
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -647,7 +647,7 @@ describe('tasks page', () => {
expect(addTask).toBeCalledWith(
expect.objectContaining({
task: 'task1',
})
}),
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/useAddTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Input {
}

export function useAddTask(
onSave: (t: TaskType) => void
onSave: (t: TaskType) => void,
): UseMutationResult<Response, Error, Input> {
const queryClient = useQueryClient();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/useEditTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default function useEditTask(): UseMutationResult<
onSettled: async () => {
await queryClient.refetchQueries('tasks');
},
}
},
);
}
15 changes: 9 additions & 6 deletions src/lib/api/useMe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useEffect } from 'react';
import { User, getMe } from '@taskratchet/sdk';

export function useMe(
queryOptions: UseQueryOptions<User> | undefined = {}
queryOptions: UseQueryOptions<User> | undefined = {},
): QueryObserverResult<User, unknown> {
const result = useQuery({
queryKey: 'me',
Expand All @@ -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<string, string>);
return prev;
},
{} as Record<string, string>,
);

H.identify(data.id, metadata);
}, [data]);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/useUpdatePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/useUpdateTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useUpdateTask(): (id: string, data: TaskInput) => void {
onSettled: async () => {
await queryClient.invalidateQueries('tasks');
},
}
},
);

return (id: string, data: TaskInput): void => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/createListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/setCookie.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/test/makeResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const makeResponse = (
args: {
ok?: boolean;
json?: Record<string, unknown>;
} = {}
} = {},
): Partial<Response> => {
const { ok = true, json = null } = args;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/test/queries.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen, waitFor } from '@testing-library/react';

export async function findTaskCheckbox(
task = 'the_task'
task = 'the_task',
): Promise<HTMLInputElement> {
const desc = await screen.findByText(task);
let checkbox;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/test/renderWithQueryProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -29,7 +29,7 @@ export function renderWithQueryProvider(
const view = render(
<ThemeProvider theme={theme}>
<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>
</ThemeProvider>
</ThemeProvider>,
);

return {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/test/withMutedReactQueryLogger.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setLogger } from 'react-query';

export async function withMutedReactQueryLogger(
callback: () => Promise<void>
callback: () => Promise<void>,
): Promise<void> {
setLogger({
log: () => {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/useDifferenceToNow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('useDifferenceToNow', () => {
const result = useDifferenceToNow(
makeTask({
due_timestamp: 1623873540,
})
}),
);

expect(result).toEqual('in 1h');
Expand All @@ -21,7 +21,7 @@ describe('useDifferenceToNow', () => {
const result = useDifferenceToNow(
makeTask({
due_timestamp: 1623869940,
})
}),
);

expect(result).toEqual('1h ago');
Expand All @@ -33,7 +33,7 @@ describe('useDifferenceToNow', () => {
const result = useDifferenceToNow(
makeTask({
due_timestamp: 1623873540 * 2,
})
}),
);

expect(result).toEqual('in 51y 5mo');
Expand All @@ -45,7 +45,7 @@ describe('useDifferenceToNow', () => {
const result = useDifferenceToNow(
makeTask({
due_timestamp: 1623873540,
})
}),
);

expect(result).toEqual('in 1h');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/useDocumentTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function useDocumentTitle(title: string, prevailOnUnmount = false) {
document.title = defaultTitle.current;
}
},
[prevailOnUnmount]
[prevailOnUnmount],
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/useFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function useFilters(): {

const { pref: filters, setPref: setFilters } = usePref(
'filters',
defaultFilters
defaultFilters,
);

const toggleFilter = useCallback(
Expand All @@ -50,7 +50,7 @@ export default function useFilters(): {
[filter]: !filters[filter],
});
},
[filters, setFilters]
[filters, setFilters],
);

return {
Expand Down
Loading

0 comments on commit 4117312

Please sign in to comment.