From 7acbca65ce20432775bf01c016fc3b21eed9b6da Mon Sep 17 00:00:00 2001 From: m5r Date: Sun, 1 Aug 2021 20:04:04 +0800 Subject: [PATCH] update prettier config --- app/api/newsletter/subscribe.ts | 2 +- app/auth/mutations/change-password.ts | 2 +- app/auth/mutations/forgot-password.test.ts | 2 +- app/auth/mutations/reset-password.test.ts | 10 +++++----- app/core/components/labeled-text-field.tsx | 2 +- app/core/hooks/use-customer-phone-number.ts | 2 +- app/core/layouts/layout/index.tsx | 2 +- app/messages/api/queue/fetch-messages.ts | 4 ++-- .../api/queue/insert-incoming-message.ts | 2 +- app/messages/api/queue/insert-messages.ts | 2 +- app/messages/api/queue/send-message.ts | 4 ++-- app/messages/api/webhook/incoming-message.ts | 4 ++-- app/messages/components/conversation.tsx | 4 ++-- app/messages/components/new-message-area.tsx | 4 ++-- app/messages/hooks/use-conversation.ts | 2 +- app/messages/hooks/use-known-recipients.ts | 2 +- app/messages/mutations/send-message.ts | 4 ++-- app/messages/queries/get-conversation.ts | 2 +- app/messages/queries/get-conversations.ts | 4 ++-- app/onboarding/api/queue/set-twilio-webhooks.ts | 2 +- app/onboarding/components/onboarding-layout.tsx | 2 +- app/onboarding/mutations/set-phone-number.ts | 4 ++-- .../mutations/set-twilio-api-fields.ts | 2 +- app/onboarding/pages/welcome/step-three.tsx | 4 ++-- app/onboarding/pages/welcome/step-two.tsx | 17 +++++++++++++---- app/phone-calls/api/queue/fetch-calls.ts | 4 ++-- app/phone-calls/queries/get-phone-calls.ts | 2 +- .../queries/get-customer-phone-number.ts | 2 +- app/settings/components/button.tsx | 2 +- app/settings/components/danger-zone.tsx | 4 ++-- mailers/forgot-password-mailer.ts | 2 +- package.json | 6 +++++- test/utils.tsx | 4 ++-- 33 files changed, 65 insertions(+), 52 deletions(-) diff --git a/app/api/newsletter/subscribe.ts b/app/api/newsletter/subscribe.ts index c6f4a38..cb15a40 100644 --- a/app/api/newsletter/subscribe.ts +++ b/app/api/newsletter/subscribe.ts @@ -15,7 +15,7 @@ const bodySchema = zod.object({ export default async function subscribeToNewsletter( req: BlitzApiRequest, - res: BlitzApiResponse + res: BlitzApiResponse, ) { if (req.method !== "POST") { const statusCode = 405; diff --git a/app/auth/mutations/change-password.ts b/app/auth/mutations/change-password.ts index 4da6f33..6c2cc95 100644 --- a/app/auth/mutations/change-password.ts +++ b/app/auth/mutations/change-password.ts @@ -20,5 +20,5 @@ export default resolver.pipe( }); return true; - } + }, ); diff --git a/app/auth/mutations/forgot-password.test.ts b/app/auth/mutations/forgot-password.test.ts index 0cbe0a6..1ceeb83 100644 --- a/app/auth/mutations/forgot-password.test.ts +++ b/app/auth/mutations/forgot-password.test.ts @@ -18,7 +18,7 @@ jest.mock("preview-email", () => jest.fn()); describe.skip("forgotPassword mutation", () => { it("does not throw error if user doesn't exist", async () => { await expect( - forgotPassword({ email: "no-user@email.com" }, {} as Ctx) + forgotPassword({ email: "no-user@email.com" }, {} as Ctx), ).resolves.not.toThrow(); }); diff --git a/app/auth/mutations/reset-password.test.ts b/app/auth/mutations/reset-password.test.ts index eab3d02..d7f0b04 100644 --- a/app/auth/mutations/reset-password.test.ts +++ b/app/auth/mutations/reset-password.test.ts @@ -53,21 +53,21 @@ describe.skip("resetPassword mutation", () => { // Non-existent token await expect( - resetPassword({ token: "no-token", password: "", passwordConfirmation: "" }, mockCtx) + resetPassword({ token: "no-token", password: "", passwordConfirmation: "" }, mockCtx), ).rejects.toThrowError(); // Expired token await expect( resetPassword( { token: expiredToken, password: newPassword, passwordConfirmation: newPassword }, - mockCtx - ) + mockCtx, + ), ).rejects.toThrowError(); // Good token await resetPassword( { token: goodToken, password: newPassword, passwordConfirmation: newPassword }, - mockCtx + mockCtx, ); // Delete's the token @@ -77,7 +77,7 @@ describe.skip("resetPassword mutation", () => { // Updates user's password const updatedUser = await db.user.findFirst({ where: { id: user.id } }); expect(await SecurePassword.verify(updatedUser!.hashedPassword, newPassword)).toBe( - SecurePassword.VALID + SecurePassword.VALID, ); }); }); diff --git a/app/core/components/labeled-text-field.tsx b/app/core/components/labeled-text-field.tsx index 7560d07..aaed95c 100644 --- a/app/core/components/labeled-text-field.tsx +++ b/app/core/components/labeled-text-field.tsx @@ -52,7 +52,7 @@ export const LabeledTextField = forwardRef ); - } + }, ); export default LabeledTextField; diff --git a/app/core/hooks/use-customer-phone-number.ts b/app/core/hooks/use-customer-phone-number.ts index 791ad6c..e1d1544 100644 --- a/app/core/hooks/use-customer-phone-number.ts +++ b/app/core/hooks/use-customer-phone-number.ts @@ -8,7 +8,7 @@ export default function useCustomerPhoneNumber() { const [customerPhoneNumber] = useQuery( getCurrentCustomerPhoneNumber, {}, - { enabled: hasCompletedOnboarding } + { enabled: hasCompletedOnboarding }, ); return customerPhoneNumber; diff --git a/app/core/layouts/layout/index.tsx b/app/core/layouts/layout/index.tsx index 1f9bb8a..8f564e6 100644 --- a/app/core/layouts/layout/index.tsx +++ b/app/core/layouts/layout/index.tsx @@ -114,7 +114,7 @@ const ErrorBoundary = withRouter( return this.props.children; } - } + }, ); export default Layout; diff --git a/app/messages/api/queue/fetch-messages.ts b/app/messages/api/queue/fetch-messages.ts index db2ae4f..e05a415 100644 --- a/app/messages/api/queue/fetch-messages.ts +++ b/app/messages/api/queue/fetch-messages.ts @@ -21,7 +21,7 @@ const fetchMessagesQueue = Queue("api/queue/fetch-messages", async ({ c }), ]); const messages = [...messagesSent, ...messagesReceived].sort( - (a, b) => a.dateCreated.getTime() - b.dateCreated.getTime() + (a, b) => a.dateCreated.getTime() - b.dateCreated.getTime(), ); await insertMessagesQueue.enqueue( @@ -31,7 +31,7 @@ const fetchMessagesQueue = Queue("api/queue/fetch-messages", async ({ c }, { id: `insert-messages-${customerId}`, - } + }, ); }); diff --git a/app/messages/api/queue/insert-incoming-message.ts b/app/messages/api/queue/insert-incoming-message.ts index ced6c9c..1f7f7ef 100644 --- a/app/messages/api/queue/insert-incoming-message.ts +++ b/app/messages/api/queue/insert-incoming-message.ts @@ -46,7 +46,7 @@ const insertIncomingMessageQueue = Queue( sentAt: new Date(message.dateCreated), }, }); - } + }, ); export default insertIncomingMessageQueue; diff --git a/app/messages/api/queue/insert-messages.ts b/app/messages/api/queue/insert-messages.ts index a074a14..7afd029 100644 --- a/app/messages/api/queue/insert-messages.ts +++ b/app/messages/api/queue/insert-messages.ts @@ -29,7 +29,7 @@ const insertMessagesQueue = Queue( .sort((a, b) => a.sentAt.getTime() - b.sentAt.getTime()); await db.message.createMany({ data: sms }); - } + }, ); export default insertMessagesQueue; diff --git a/app/messages/api/queue/send-message.ts b/app/messages/api/queue/send-message.ts index a8ec8c1..96cfe51 100644 --- a/app/messages/api/queue/send-message.ts +++ b/app/messages/api/queue/send-message.ts @@ -19,7 +19,7 @@ const sendMessageQueue = Queue( try { const message = await twilio( customer!.accountSid!, - customer!.authToken! + customer!.authToken!, ).messages.create({ body: content, to, @@ -37,7 +37,7 @@ const sendMessageQueue = Queue( }, { retry: ["1min"], - } + }, ); export default sendMessageQueue; diff --git a/app/messages/api/webhook/incoming-message.ts b/app/messages/api/webhook/incoming-message.ts index 0f1c2ba..9041469 100644 --- a/app/messages/api/webhook/incoming-message.ts +++ b/app/messages/api/webhook/incoming-message.ts @@ -61,7 +61,7 @@ export default async function incomingMessageHandler(req: BlitzApiRequest, res: customer.authToken, twilioSignature, url, - req.body + req.body, ); if (!isRequestValid) { const statusCode = 400; @@ -83,7 +83,7 @@ export default async function incomingMessageHandler(req: BlitzApiRequest, res: messageSid, customerId: customer.id, }, - { id: messageSid } + { id: messageSid }, ); res.status(200).end(); diff --git a/app/messages/components/conversation.tsx b/app/messages/components/conversation.tsx index 730350d..7f22c93 100644 --- a/app/messages/components/conversation.tsx +++ b/app/messages/components/conversation.tsx @@ -57,7 +57,7 @@ export default function Conversation() {
{message.content} diff --git a/app/messages/components/new-message-area.tsx b/app/messages/components/new-message-area.tsx index 0e87568..451bc26 100644 --- a/app/messages/components/new-message-area.tsx +++ b/app/messages/components/new-message-area.tsx @@ -25,7 +25,7 @@ const NewMessageArea: FunctionComponent = ({ recipient, onSend }) => { const sendMessageMutation = useMutation(sendMessage)[0]; const { setQueryData: setConversationsQueryData, refetch: refetchConversations } = useQuery( getConversationsQuery, - {} + {}, )[1]; const { register, @@ -65,7 +65,7 @@ const NewMessageArea: FunctionComponent = ({ recipient, onSend }) => { nextConversations[recipient] = [...nextConversations[recipient]!, message]; return nextConversations; }, - { refetch: false } + { refetch: false }, ); setValue("content", ""); onSend?.(); diff --git a/app/messages/hooks/use-conversation.ts b/app/messages/hooks/use-conversation.ts index adde552..d3534ac 100644 --- a/app/messages/hooks/use-conversation.ts +++ b/app/messages/hooks/use-conversation.ts @@ -15,6 +15,6 @@ export default function useConversation(recipient: string) { return conversations[recipient]!; }, keepPreviousData: true, - } + }, ); } diff --git a/app/messages/hooks/use-known-recipients.ts b/app/messages/hooks/use-known-recipients.ts index 633fb24..dc311c0 100644 --- a/app/messages/hooks/use-known-recipients.ts +++ b/app/messages/hooks/use-known-recipients.ts @@ -9,6 +9,6 @@ export default function useKnownRecipients() { select(conversations) { return Object.keys(conversations); }, - } + }, ); } diff --git a/app/messages/mutations/send-message.ts b/app/messages/mutations/send-message.ts index f07c321..66ecca7 100644 --- a/app/messages/mutations/send-message.ts +++ b/app/messages/mutations/send-message.ts @@ -54,7 +54,7 @@ export default resolver.pipe( }, { id: message.id, - } + }, ); - } + }, ); diff --git a/app/messages/queries/get-conversation.ts b/app/messages/queries/get-conversation.ts index 62ad800..74c6797 100644 --- a/app/messages/queries/get-conversation.ts +++ b/app/messages/queries/get-conversation.ts @@ -27,5 +27,5 @@ export default resolver.pipe( content: decrypt(message.content, customer!.encryptionKey), }; }); - } + }, ); diff --git a/app/messages/queries/get-conversations.ts b/app/messages/queries/get-conversations.ts index d9a741a..2680ed7 100644 --- a/app/messages/queries/get-conversations.ts +++ b/app/messages/queries/get-conversations.ts @@ -33,8 +33,8 @@ export default resolver.pipe(resolver.authorize(), async (_ = null, context) => } conversations = Object.fromEntries( Object.entries(conversations).sort( - ([, a], [, b]) => b[b.length - 1]!.sentAt.getTime() - a[a.length - 1]!.sentAt.getTime() - ) + ([, a], [, b]) => b[b.length - 1]!.sentAt.getTime() - a[a.length - 1]!.sentAt.getTime(), + ), ); return conversations; diff --git a/app/onboarding/api/queue/set-twilio-webhooks.ts b/app/onboarding/api/queue/set-twilio-webhooks.ts index 4940476..aac7ca4 100644 --- a/app/onboarding/api/queue/set-twilio-webhooks.ts +++ b/app/onboarding/api/queue/set-twilio-webhooks.ts @@ -37,7 +37,7 @@ const setTwilioWebhooks = Queue( voiceApplicationSid: twimlAppSid, }), ]); - } + }, ); export default setTwilioWebhooks; diff --git a/app/onboarding/components/onboarding-layout.tsx b/app/onboarding/components/onboarding-layout.tsx index 2d46c2e..06944a2 100644 --- a/app/onboarding/components/onboarding-layout.tsx +++ b/app/onboarding/components/onboarding-layout.tsx @@ -65,7 +65,7 @@ const OnboardingLayout: FunctionComponent = ({ children, currentStep, pre key={step} className={clsx( stepIdx !== steps.length - 1 ? "pr-20 sm:pr-32" : "", - "relative" + "relative", )} > {isComplete ? ( diff --git a/app/onboarding/mutations/set-phone-number.ts b/app/onboarding/mutations/set-phone-number.ts index 4538f60..a750928 100644 --- a/app/onboarding/mutations/set-phone-number.ts +++ b/app/onboarding/mutations/set-phone-number.ts @@ -20,7 +20,7 @@ export default resolver.pipe( const customerId = customer!.id; const phoneNumbers = await twilio( customer!.accountSid!, - customer!.authToken! + customer!.authToken!, ).incomingPhoneNumbers.list(); const phoneNumber = phoneNumbers.find((phoneNumber) => phoneNumber.sid === phoneNumberSid)!; await db.phoneNumber.create({ @@ -36,5 +36,5 @@ export default resolver.pipe( fetchCallsQueue.enqueue({ customerId }, { id: `fetch-messages-${customerId}` }), setTwilioWebhooks.enqueue({ customerId }, { id: `set-twilio-webhooks-${customerId}` }), ]); - } + }, ); diff --git a/app/onboarding/mutations/set-twilio-api-fields.ts b/app/onboarding/mutations/set-twilio-api-fields.ts index c2290bc..8ed52fe 100644 --- a/app/onboarding/mutations/set-twilio-api-fields.ts +++ b/app/onboarding/mutations/set-twilio-api-fields.ts @@ -22,5 +22,5 @@ export default resolver.pipe( authToken: twilioAuthToken, }, }); - } + }, ); diff --git a/app/onboarding/pages/welcome/step-three.tsx b/app/onboarding/pages/welcome/step-three.tsx index c50b46f..0b7fb67 100644 --- a/app/onboarding/pages/welcome/step-three.tsx +++ b/app/onboarding/pages/welcome/step-three.tsx @@ -70,7 +70,7 @@ const StepThree: BlitzPage = ({ availablePhoneNumbers }) => { className={clsx( "max-w-[240px] mt-6 mx-auto w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 text-base font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 sm:text-sm", !isSubmitting && "bg-primary-600 hover:bg-primary-700", - isSubmitting && "bg-primary-400 cursor-not-allowed" + isSubmitting && "bg-primary-400 cursor-not-allowed", )} > Save @@ -131,7 +131,7 @@ export const getServerSideProps: GetServerSideProps = async ({ req, res } const incomingPhoneNumbers = await twilio( customer.accountSid, - customer.authToken + customer.authToken, ).incomingPhoneNumbers.list(); const phoneNumbers = incomingPhoneNumbers.map(({ phoneNumber, sid }) => ({ phoneNumber, sid })); diff --git a/app/onboarding/pages/welcome/step-two.tsx b/app/onboarding/pages/welcome/step-two.tsx index 7aee88c..5a7c350 100644 --- a/app/onboarding/pages/welcome/step-two.tsx +++ b/app/onboarding/pages/welcome/step-two.tsx @@ -1,7 +1,8 @@ +import type { FunctionComponent } from "react"; +import { Suspense, useEffect } from "react"; import type { BlitzPage, GetServerSideProps } from "blitz"; import { getSession, Routes, useMutation, useRouter } from "blitz"; import clsx from "clsx"; -import { useEffect } from "react"; import { useForm } from "react-hook-form"; import db from "db"; @@ -80,7 +81,7 @@ const StepTwo: BlitzPage = () => { className={clsx( "max-w-[240px] mx-auto w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 text-base font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 sm:text-sm", !isSubmitting && "bg-primary-600 hover:bg-primary-700", - isSubmitting && "bg-primary-400 cursor-not-allowed" + isSubmitting && "bg-primary-400 cursor-not-allowed", )} > Save @@ -90,7 +91,15 @@ const StepTwo: BlitzPage = () => { ); }; -StepTwo.getLayout = function StepTwoLayout(page) { +StepTwo.getLayout = (page) => { + return ( + + {page} + + ); +}; + +const StepTwoLayout: FunctionComponent = ({ children }) => { const { customer } = useCurrentCustomer(); const initialAuthToken = customer?.authToken ?? ""; const initialAccountSid = customer?.accountSid ?? ""; @@ -106,7 +115,7 @@ StepTwo.getLayout = function StepTwoLayout(page) { } previous={{ href: Routes.StepOne().pathname, label: "Back" }} > - {page} + {children} ); }; diff --git a/app/phone-calls/api/queue/fetch-calls.ts b/app/phone-calls/api/queue/fetch-calls.ts index 51e2c08..651af9d 100644 --- a/app/phone-calls/api/queue/fetch-calls.ts +++ b/app/phone-calls/api/queue/fetch-calls.ts @@ -21,7 +21,7 @@ const fetchCallsQueue = Queue("api/queue/fetch-calls", async ({ custome }), ]); const calls = [...callsSent, ...callsReceived].sort( - (a, b) => a.dateCreated.getTime() - b.dateCreated.getTime() + (a, b) => a.dateCreated.getTime() - b.dateCreated.getTime(), ); await insertCallsQueue.enqueue( @@ -31,7 +31,7 @@ const fetchCallsQueue = Queue("api/queue/fetch-calls", async ({ custome }, { id: `insert-calls-${customerId}`, - } + }, ); }); diff --git a/app/phone-calls/queries/get-phone-calls.ts b/app/phone-calls/queries/get-phone-calls.ts index 36bf1e1..0a68db1 100644 --- a/app/phone-calls/queries/get-phone-calls.ts +++ b/app/phone-calls/queries/get-phone-calls.ts @@ -28,5 +28,5 @@ export default resolver.pipe( hasMore, count, }; - } + }, ); diff --git a/app/phone-numbers/queries/get-customer-phone-number.ts b/app/phone-numbers/queries/get-customer-phone-number.ts index e240413..5496bb7 100644 --- a/app/phone-numbers/queries/get-customer-phone-number.ts +++ b/app/phone-numbers/queries/get-customer-phone-number.ts @@ -15,5 +15,5 @@ export default resolver.pipe(resolver.zod(GetCustomerPhoneNumber), async ({ cust phoneNumber: true, phoneNumberSid: true, }, - }) + }), ); diff --git a/app/settings/components/button.tsx b/app/settings/components/button.tsx index 4d731f8..c90d7cd 100644 --- a/app/settings/components/button.tsx +++ b/app/settings/components/button.tsx @@ -18,7 +18,7 @@ const Button: FunctionComponent = ({ children, type, variant, onClick, is { [VARIANTS_STYLES[variant].base]: !isDisabled, [VARIANTS_STYLES[variant].disabled]: isDisabled, - } + }, )} disabled={isDisabled} > diff --git a/app/settings/components/danger-zone.tsx b/app/settings/components/danger-zone.tsx index 6df63e3..0799c76 100644 --- a/app/settings/components/danger-zone.tsx +++ b/app/settings/components/danger-zone.tsx @@ -72,7 +72,7 @@ export default function DangerZone() { { "bg-red-400 cursor-not-allowed": isDeletingUser, "bg-red-600 hover:bg-red-700": !isDeletingUser, - } + }, )} onClick={onConfirm} disabled={isDeletingUser} @@ -87,7 +87,7 @@ export default function DangerZone() { { "bg-gray-50 cursor-not-allowed": isDeletingUser, "hover:bg-gray-50": !isDeletingUser, - } + }, )} onClick={closeModal} disabled={isDeletingUser} diff --git a/mailers/forgot-password-mailer.ts b/mailers/forgot-password-mailer.ts index 6148cad..964cf6f 100644 --- a/mailers/forgot-password-mailer.ts +++ b/mailers/forgot-password-mailer.ts @@ -36,7 +36,7 @@ export function forgotPasswordMailer({ to, token }: ResetPasswordMailer) { // TODO - send the production email, like this: // await postmark.sendEmail(msg) throw new Error( - "No production email implementation in mailers/forgotPasswordMailer" + "No production email implementation in mailers/forgotPasswordMailer", ); } else { // Preview email in the browser diff --git a/package.json b/package.json index 69a1e04..bd5c0e2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,11 @@ "semi": true, "useTabs": true, "tabWidth": 4, - "printWidth": 100 + "printWidth": 100, + "trailingComma": "all", + "jsxBracketSameLine": false, + "quoteProps": "as-needed", + "singleQuote": false }, "lint-staged": { "*.{js,ts,tsx}": [ diff --git a/test/utils.tsx b/test/utils.tsx index 13aa41a..2ebe85a 100644 --- a/test/utils.tsx +++ b/test/utils.tsx @@ -26,7 +26,7 @@ export * from "@testing-library/react"; // -------------------------------------------------- export function render( ui: RenderUI, - { wrapper, router, dehydratedState, ...options }: RenderOptions = {} + { wrapper, router, dehydratedState, ...options }: RenderOptions = {}, ) { if (!wrapper) { // Add a default context wrapper if one isn't supplied from the test @@ -54,7 +54,7 @@ export function render( // -------------------------------------------------- export function renderHook( hook: RenderHook, - { wrapper, router, dehydratedState, ...options }: RenderHookOptions = {} + { wrapper, router, dehydratedState, ...options }: RenderHookOptions = {}, ) { if (!wrapper) { // Add a default context wrapper if one isn't supplied from the test