diff --git a/apps/web/src/components/ApplicationCard/ApplicationActions.tsx b/apps/web/src/components/ApplicationCard/ApplicationActions.tsx index ee79be12d82..80d4cabffe3 100644 --- a/apps/web/src/components/ApplicationCard/ApplicationActions.tsx +++ b/apps/web/src/components/ApplicationCard/ApplicationActions.tsx @@ -192,8 +192,8 @@ const CopyApplicationIdAction = ({ fontSize="caption" data-h2-vertical-align="base(top)" icon={linkCopied ? CheckIcon : undefined} - onClick={() => { - navigator.clipboard.writeText(id); + onClick={async () => { + await navigator.clipboard.writeText(id); setLinkCopied(true); }} aria-label={ diff --git a/apps/web/src/components/ApplicationCard/ApplicationCard.tsx b/apps/web/src/components/ApplicationCard/ApplicationCard.tsx index 377db4d45e3..1b309104a02 100644 --- a/apps/web/src/components/ApplicationCard/ApplicationCard.tsx +++ b/apps/web/src/components/ApplicationCard/ApplicationCard.tsx @@ -126,8 +126,8 @@ const ApplicationCard = ({ classification: application.pool.classification, }); - const deleteApplication = () => { - executeDeleteMutation({ + const deleteApplication = async () => { + await executeDeleteMutation({ id: application.id, }).then((result) => { if (result.data?.deleteApplication) { diff --git a/apps/web/src/components/AssessmentStepTracker/AssessmentStepTracker.test.tsx b/apps/web/src/components/AssessmentStepTracker/AssessmentStepTracker.test.tsx index b1c3fc51127..f579e26eb23 100644 --- a/apps/web/src/components/AssessmentStepTracker/AssessmentStepTracker.test.tsx +++ b/apps/web/src/components/AssessmentStepTracker/AssessmentStepTracker.test.tsx @@ -99,8 +99,8 @@ describe("AssessmentStepTracker", () => { it("should have no accessibility errors", async () => { const { container } = renderAssessmentStepTracker(); - await waitFor(() => { - axeTest(container); + await waitFor(async () => { + await axeTest(container); }); }); diff --git a/apps/web/src/components/EmailVerification/EmailVerification.test.tsx b/apps/web/src/components/EmailVerification/EmailVerification.test.tsx index 064ce3b06ed..1710033095d 100644 --- a/apps/web/src/components/EmailVerification/EmailVerification.test.tsx +++ b/apps/web/src/components/EmailVerification/EmailVerification.test.tsx @@ -47,8 +47,8 @@ const renderComponent = ( describe("EmailVerification", () => { it("should have no accessibility errors", async () => { const { container } = renderComponent(getDefaultProps(), getMockClient()); - await waitFor(() => { - axeTest(container); + await waitFor(async () => { + await axeTest(container); }); }); diff --git a/apps/web/src/components/EmploymentEquity/EquityOptions.tsx b/apps/web/src/components/EmploymentEquity/EquityOptions.tsx index c63ab6c8fb9..8bef4d1c9aa 100644 --- a/apps/web/src/components/EmploymentEquity/EquityOptions.tsx +++ b/apps/web/src/components/EmploymentEquity/EquityOptions.tsx @@ -103,13 +103,19 @@ const EquityOptions = ({ }); }; + const handleError = () => { + toast.error(intl.formatMessage(profileMessages.updatingFailed)); + }; + const handleMultipleFieldSave = (data: UpdateUserAsUserInput) => { - onUpdate(data).then((res) => { - if (res) toast.success(intl.formatMessage(profileMessages.userUpdated)); - else { - toast.error(intl.formatMessage(profileMessages.updatingFailed)); - } - }); + onUpdate(data) + .then((res) => { + if (res) toast.success(intl.formatMessage(profileMessages.userUpdated)); + else { + handleError(); + } + }) + .catch(handleError); }; return ( diff --git a/apps/web/src/components/NotificationList/NotificationItem.tsx b/apps/web/src/components/NotificationList/NotificationItem.tsx index af4878e37b2..848f382e700 100644 --- a/apps/web/src/components/NotificationList/NotificationItem.tsx +++ b/apps/web/src/components/NotificationList/NotificationItem.tsx @@ -136,11 +136,11 @@ const NotificationItem = ({ const isTogglingReadStatus = markingAsRead || markingAsUnread; - const toggleReadStatus = () => { + const toggleReadStatus = async () => { const mutation = isUnread ? executeMarkAsReadMutation : executeMarkAsUnreadMutation; - mutation({ id: notification.id }); + await mutation({ id: notification.id }); }; const createdAt = notification.createdAt diff --git a/apps/web/src/components/NotificationList/RemoveDialog.tsx b/apps/web/src/components/NotificationList/RemoveDialog.tsx index 29458913a59..058c81966ff 100644 --- a/apps/web/src/components/NotificationList/RemoveDialog.tsx +++ b/apps/web/src/components/NotificationList/RemoveDialog.tsx @@ -31,8 +31,8 @@ const RemoveDialog = forwardRef< DeleteNotification_Mutation, ); - const handleDelete = () => { - executeDeleteMutation({ id }).then((res) => { + const handleDelete = async () => { + await executeDeleteMutation({ id }).then((res) => { if (res.data?.deleteNotification) { setIsOpen(false); } diff --git a/apps/web/src/components/PoolCandidatesTable/PoolCandidatesTable.tsx b/apps/web/src/components/PoolCandidatesTable/PoolCandidatesTable.tsx index 84a376d4db0..927b1411300 100644 --- a/apps/web/src/components/PoolCandidatesTable/PoolCandidatesTable.tsx +++ b/apps/web/src/components/PoolCandidatesTable/PoolCandidatesTable.tsx @@ -634,9 +634,9 @@ const PoolCandidatesTable = ({ const handleDocDownload = (anonymous: boolean) => { if (selectedRows.length === 1) { downloadDoc({ id: selectedRows[0], anonymous }) - .then((res) => { + .then(async (res) => { if (res?.data?.downloadPoolCandidateDoc) { - executeAsyncDownload({ + await executeAsyncDownload({ url: apiRoutes.userGeneratedFile( res.data.downloadPoolCandidateDoc, ), diff --git a/apps/web/src/components/QualifiedRecruitmentCard/QualifiedRecruitmentCard.tsx b/apps/web/src/components/QualifiedRecruitmentCard/QualifiedRecruitmentCard.tsx index d2d2461d9be..cb6a69478a1 100644 --- a/apps/web/src/components/QualifiedRecruitmentCard/QualifiedRecruitmentCard.tsx +++ b/apps/web/src/components/QualifiedRecruitmentCard/QualifiedRecruitmentCard.tsx @@ -367,8 +367,8 @@ const QualifiedRecruitmentCard = ({ color="black" fontSize="caption" icon={linkCopied ? CheckIcon : undefined} - onClick={() => { - navigator.clipboard.writeText(candidate.id); + onClick={async () => { + await navigator.clipboard.writeText(candidate.id); setLinkCopied(true); }} aria-label={intl.formatMessage( diff --git a/apps/web/src/components/SkillBrowser/SkillBrowserDialog.tsx b/apps/web/src/components/SkillBrowser/SkillBrowserDialog.tsx index 658042cd880..b955fd6ea0b 100644 --- a/apps/web/src/components/SkillBrowser/SkillBrowserDialog.tsx +++ b/apps/web/src/components/SkillBrowser/SkillBrowserDialog.tsx @@ -133,7 +133,7 @@ const SkillBrowserDialog = ({ useEffect(() => { if (watchSkill) { - formTrigger("skill"); + void formTrigger("skill"); } }, [watchSkill, formTrigger]); diff --git a/apps/web/src/hooks/useApplicationDownloads.ts b/apps/web/src/hooks/useApplicationDownloads.ts index b8a5957d216..99a5258bcdf 100644 --- a/apps/web/src/hooks/useApplicationDownloads.ts +++ b/apps/web/src/hooks/useApplicationDownloads.ts @@ -52,9 +52,9 @@ const useApplicationDownloads = () => { const downloadDoc = ({ id }: { id: Scalars["UUID"]["input"] }) => { executeDocMutation({ id }) - .then((res) => { + .then(async (res) => { if (res?.data?.downloadApplicationDoc) { - executeAsyncDownload({ + await executeAsyncDownload({ url: paths.userGeneratedFile(res.data.downloadApplicationDoc), fileName: res.data.downloadApplicationDoc, }); diff --git a/apps/web/src/hooks/usePoolMutations.ts b/apps/web/src/hooks/usePoolMutations.ts index 7b99844acc4..859dbf070a6 100644 --- a/apps/web/src/hooks/usePoolMutations.ts +++ b/apps/web/src/hooks/usePoolMutations.ts @@ -205,7 +205,7 @@ const usePoolMutations = (returnPath?: string) => { }), ); } else { - handleUpdateError(); + void handleUpdateError(); } }) .catch(handleUpdateError); diff --git a/apps/web/src/hooks/useUserDownloads.ts b/apps/web/src/hooks/useUserDownloads.ts index ca1366d8ab9..45228971cf7 100644 --- a/apps/web/src/hooks/useUserDownloads.ts +++ b/apps/web/src/hooks/useUserDownloads.ts @@ -91,7 +91,7 @@ const useUserDownloads = () => { executeAsyncDownload({ url: paths.userGeneratedFile(res.data.downloadUserDoc), fileName: res.data.downloadUserDoc, - }); + }).catch(handleDownloadError); } else { handleDownloadError(); } diff --git a/apps/web/src/pages/Auth/RegistrationPages/GettingStartedPage/GettingStartedPage.tsx b/apps/web/src/pages/Auth/RegistrationPages/GettingStartedPage/GettingStartedPage.tsx index 7885d502904..7c45e3beed4 100644 --- a/apps/web/src/pages/Auth/RegistrationPages/GettingStartedPage/GettingStartedPage.tsx +++ b/apps/web/src/pages/Auth/RegistrationPages/GettingStartedPage/GettingStartedPage.tsx @@ -271,8 +271,8 @@ export const GettingStartedForm = ({ ], }); - const onSubmit = (values: FormValues) => { - handleSubmit( + const onSubmit = async (values: FormValues) => { + await handleSubmit( { firstName: values.firstName, lastName: values.lastName, @@ -402,9 +402,9 @@ const GettingStarted = () => { id, email: emptyToNull(generalInput.email), }, - }).then((generalResult) => { + }).then(async (generalResult) => { if (generalResult.data?.updateUserAsUser) { - executeNotificationMutation({ + await executeNotificationMutation({ enabledEmailNotifications: notificationInput, }).then((notificationResult) => { if (notificationResult.data?.updateEnabledNotifications) { diff --git a/apps/web/src/pages/Pools/EditPoolPage/components/AssetSkillsSection.tsx b/apps/web/src/pages/Pools/EditPoolPage/components/AssetSkillsSection.tsx index cf31b8ae1aa..20996979008 100644 --- a/apps/web/src/pages/Pools/EditPoolPage/components/AssetSkillsSection.tsx +++ b/apps/web/src/pages/Pools/EditPoolPage/components/AssetSkillsSection.tsx @@ -75,7 +75,7 @@ const AssetSkillsSection = ({ skillSelected: string, skillLevel: SkillLevel, ) => { - poolSkillMutations.create(pool.id, skillSelected, { + await poolSkillMutations.create(pool.id, skillSelected, { type: PoolSkillType.Nonessential, requiredLevel: skillLevel, }); @@ -85,13 +85,13 @@ const AssetSkillsSection = ({ poolSkillSelected: string, skillLevel: SkillLevel, ) => { - poolSkillMutations.update(poolSkillSelected, { + await poolSkillMutations.update(poolSkillSelected, { requiredLevel: skillLevel, }); }; const handleRemove = async (poolSkillSelected: string) => { - poolSkillMutations.delete(poolSkillSelected); + await poolSkillMutations.delete(poolSkillSelected); }; // disabled unless status is draft diff --git a/apps/web/src/pages/Pools/EditPoolPage/components/EssentialSkillsSection.tsx b/apps/web/src/pages/Pools/EditPoolPage/components/EssentialSkillsSection.tsx index 1de746fdc4e..df0cfe21859 100644 --- a/apps/web/src/pages/Pools/EditPoolPage/components/EssentialSkillsSection.tsx +++ b/apps/web/src/pages/Pools/EditPoolPage/components/EssentialSkillsSection.tsx @@ -75,7 +75,7 @@ const EssentialSkillsSection = ({ skillSelected: string, skillLevel: SkillLevel, ) => { - poolSkillMutations.create(pool.id, skillSelected, { + await poolSkillMutations.create(pool.id, skillSelected, { type: PoolSkillType.Essential, requiredLevel: skillLevel, }); @@ -85,13 +85,13 @@ const EssentialSkillsSection = ({ poolSkillSelected: string, skillLevel: SkillLevel, ) => { - poolSkillMutations.update(poolSkillSelected, { + await poolSkillMutations.update(poolSkillSelected, { requiredLevel: skillLevel, }); }; const handleRemove = async (poolSkillSelected: string) => { - poolSkillMutations.delete(poolSkillSelected); + await poolSkillMutations.delete(poolSkillSelected); }; // disabled unless status is draft diff --git a/apps/web/src/pages/Pools/EditPoolPage/components/GeneralQuestionsSection/GeneralQuestionsSection.tsx b/apps/web/src/pages/Pools/EditPoolPage/components/GeneralQuestionsSection/GeneralQuestionsSection.tsx index 92bfb9ab5e3..9beb09bdd22 100644 --- a/apps/web/src/pages/Pools/EditPoolPage/components/GeneralQuestionsSection/GeneralQuestionsSection.tsx +++ b/apps/web/src/pages/Pools/EditPoolPage/components/GeneralQuestionsSection/GeneralQuestionsSection.tsx @@ -66,13 +66,13 @@ const GeneralQuestionsSection = ({ ); const { isSubmitting } = useEditPoolContext(); - const handleUpdate = (newQuestions: GeneralQuestion[]) => { + const handleUpdate = async (newQuestions: GeneralQuestion[]) => { setIsUpdating(true); const generalQuestions = repeaterQuestionsToSubmitData( newQuestions, questions, ); - onSave({ generalQuestions }).then(() => { + await onSave({ generalQuestions }).then(() => { setIsUpdating(false); }); }; diff --git a/apps/web/src/pages/Pools/EditPoolPage/components/SkillTable.tsx b/apps/web/src/pages/Pools/EditPoolPage/components/SkillTable.tsx index f79027dff50..647395d6933 100644 --- a/apps/web/src/pages/Pools/EditPoolPage/components/SkillTable.tsx +++ b/apps/web/src/pages/Pools/EditPoolPage/components/SkillTable.tsx @@ -72,7 +72,7 @@ const ActionCell = ( }} onSave={async (value) => { if (value.skill && value.skillLevel) { - onUpdate(poolSkillId, value.skillLevel); + await onUpdate(poolSkillId, value.skillLevel); } }} /> @@ -204,7 +204,7 @@ const SkillTable = ({ skills={availableSkills} onSave={async (value) => { if (value.skill && value.skillLevel) { - onCreate(value.skill, value.skillLevel); + await onCreate(value.skill, value.skillLevel); } }} /> diff --git a/apps/web/src/pages/Pools/EditPoolPage/components/UpdatePublishedProcessDialog/UpdatePublishedProcessDialog.tsx b/apps/web/src/pages/Pools/EditPoolPage/components/UpdatePublishedProcessDialog/UpdatePublishedProcessDialog.tsx index eb05ce9114b..c0b3b0199cf 100644 --- a/apps/web/src/pages/Pools/EditPoolPage/components/UpdatePublishedProcessDialog/UpdatePublishedProcessDialog.tsx +++ b/apps/web/src/pages/Pools/EditPoolPage/components/UpdatePublishedProcessDialog/UpdatePublishedProcessDialog.tsx @@ -82,8 +82,8 @@ const UpdatePublishedProcessDialog = ({ }); }; - const handleSave = () => { - methods.handleSubmit(handleUpdate)(); + const handleSave = async () => { + await methods.handleSubmit(handleUpdate)(); }; const label = intl.formatMessage({ diff --git a/apps/web/src/pages/Pools/PoolAdvertisementPage/PoolAdvertisementPage.tsx b/apps/web/src/pages/Pools/PoolAdvertisementPage/PoolAdvertisementPage.tsx index 9441bc2313f..efcb4838a46 100644 --- a/apps/web/src/pages/Pools/PoolAdvertisementPage/PoolAdvertisementPage.tsx +++ b/apps/web/src/pages/Pools/PoolAdvertisementPage/PoolAdvertisementPage.tsx @@ -549,8 +549,8 @@ export const PoolPoster = ({ mode="inline" color="secondary" icon={linkCopied ? CheckIcon : undefined} - onClick={() => { - navigator.clipboard.writeText(window.location.href); + onClick={async () => { + await navigator.clipboard.writeText(window.location.href); setLinkCopied(true); setTimeout(() => { setLinkCopied(false); diff --git a/apps/web/src/pages/Pools/ScreeningAndEvaluationPage/ScreeningAndEvaluationPage.tsx b/apps/web/src/pages/Pools/ScreeningAndEvaluationPage/ScreeningAndEvaluationPage.tsx index 6b20bd630e0..31289014b3a 100644 --- a/apps/web/src/pages/Pools/ScreeningAndEvaluationPage/ScreeningAndEvaluationPage.tsx +++ b/apps/web/src/pages/Pools/ScreeningAndEvaluationPage/ScreeningAndEvaluationPage.tsx @@ -14,6 +14,7 @@ import { import { Pending, ThrowNotFound } from "@gc-digital-talent/ui"; import { toast } from "@gc-digital-talent/toast"; import { ROLE_NAME } from "@gc-digital-talent/auth"; +import { useLogger } from "@gc-digital-talent/logger"; import useRequiredParams from "~/hooks/useRequiredParams"; import AssessmentStepTracker, { @@ -77,6 +78,7 @@ const ScreeningAndEvaluationPage = () => { const { poolId } = useRequiredParams("poolId"); const client = useClient(); const intl = useIntl(); + const logger = useLogger(); const [fetchingCandidates, setFetchingCandidates] = useState(true); const [candidates, setCandidates] = useState< FragmentType[] @@ -132,11 +134,11 @@ const ScreeningAndEvaluationPage = () => { [client, intl, lastPage], ); - const handleFilterSubmit: SubmitHandler = (formData) => { + const handleFilterSubmit: SubmitHandler = async (formData) => { const transformedData: PoolCandidateSearchInput = transformFormValuesToFilterState(formData, poolId); - batchLoader(transformedData).then((res) => { + await batchLoader(transformedData).then((res) => { setCandidates(res); }); }; @@ -147,9 +149,13 @@ const ScreeningAndEvaluationPage = () => { applicantFilter: { pools: [{ id: poolId }] }, suspendedStatus: CandidateSuspendedFilter.Active, expiryStatus: CandidateExpiryFilter.Active, - }).then((res) => { - setCandidates(res); - }); + }) + .then((res) => { + setCandidates(res); + }) + .catch((err) => { + logger.error(err); + }); } // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/apps/web/src/pages/Skills/components/SkillPortfolioTable.tsx b/apps/web/src/pages/Skills/components/SkillPortfolioTable.tsx index 93726e70ab6..429b42ebd83 100644 --- a/apps/web/src/pages/Skills/components/SkillPortfolioTable.tsx +++ b/apps/web/src/pages/Skills/components/SkillPortfolioTable.tsx @@ -243,7 +243,7 @@ const SkillPortfolioTable = ({ context="library" skills={unclaimedSkills} onSave={async (value) => { - executeCreateMutation({ + await executeCreateMutation({ userId: userAuthInfo?.id ?? "", skillId: value?.skill ?? "", userSkill: { diff --git a/packages/eslint-config-custom/index.js b/packages/eslint-config-custom/index.js index 7d8d0a1800a..f16d0844856 100644 --- a/packages/eslint-config-custom/index.js +++ b/packages/eslint-config-custom/index.js @@ -102,7 +102,6 @@ module.exports = { "@typescript-eslint/only-throw-error": "off", // Remove in #11378 "@typescript-eslint/no-misused-promises": "off", // Remove in #11379 "@typescript-eslint/no-base-to-string": "off", // Remove in #11380 - "@typescript-eslint/no-floating-promises": "off", // Remove in #11381 "@typescript-eslint/prefer-promise-reject-errors": "off", // Remove in #11382 // Remove in #11384 diff --git a/packages/forms/src/components/Combobox/Combobox.stories.tsx b/packages/forms/src/components/Combobox/Combobox.stories.tsx index 06fb47b5f38..3e1022080fa 100644 --- a/packages/forms/src/components/Combobox/Combobox.stories.tsx +++ b/packages/forms/src/components/Combobox/Combobox.stories.tsx @@ -53,6 +53,7 @@ const Template: StoryFn = (args) => { .then((newOptions) => { setFilteredOptions(newOptions); }) + .catch((err) => action("error")(err)) .finally(() => { setIsSearching(false); }); diff --git a/packages/forms/src/components/DateInput/DateInput.stories.tsx b/packages/forms/src/components/DateInput/DateInput.stories.tsx index 82235be2e25..693483f684a 100644 --- a/packages/forms/src/components/DateInput/DateInput.stories.tsx +++ b/packages/forms/src/components/DateInput/DateInput.stories.tsx @@ -204,6 +204,7 @@ const AsyncTemplate: StoryFn = (args) => { .then((res: Pool) => { setPool(res); }) + .catch((err) => action("error")(err)) .finally(() => { setFetching(false); }); diff --git a/packages/forms/src/components/RichTextInput/LinkDialog.tsx b/packages/forms/src/components/RichTextInput/LinkDialog.tsx index 4b704a33703..f1b74cce224 100644 --- a/packages/forms/src/components/RichTextInput/LinkDialog.tsx +++ b/packages/forms/src/components/RichTextInput/LinkDialog.tsx @@ -75,9 +75,9 @@ const LinkDialog = ({ editor }: LinkDialogProps) => { const methods = useForm(); const actionProps = methods.register("action"); - const handleSave = (action: FormValues["action"]) => { + const handleSave = async (action: FormValues["action"]) => { methods.setValue("action", action); - methods.handleSubmit(handleSubmit)(); + await methods.handleSubmit(handleSubmit)(); }; const handleOpenChange = (newOpen: boolean) => { @@ -102,7 +102,7 @@ const LinkDialog = ({ editor }: LinkDialogProps) => { const handleKeyDown: KeyboardEventHandler = (e) => { if (e.key === "Enter") { e.preventDefault(); - handleSave("add"); + void handleSave("add"); } };