diff --git a/.eslintrc.js b/.eslintrc.js index b33e2ecde..3eebdd1b5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -63,6 +63,7 @@ module.exports = { ignoreMemberSort: false, }, ], + curly: 'error', eqeqeq: 'error', 'no-console': 'error', '@typescript-eslint/no-loss-of-precision': 'warn', diff --git a/onesky/download.js b/onesky/download.js index 5d57b2c5a..a8e1d6860 100644 --- a/onesky/download.js +++ b/onesky/download.js @@ -24,8 +24,9 @@ onesky fileName: 'translation.json', }) .then(function (langContent) { - if (!fs.existsSync('public/locales/' + lang.code)) + if (!fs.existsSync('public/locales/' + lang.code)) { fs.promises.mkdir('public/locales/' + lang.code); + } fs.promises.writeFile( 'public/locales/' + lang.code + '/translation.json', langContent, diff --git a/pages/accountLists/[accountListId].page.tsx b/pages/accountLists/[accountListId].page.tsx index 5b0a6d93c..ba997745b 100644 --- a/pages/accountLists/[accountListId].page.tsx +++ b/pages/accountLists/[accountListId].page.tsx @@ -40,7 +40,9 @@ const AccountListIdPage = ({ }, []); useEffect(() => { - if (!modal || dialogOpen) return; + if (!modal || dialogOpen) { + return; + } switch (modal) { case 'AddContact': setSelectedMenuItem(AddMenuItemsEnum.NewContact); diff --git a/pages/api/Schema/Settings/Integrations/Mailchimp/mailchimpAccount/datahandler.ts b/pages/api/Schema/Settings/Integrations/Mailchimp/mailchimpAccount/datahandler.ts index 05ef3a835..8ee5914f5 100644 --- a/pages/api/Schema/Settings/Integrations/Mailchimp/mailchimpAccount/datahandler.ts +++ b/pages/api/Schema/Settings/Integrations/Mailchimp/mailchimpAccount/datahandler.ts @@ -50,7 +50,9 @@ export const MailchimpAccount = ( ): MailchimpAccountCamel[] => { // Returning inside an array so I can mock an empty response from GraphQL // without the test thinking I want it to create custom random test data. - if (!data) return []; + if (!data) { + return []; + } const attributes = {} as Omit; Object.keys(data.attributes).forEach((key) => { attributes[snakeToCamel(key)] = data.attributes[key]; diff --git a/pages/api/Schema/Settings/Integrations/Prayerletters/prayerlettersAccount/datahandler.ts b/pages/api/Schema/Settings/Integrations/Prayerletters/prayerlettersAccount/datahandler.ts index 86bcf9d47..5d8b09ab0 100644 --- a/pages/api/Schema/Settings/Integrations/Prayerletters/prayerlettersAccount/datahandler.ts +++ b/pages/api/Schema/Settings/Integrations/Prayerletters/prayerlettersAccount/datahandler.ts @@ -22,7 +22,9 @@ export const PrayerlettersAccount = ( ): PrayerlettersAccountCamel[] => { // Returning inside an array so I can mock an empty response from GraphQL // without the test thinking I want it to create custom random test data. - if (!data) return []; + if (!data) { + return []; + } return [ { id: data.id, diff --git a/pages/api/auth/[...nextauth].page.ts b/pages/api/auth/[...nextauth].page.ts index a0719344d..0d49f8a58 100644 --- a/pages/api/auth/[...nextauth].page.ts +++ b/pages/api/auth/[...nextauth].page.ts @@ -175,7 +175,9 @@ const Auth = (req: NextApiRequest, res: NextApiResponse): Promise => { user.userID = userInfo.userID; user.impersonating = userInfo.impersonating; user.impersonatorApiToken = userInfo.impersonatorApiToken; - if (cookies) res.setHeader('Set-Cookie', cookies); + if (cookies) { + res.setHeader('Set-Cookie', cookies); + } }; // An API token is not required for the apiOauthSignIn or oktaSignIn mutations @@ -266,13 +268,17 @@ const Auth = (req: NextApiRequest, res: NextApiResponse): Promise => { }; }, redirect({ url, baseUrl }) { - if (url.startsWith(baseUrl)) return url; + if (url.startsWith(baseUrl)) { + return url; + } if (url === 'signOut' && AUTH_PROVIDER === 'OKTA') { return `https://signon.okta.com/login/signout?fromURI=${encodeURIComponent( process.env.OKTA_SIGNOUT_REDIRECT_URL ?? '', )}`; } - if (url.startsWith('/')) return new URL(url, baseUrl).toString(); + if (url.startsWith('/')) { + return new URL(url, baseUrl).toString(); + } return baseUrl; }, }, diff --git a/pages/api/mpdx-web-handoff.page.ts b/pages/api/mpdx-web-handoff.page.ts index 61426b6f1..a9c2c755c 100644 --- a/pages/api/mpdx-web-handoff.page.ts +++ b/pages/api/mpdx-web-handoff.page.ts @@ -18,10 +18,14 @@ const defineRedirectUrl = ({ rest, }: DefineRedirectUrlProps): string => { let redirectUrl = `${process.env.SITE_URL}/accountLists/${accountListId}`; - if (path) redirectUrl += path; + if (path) { + redirectUrl += path; + } if (rest) { for (const [key, value] of Object.entries(rest)) { - if (typeof value !== 'string') continue; + if (typeof value !== 'string') { + continue; + } const contactsAndReportsRegex = new RegExp('/contacts|/reports'); if (contactsAndReportsRegex.test(path) && key === 'contactId') { if (redirectUrl.includes('?')) { @@ -30,21 +34,27 @@ const defineRedirectUrl = ({ `/${value}`, `?${redirectUrl.split('?')[1]}`, ].join(''); - } else redirectUrl += `/${value}`; + } else { + redirectUrl += `/${value}`; + } continue; } else if (path.includes('/tasks') && key === 'group') { const typeDetails = taskFiltersTabs.find( (item) => item.name.toLowerCase() === value.toLowerCase(), ); if (typeDetails) { - if (!redirectUrl.includes('?')) redirectUrl += '?'; + if (!redirectUrl.includes('?')) { + redirectUrl += '?'; + } redirectUrl += `filters=${encodeURIComponent( JSON.stringify(typeDetails.activeFiltersOptions), )}`; continue; } } - if (!redirectUrl.includes('?')) redirectUrl += '?'; + if (!redirectUrl.includes('?')) { + redirectUrl += '?'; + } redirectUrl += `${key}=${value}&`; } } @@ -110,7 +120,9 @@ const mpdxWebHandoff = async ( ); } // Removes duplicates and set cookies - if (cookies) res.setHeader('Set-Cookie', [...new Set(cookies)]); + if (cookies) { + res.setHeader('Set-Cookie', [...new Set(cookies)]); + } res.redirect(jwtToken ? redirectUrl : `${process.env.SITE_URL}/login`); } catch (err) { res.redirect(`${process.env.SITE_URL}/`); diff --git a/pages/login.page.tsx b/pages/login.page.tsx index 0bb4f59e5..0146d2d25 100644 --- a/pages/login.page.tsx +++ b/pages/login.page.tsx @@ -25,7 +25,9 @@ const Login = ({ const { appName } = useGetAppSettings(); useEffect(() => { - if (immediateSignIn) signIn(signInAuthProviderId); + if (immediateSignIn) { + signIn(signInAuthProviderId); + } }, []); return ( diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx index 7c2e40183..159a4b4e6 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx @@ -89,7 +89,9 @@ export const ContactTags: React.FC = ({ { resetForm }: FormikHelpers<{ tagList: string[] & never[] }>, ): Promise => { resetForm(); - if (tagList.length === 0) return; + if (tagList.length === 0) { + return; + } const { data } = await updateContactTags({ variables: { diff --git a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/TaskDate/TaskDate.tsx b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/TaskDate/TaskDate.tsx index 75e1889fd..2eb79a3ac 100644 --- a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/TaskDate/TaskDate.tsx +++ b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTaskRow/TaskDate/TaskDate.tsx @@ -47,7 +47,9 @@ export const TaskDate: React.FC = ({ taskDate, small, }) => { - if (!taskDate) return null; + if (!taskDate) { + return null; + } const locale = useLocale(); const isLate = isComplete ? false : taskDate < DateTime.local(); const showYear = taskDate.year !== DateTime.local().year; diff --git a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTasksTab.tsx b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTasksTab.tsx index 52e2557a3..346c28600 100644 --- a/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTasksTab.tsx +++ b/src/components/Contacts/ContactDetails/ContactTasksTab/ContactTasksTab.tsx @@ -148,7 +148,9 @@ export const ContactTasksTab: React.FC = ({ const { t } = useTranslation(); useEffect(() => { - if (!infiniteListRef.current) return; + if (!infiniteListRef.current) { + return; + } setInfiniteListRectTop(infiniteListRef.current.getBoundingClientRect().top); }, [contactId, contactDetailsLoaded]); diff --git a/src/components/Contacts/ContactsContext/ContactsContext.tsx b/src/components/Contacts/ContactsContext/ContactsContext.tsx index 5f930228e..c4af76d21 100644 --- a/src/components/Contacts/ContactsContext/ContactsContext.tsx +++ b/src/components/Contacts/ContactsContext/ContactsContext.tsx @@ -237,7 +237,9 @@ export const ContactsProvider: React.FC = ({ }, [isReady, contactId]); useEffect(() => { - if (userOptionsLoading) return; + if (userOptionsLoading) { + return; + } setContactFocus( contactId && diff --git a/src/components/Contacts/ContactsMap/ContactsMap.tsx b/src/components/Contacts/ContactsMap/ContactsMap.tsx index 1e148ae82..d3c039621 100644 --- a/src/components/Contacts/ContactsMap/ContactsMap.tsx +++ b/src/components/Contacts/ContactsMap/ContactsMap.tsx @@ -96,7 +96,9 @@ export const ContactsMap: React.FC = ({}) => { const beacon = document.querySelector( '#beacon-container .BeaconFabButtonFrame', ) as HTMLElement; - if (!beacon) return; + if (!beacon) { + return; + } beacon.style.setProperty('right', '60px', 'important'); return () => beacon.style.setProperty('right', '20px'); }, []); @@ -109,8 +111,9 @@ export const ContactsMap: React.FC = ({}) => { // Update the map to contain all of the contacts' locations const bounds = new window.google.maps.LatLngBounds(); data.forEach((contact) => { - if (typeof contact.lat === 'number' && typeof contact.lng === 'number') + if (typeof contact.lat === 'number' && typeof contact.lng === 'number') { bounds.extend({ lat: contact.lat, lng: contact.lng }); + } }); mapRef.current.fitBounds(bounds); }, [data, isLoaded, mapRef.current]); diff --git a/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/Item/Item.tsx b/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/Item/Item.tsx index 974b12288..4723f0633 100644 --- a/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/Item/Item.tsx +++ b/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/Item/Item.tsx @@ -79,7 +79,9 @@ const NotificationMenuItem = ({ }, }, update: (cache) => { - if (!optimisticResponse) return; + if (!optimisticResponse) { + return; + } const query = { query: GetNotificationsDocument, @@ -102,7 +104,9 @@ const NotificationMenuItem = ({ }, }); } - if (typeof onClick === 'function') onClick(); + if (typeof onClick === 'function') { + onClick(); + } }; let message; diff --git a/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/NotificationMenu.tsx b/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/NotificationMenu.tsx index ab5c8f8d0..0a523866b 100644 --- a/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/NotificationMenu.tsx +++ b/src/components/Layouts/Primary/TopBar/Items/NotificationMenu/NotificationMenu.tsx @@ -169,7 +169,9 @@ const NotificationMenu = ({ }, }, update: (cache) => { - if (!optimisticResponse) return; + if (!optimisticResponse) { + return; + } const query = { query: GetNotificationsDocument, diff --git a/src/components/Reports/FourteenMonthReports/FourteenMonthReport.tsx b/src/components/Reports/FourteenMonthReports/FourteenMonthReport.tsx index ad3dea76a..f2542829f 100644 --- a/src/components/Reports/FourteenMonthReports/FourteenMonthReport.tsx +++ b/src/components/Reports/FourteenMonthReports/FourteenMonthReport.tsx @@ -110,7 +110,9 @@ export const FourteenMonthReport: React.FC = ({ }); const csvData = useMemo(() => { - if (!contacts) return []; + if (!contacts) { + return []; + } const months = data?.fourteenMonthReport.currencyGroups[0]?.totals.months ?? []; diff --git a/src/components/Reports/FourteenMonthReports/Layout/Table/Table.tsx b/src/components/Reports/FourteenMonthReports/Layout/Table/Table.tsx index b0a55e03d..236b4db0c 100644 --- a/src/components/Reports/FourteenMonthReports/Layout/Table/Table.tsx +++ b/src/components/Reports/FourteenMonthReports/Layout/Table/Table.tsx @@ -106,7 +106,9 @@ export const FourteenMonthReportTable: React.FC< return contact.months.reduce((partialSum, month) => { return partialSum + month.salaryCurrencyTotal; }, 0); - } else return 0; + } else { + return 0; + } }, [contact]); return ( = ({ isSpouse }) => { const onSubmit = async (attributes: FormikSchema) => { const { selectedAccountId, accept } = attributes; - if (!currentAccount?.id || !accept) return; + if (!currentAccount?.id || !accept) { + return; + } await mergeAccountList({ variables: { diff --git a/src/components/Settings/Organization/AccountLists/AccountListRow/AccountListCoachesOrUsers/AccountListCoachesOrUsers.tsx b/src/components/Settings/Organization/AccountLists/AccountListRow/AccountListCoachesOrUsers/AccountListCoachesOrUsers.tsx index 8105559b9..31b74cd99 100644 --- a/src/components/Settings/Organization/AccountLists/AccountListRow/AccountListCoachesOrUsers/AccountListCoachesOrUsers.tsx +++ b/src/components/Settings/Organization/AccountLists/AccountListRow/AccountListCoachesOrUsers/AccountListCoachesOrUsers.tsx @@ -83,7 +83,9 @@ export const AccountListCoachesOrUsers: React.FC = ({ {emails && emails.map((email, idx) => { - if (!email?.id) return null; + if (!email?.id) { + return null; + } return ( = ({ const { enqueueSnackbar } = useSnackbar(); const haneleInviteDelete = async (invite) => { - if (!invite?.id) return; + if (!invite?.id) { + return; + } await adminDeleteOrganizationInvite({ variables: { diff --git a/src/components/Settings/Organization/AccountLists/AccountLists.tsx b/src/components/Settings/Organization/AccountLists/AccountLists.tsx index bdf7fff89..9fb1b2d52 100644 --- a/src/components/Settings/Organization/AccountLists/AccountLists.tsx +++ b/src/components/Settings/Organization/AccountLists/AccountLists.tsx @@ -37,8 +37,9 @@ export const AccountLists: React.FC = () => { const pagination = data?.searchOrganizationsAccountLists.pagination; useEffect(() => { - if (!accountListsRef.current) return; - if (!window.visualViewport?.height) return; + if (!accountListsRef.current || !window.visualViewport?.height) { + return; + } // 24px for the padding which the parent page has added. setInfiniteListHeight( window.visualViewport.height - diff --git a/src/components/Settings/Organization/Contacts/Contacts.tsx b/src/components/Settings/Organization/Contacts/Contacts.tsx index ab3bc46ba..a495b4b64 100644 --- a/src/components/Settings/Organization/Contacts/Contacts.tsx +++ b/src/components/Settings/Organization/Contacts/Contacts.tsx @@ -37,8 +37,9 @@ export const Contacts: React.FC = () => { const pagination = data?.searchOrganizationsContacts.pagination; useEffect(() => { - if (!contactsRef.current) return; - if (!window.visualViewport?.height) return; + if (!contactsRef.current || !window.visualViewport?.height) { + return; + } // 24px for the padding which the parent page has added. setInfiniteListHeight( window.visualViewport.height - diff --git a/src/components/Settings/integrations/Google/Modals/EditGoogleAccountModal.tsx b/src/components/Settings/integrations/Google/Modals/EditGoogleAccountModal.tsx index 032dc08ab..d44dcd974 100644 --- a/src/components/Settings/integrations/Google/Modals/EditGoogleAccountModal.tsx +++ b/src/components/Settings/integrations/Google/Modals/EditGoogleAccountModal.tsx @@ -85,7 +85,9 @@ export const EditGoogleAccountModal: React.FC = ({ const handleToggleCalendarIntegration = async ( enableIntegration: boolean, ) => { - if (!tabSelected) return; + if (!tabSelected) { + return; + } setIsSubmitting(true); if (!googleAccountDetails && enableIntegration) { diff --git a/src/components/Settings/integrations/Google/Modals/EditGoogleIntegrationForm.tsx b/src/components/Settings/integrations/Google/Modals/EditGoogleIntegrationForm.tsx index 59eef1a01..1f1b51690 100644 --- a/src/components/Settings/integrations/Google/Modals/EditGoogleIntegrationForm.tsx +++ b/src/components/Settings/integrations/Google/Modals/EditGoogleIntegrationForm.tsx @@ -201,7 +201,9 @@ export const EditGoogleIntegrationForm: React.FC< {actvities?.map((activity) => { - if (!activity?.id || !activity?.value) return null; + if (!activity?.id || !activity?.value) { + return null; + } const activityId = `${activity.value}-Checkbox`; const isChecked = calendarIntegrations.includes( activity?.id ?? '', diff --git a/src/components/Settings/integrations/Organization/Modals/OrganizationAddAccountModal.tsx b/src/components/Settings/integrations/Organization/Modals/OrganizationAddAccountModal.tsx index 7b41ce322..588358b0b 100644 --- a/src/components/Settings/integrations/Organization/Modals/OrganizationAddAccountModal.tsx +++ b/src/components/Settings/integrations/Organization/Modals/OrganizationAddAccountModal.tsx @@ -121,7 +121,9 @@ export const OrganizationAddAccountModal: React.FC< const { getOrganizationOauthUrl: getOauthUrl } = useOauthUrl(); const onSubmit = async (attributes: Partial) => { - if (!attributes?.selectedOrganization) return; + if (!attributes?.selectedOrganization) { + return; + } const { apiClass, oauth, id } = attributes.selectedOrganization; const type = getOrganizationType(apiClass, oauth); @@ -134,7 +136,9 @@ export const OrganizationAddAccountModal: React.FC< return; } - if (!accountListId) return; + if (!accountListId) { + return; + } const createAccountAttributes: { organizationId: string; diff --git a/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx b/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx index 44ae78148..ad5c97b37 100644 --- a/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx +++ b/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx @@ -64,7 +64,9 @@ export const OrganizationImportDataSyncModal: React.FC< const handleSubmit = async (event) => { event.preventDefault(); try { - if (!importFile) throw new Error('Please select a file to upload.'); + if (!importFile) { + throw new Error('Please select a file to upload.'); + } setIsSubmitting(true); const form = new FormData(); @@ -115,10 +117,14 @@ export const OrganizationImportDataSyncModal: React.FC< ) => { try { const file = event.target.files?.[0]; - if (!file) return; + if (!file) { + return; + } const validationResult = validateFile({ file, t }); - if (!validationResult.success) throw new Error(validationResult.message); + if (!validationResult.success) { + throw new Error(validationResult.message); + } setImportFile(file); setIsValid(true); } catch (err) { diff --git a/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx b/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx index 3d9d8b3b3..1928e3a1a 100644 --- a/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx +++ b/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx @@ -111,7 +111,9 @@ export const CurrencyAccordion: React.FC = ({ const selectedCurrency = currencies.find( ({ code }) => code === currency, ); - if (!selectedCurrency) return ''; + if (!selectedCurrency) { + return ''; + } return `${selectedCurrency.name} - ${selectedCurrency.codeSymbolString}`; }} fullWidth diff --git a/src/components/Shared/MassActions/TasksMassActionsDropdown.tsx b/src/components/Shared/MassActions/TasksMassActionsDropdown.tsx index b3c2cbf33..a8f8bbbfa 100644 --- a/src/components/Shared/MassActions/TasksMassActionsDropdown.tsx +++ b/src/components/Shared/MassActions/TasksMassActionsDropdown.tsx @@ -84,7 +84,9 @@ export const TasksMassActionsDropdown: React.FC< variant: 'success', }); setCompleteTasksModalOpen(false); - if (massDeselectAll) massDeselectAll(); + if (massDeselectAll) { + massDeselectAll(); + } }; const deleteTasks = async () => { @@ -105,7 +107,9 @@ export const TasksMassActionsDropdown: React.FC< variant: 'success', }); setDeleteTasksModalOpen(false); - if (massDeselectAll) massDeselectAll(); + if (massDeselectAll) { + massDeselectAll(); + } }; return ( diff --git a/src/components/Shared/MultiPageLayout/MultiPageMenu/Item/Item.tsx b/src/components/Shared/MultiPageLayout/MultiPageMenu/Item/Item.tsx index f97e5b001..05a5b4ace 100644 --- a/src/components/Shared/MultiPageLayout/MultiPageMenu/Item/Item.tsx +++ b/src/components/Shared/MultiPageLayout/MultiPageMenu/Item/Item.tsx @@ -26,14 +26,22 @@ export const Item: React.FC = ({ const { t } = useTranslation(); const isSelected = useMemo(() => { - if (item.id === selectedId) return true; - if (!item?.subItems?.length) return false; + if (item.id === selectedId) { + return true; + } + if (!item?.subItems?.length) { + return false; + } return !!item.subItems.find((item) => item.id === selectedId)?.id; }, [item]); const handleClick = () => { - if (isSelected) return; - if (!item?.subItems?.length) return; + if (isSelected) { + return; + } + if (!item?.subItems?.length) { + return; + } setOpenSubMenu(!openSubMenu); }; diff --git a/src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx b/src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx index 496e100f6..ca3ae2f5f 100644 --- a/src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx +++ b/src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx @@ -81,7 +81,9 @@ const showMenuItem = ({ if (item.grantedAccess.indexOf('developer') !== -1 && user.developer) { return true; } - } else return true; + } else { + return true; + } return false; }; diff --git a/src/components/Shared/alertBanner/AlertBanner.tsx b/src/components/Shared/alertBanner/AlertBanner.tsx index dcbf1d5f5..f9c1a54b2 100644 --- a/src/components/Shared/alertBanner/AlertBanner.tsx +++ b/src/components/Shared/alertBanner/AlertBanner.tsx @@ -33,11 +33,15 @@ export const AlertBanner: React.FC = ({ const [showAlert, setShowAlert] = useState(false); useEffect(() => { - if (!window?.localStorage) return; + if (!window?.localStorage) { + return; + } const isClosed = window.localStorage.getItem( `alert-${localStorageName}-closed`, ); - if (!isClosed && isClosed !== 'true') setShowAlert(true); + if (!isClosed && isClosed !== 'true') { + setShowAlert(true); + } }, []); const closeAlert = () => { diff --git a/src/components/common/Links/Facebook.tsx b/src/components/common/Links/Facebook.tsx index cac45188f..ada430584 100644 --- a/src/components/common/Links/Facebook.tsx +++ b/src/components/common/Links/Facebook.tsx @@ -8,7 +8,9 @@ interface Props { } export const Facebook: React.FC = ({ username }) => { - if (!username) return null; + if (!username) { + return null; + } return ( = ({ publicUrl }) => { - if (!publicUrl) return null; + if (!publicUrl) { + return null; + } return ( diff --git a/src/components/common/Links/Twitter.tsx b/src/components/common/Links/Twitter.tsx index 93ca58927..f340532e1 100644 --- a/src/components/common/Links/Twitter.tsx +++ b/src/components/common/Links/Twitter.tsx @@ -8,7 +8,9 @@ interface Props { } export const Twitter: React.FC = ({ screenName }) => { - if (!screenName) return null; + if (!screenName) { + return null; + } return ( = ({ url }) => { - if (!url) return null; + if (!url) { + return null; + } return ( diff --git a/src/hooks/useDataDog.ts b/src/hooks/useDataDog.ts index 47baceac7..ae45f1107 100644 --- a/src/hooks/useDataDog.ts +++ b/src/hooks/useDataDog.ts @@ -5,7 +5,9 @@ declare global { } export const isDataDogConfigured = (): boolean => { - if (typeof window === 'undefined') return false; + if (typeof window === 'undefined') { + return false; + } return !!( process.env.DATADOG_CONFIGURED === 'true' && (window?.DD_RUM ?? {}).hasOwnProperty('getUser') @@ -25,14 +27,18 @@ export const setDataDogUser = ({ email, accountListId, }: SetDataDogUserProps): void => { - if (!isDataDogConfigured()) return; + if (!isDataDogConfigured()) { + return; + } if ( window.DD_RUM.getUser()?.accountListId && window.DD_RUM.getUser()?.accountListId === accountListId - ) + ) { return; - if (window.DD_RUM.getUser()?.accountListId !== accountListId) + } + if (window.DD_RUM.getUser()?.accountListId !== accountListId) { clearDataDogUser(); + } window.DD_RUM.setUser({ id: accountListId, name, @@ -42,6 +48,8 @@ export const setDataDogUser = ({ }; export const clearDataDogUser = (): void => { - if (!isDataDogConfigured()) return; + if (!isDataDogConfigured()) { + return; + } window.DD_RUM.clearUser(); }; diff --git a/src/lib/apollo/relayStylePaginationWithNodes.tsx b/src/lib/apollo/relayStylePaginationWithNodes.tsx index 75f509b75..d757e1d7f 100644 --- a/src/lib/apollo/relayStylePaginationWithNodes.tsx +++ b/src/lib/apollo/relayStylePaginationWithNodes.tsx @@ -34,7 +34,9 @@ export function relayStylePaginationWithNodes( keyArgs, read(existing, { canRead, readField }) { - if (!existing) return; + if (!existing) { + return; + } const edges: TRelayEdge[] = []; let firstEdgeCursor = ''; @@ -192,13 +194,20 @@ export function relayStylePaginationWithNodes( // coincides with the beginning or end of the existing data, as // determined using prefix.length and suffix.length. if (!prefix.length) { - if (void 0 !== hasPreviousPage) + if (void 0 !== hasPreviousPage) { pageInfo.hasPreviousPage = hasPreviousPage; - if (void 0 !== startCursor) pageInfo.startCursor = startCursor; + } + if (void 0 !== startCursor) { + pageInfo.startCursor = startCursor; + } } if (!suffix.length) { - if (void 0 !== hasNextPage) pageInfo.hasNextPage = hasNextPage; - if (void 0 !== endCursor) pageInfo.endCursor = endCursor; + if (void 0 !== hasNextPage) { + pageInfo.hasNextPage = hasNextPage; + } + if (void 0 !== endCursor) { + pageInfo.endCursor = endCursor; + } } } diff --git a/src/lib/extractCookie.ts b/src/lib/extractCookie.ts index 6049ddb06..a7d7263f6 100644 --- a/src/lib/extractCookie.ts +++ b/src/lib/extractCookie.ts @@ -1,4 +1,6 @@ export const extractCookie = (cookies: string | undefined, cookieName) => { - if (!cookies) return undefined; + if (!cookies) { + return undefined; + } return cookies?.split(`${cookieName}=`)[1]?.split(';')[0]; }; diff --git a/src/lib/getErrorFromCatch.ts b/src/lib/getErrorFromCatch.ts index 65972171c..0cf298091 100644 --- a/src/lib/getErrorFromCatch.ts +++ b/src/lib/getErrorFromCatch.ts @@ -1,6 +1,9 @@ export const getErrorMessage = (err: unknown) => { let message; - if (err instanceof Error) message = err.message; - else message = String(err); + if (err instanceof Error) { + message = err.message; + } else { + message = String(err); + } return message; };