From b930ba69843e8f99948658a01a0650b98a4eee9d Mon Sep 17 00:00:00 2001 From: Arnei Date: Mon, 11 May 2026 17:13:39 +0200 Subject: [PATCH] Enable eslint no-misused-promises Enables the rule no-misused-promises and makes the necessary changes. --- eslint.config.js | 1 - src/components/Header.tsx | 4 ++-- src/components/NavBar.tsx | 4 ++-- .../partials/ThemesActionsCell.tsx | 2 +- .../events/partials/EventActionCell.tsx | 2 +- .../ModalTabsAndPages/DetailsTobiraTab.tsx | 10 ++++---- .../ModalTabsAndPages/NewSourcePage.tsx | 24 ++++++++++--------- .../ModalTabsAndPages/NewTobiraPage.tsx | 2 +- .../events/partials/SeriesActionsCell.tsx | 4 ++-- .../partials/RecordingsActionCell.tsx | 2 +- src/components/shared/DateTimeCell.tsx | 2 +- src/components/shared/DropDown.tsx | 5 ++-- src/components/shared/FilterCell.tsx | 2 +- src/components/shared/MainNav.tsx | 4 ++-- src/components/shared/MultiValueCell.tsx | 2 +- src/components/shared/RedirectCell.tsx | 2 +- src/components/shared/Stats.tsx | 4 ++-- src/components/shared/Table.tsx | 2 +- src/components/shared/TableFilters.tsx | 8 +++---- src/components/shared/wizard/RenderField.tsx | 10 +++++--- .../partials/ServersMaintenanceCell.tsx | 2 +- .../systems/partials/ServicesActionsCell.tsx | 2 +- .../users/partials/AclsActionsCell.tsx | 2 +- .../users/partials/GroupsActionsCell.tsx | 2 +- .../users/partials/UsersActionsCell.tsx | 2 +- 25 files changed, 57 insertions(+), 49 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 3df3c47f4d..a06872f1d0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -16,7 +16,6 @@ export default [ "no-tabs": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-floating-promises": "off", - "@typescript-eslint/no-misused-promises": "off", }, }, ]; diff --git a/src/components/Header.tsx b/src/components/Header.tsx index abc054a621..860684d31c 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -121,7 +121,7 @@ const Header = () => { // Fetching health status information at mount loadHealthStatus().then(r => console.info(r)); // Fetch health status every minute - const interval = setInterval(() => dispatch(fetchHealthStatus()), 5000); + const interval = setInterval(() => { dispatch(fetchHealthStatus()); }, 5000); // Event listener for handle a click outside of dropdown menu window.addEventListener("mousedown", handleClickOutside); @@ -334,7 +334,7 @@ const MenuNotify = ({
  • {!!service.status && ( redirectToServices()} + onClick={() => { redirectToServices(); }} > {service.name} {service.error ? ( diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 49af40b7d2..d1f14580ad 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -75,7 +75,7 @@ const NavBar = ({ useHotkeys( (create && create.hotkeySequence) ?? [], - () => showNewResourceModal(), + () => { showNewResourceModal(); }, { description: create && create.hotkeyDescription ? t(create.hotkeyDescription) : undefined }, [showNewResourceModal], ); @@ -115,7 +115,7 @@ const NavBar = ({ {hasAccess(create.accessRole, user) && ( { showNewResourceModal(); }} style={{ display: "flex", alignItems: "center" }} > diff --git a/src/components/configuration/partials/ThemesActionsCell.tsx b/src/components/configuration/partials/ThemesActionsCell.tsx index d3840210bd..c041b47ece 100644 --- a/src/components/configuration/partials/ThemesActionsCell.tsx +++ b/src/components/configuration/partials/ThemesActionsCell.tsx @@ -46,7 +46,7 @@ const ThemesActionsCell = ({ <> {/* edit themes */} showThemeDetails()} + onClick={() => { showThemeDetails(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_THEMES_EDIT"} // tooltipText={"CONFIGURATION.THEMES.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns diff --git a/src/components/events/partials/EventActionCell.tsx b/src/components/events/partials/EventActionCell.tsx index fa37250d01..1fb5e45ab5 100644 --- a/src/components/events/partials/EventActionCell.tsx +++ b/src/components/events/partials/EventActionCell.tsx @@ -91,7 +91,7 @@ const EventActionCell = ({ {/* If event belongs to a series then the corresponding series details can be opened */} {!!row.series && ( { onClickSeriesDetails(); }} className={"action-cell-button more-series"} editAccessRole={"ROLE_UI_SERIES_DETAILS_VIEW"} // tooltipText={"EVENTS.SERIES.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx index 8060923bae..0beb7fc2bb 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx @@ -136,7 +136,9 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => { return <>
    {tabHierarchy === "edit-path" && { + void openSubTab(tabType); + }} hierarchyDepth={0} translationKey0="EVENTS.SERIES.DETAILS.TOBIRA.DISCARD" subTabArgument0="main" @@ -216,7 +218,7 @@ const TobiraTable = ({ tobiraData, i18nKey, openSubTab, handleDelete }: TobiraTa {i18nKey === "SERIES" && openSubTab("edit-path")} + onClick={() => { openSubTab("edit-path"); }} tooltipText="EVENTS.SERIES.DETAILS.TOBIRA.MOUNT_SERIES" > @@ -257,7 +259,7 @@ const TobiraTable = ({ tobiraData, i18nKey, openSubTab, handleDelete }: TobiraTa openSubTab("edit-path", hostPage)} + onClick={() => { openSubTab("edit-path", hostPage); }} tooltipText="EVENTS.SERIES.DETAILS.TOBIRA.EDIT_PATH" > @@ -266,7 +268,7 @@ const TobiraTable = ({ tobiraData, i18nKey, openSubTab, handleDelete }: TobiraTa close={() => deleteConfirmationModalRef.current?.close?.()} resourceName={hostPage.path} resourceId={null} - deleteMethod={() => handleDelete(hostPage)} + deleteMethod={() => { handleDelete(hostPage); }} resourceType="TOBIRA_PATH" modalRef={deleteConfirmationModalRef} /> diff --git a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx index 3ac1802ce0..51410546c4 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx @@ -107,6 +107,18 @@ const NewSourcePage = ({ return inputDevices.length > 0 && hasAnyDeviceAccess(user, inputDevices); }; + const nextPageWithCheck = async () => { + removeOldNotifications(); + const noConflicts = await dispatch(checkConflicts(formik.values)); + if (Array.isArray(noConflicts)) { + setConflicts(noConflicts); + } + if ((typeof noConflicts == "boolean" && noConflicts) + || (Array.isArray(noConflicts) && noConflicts.length === 0)) { + nextPage(formik.values); + } + }; + return ( <> @@ -210,17 +222,7 @@ const NewSourcePage = ({ {/* Button for navigation to next page and previous page */} { - removeOldNotifications(); - const noConflicts = await dispatch(checkConflicts(formik.values)); - if (Array.isArray(noConflicts)) { - setConflicts(noConflicts); - } - if ((typeof noConflicts == "boolean" && noConflicts) - || (Array.isArray(noConflicts) && noConflicts.length === 0)) { - nextPage(formik.values); - } - }} + nextPage={() => { nextPageWithCheck(); }} previousPage={previousPage} /> diff --git a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx index 8575fa6d1d..f5b95d6170 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx @@ -370,7 +370,7 @@ const NewTobiraPage = ({ {/* Render buttons for saving or resetting updated path */} {mode.edit && formik.setFieldValue("selectedPage", undefined)} + reset={() => { formik.setFieldValue("selectedPage", undefined); }} submit={() => formik.handleSubmit()} {...{ isValid }} />} diff --git a/src/components/events/partials/SeriesActionsCell.tsx b/src/components/events/partials/SeriesActionsCell.tsx index c88720f13a..1b5dac798b 100644 --- a/src/components/events/partials/SeriesActionsCell.tsx +++ b/src/components/events/partials/SeriesActionsCell.tsx @@ -68,7 +68,7 @@ const SeriesActionsCell = ({ <> {/* series details */} showSeriesDetailsModal()} + onClick={() => { showSeriesDetailsModal(); }} className={"action-cell-button more-series"} editAccessRole={"ROLE_UI_SERIES_DETAILS_VIEW"} // tooltipText={"EVENTS.SERIES.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns @@ -78,7 +78,7 @@ const SeriesActionsCell = ({ {/* delete series */} showDeleteConfirmation()} + onClick={() => { showDeleteConfirmation(); }} className={"action-cell-button remove"} editAccessRole={"ROLE_UI_SERIES_DELETE"} // tooltipText={"EVENTS.SERIES.TABLE.TOOLTIP.DELETE"} // Disabled due to performance concerns diff --git a/src/components/recordings/partials/RecordingsActionCell.tsx b/src/components/recordings/partials/RecordingsActionCell.tsx index c021f7b666..bda2afb97a 100644 --- a/src/components/recordings/partials/RecordingsActionCell.tsx +++ b/src/components/recordings/partials/RecordingsActionCell.tsx @@ -34,7 +34,7 @@ const RecordingsActionCell = ({ <> {/* view details location/recording */} showRecordingDetails()} + onClick={() => { showRecordingDetails(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_LOCATIONS_DETAILS_VIEW"} // tooltipText={"RECORDINGS.RECORDINGS.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns diff --git a/src/components/shared/DateTimeCell.tsx b/src/components/shared/DateTimeCell.tsx index 40b4df03d0..3c552423a1 100644 --- a/src/components/shared/DateTimeCell.tsx +++ b/src/components/shared/DateTimeCell.tsx @@ -53,7 +53,7 @@ const DateTimeCell = ({ return ( // Link template for start date of event addFilter(date)} + onClick={() => { addFilter(date); }} className={"crosslink"} tooltipText={tooltipText} > diff --git a/src/components/shared/DropDown.tsx b/src/components/shared/DropDown.tsx index 7e86dae56d..e68ea32f7f 100644 --- a/src/components/shared/DropDown.tsx +++ b/src/components/shared/DropDown.tsx @@ -160,12 +160,13 @@ const DropDown = ({ }; const loadOptionsAsync = (inputValue: string, callback: (options: DropDownOption[]) => void) => { - setTimeout(async () => { + const timeout = async () => { callback(formatOptions( fetchOptions ? await fetchOptions(inputValue) : filterOptions(inputValue), required, )); - }, 1000); + }; + setTimeout(() => { timeout(); }, 1000); }; const loadOptions = ( diff --git a/src/components/shared/FilterCell.tsx b/src/components/shared/FilterCell.tsx index e6f5da7335..820878428a 100644 --- a/src/components/shared/FilterCell.tsx +++ b/src/components/shared/FilterCell.tsx @@ -47,7 +47,7 @@ const FilterCell = ({ filterItems.map((item, key) => ( addFilter(item.filterValue)} + onClick={() => { addFilter(item.filterValue); }} className={"crosslink"} tooltipText={item.cellTooltipText} > diff --git a/src/components/shared/MainNav.tsx b/src/components/shared/MainNav.tsx index 6d126f647d..e8747c9907 100644 --- a/src/components/shared/MainNav.tsx +++ b/src/components/shared/MainNav.tsx @@ -43,14 +43,14 @@ const MainNav = ({ useHotkeys( availableHotkeys.general.EVENT_VIEW.sequence, - () => navigate("/events/events"), + () => { navigate("/events/events"); }, { description: t(availableHotkeys.general.EVENT_VIEW.description) ?? undefined }, [], ); useHotkeys( availableHotkeys.general.SERIES_VIEW.sequence, - () => navigate("/events/series"), + () => { navigate("/events/series"); }, { description: t(availableHotkeys.general.SERIES_VIEW.description) ?? undefined }, [], ); diff --git a/src/components/shared/MultiValueCell.tsx b/src/components/shared/MultiValueCell.tsx index 3783d30ec1..58e5b56d7f 100644 --- a/src/components/shared/MultiValueCell.tsx +++ b/src/components/shared/MultiValueCell.tsx @@ -45,7 +45,7 @@ const MultiValueCell = ({ values.map((value, key) => ( addFilter(value)} + onClick={() => { addFilter(value); }} className={"metadata-entry"} tooltipText={tooltipText} > diff --git a/src/components/shared/RedirectCell.tsx b/src/components/shared/RedirectCell.tsx index a1b124681c..363e06efd1 100644 --- a/src/components/shared/RedirectCell.tsx +++ b/src/components/shared/RedirectCell.tsx @@ -39,7 +39,7 @@ const RedirectCell = ({ redirectToResource(filterValue)} + onClick={() => { redirectToResource(filterValue); }} > {children} diff --git a/src/components/shared/Stats.tsx b/src/components/shared/Stats.tsx index 9451efa861..4a60e796ab 100644 --- a/src/components/shared/Stats.tsx +++ b/src/components/shared/Stats.tsx @@ -59,7 +59,7 @@ const Stats = () => { // Load stats on mount loadStats(); - const fetchEventsInterval = setInterval(() => loadStats(), 5000); + const fetchEventsInterval = setInterval(() => { loadStats(); }, 5000); return () => clearInterval(fetchEventsInterval); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -76,7 +76,7 @@ const Stats = () => { tooltipText={"DASHBOARD.BUTTON_TOOLTIP"} tooltipParams={{ filterName: t(st.description as ParseKeys) }} aria-label={t("DASHBOARD.BUTTON_TOOLTIP", { filterName: t(st.description as ParseKeys) })} - onClick={() => showStatsFilter(st)} + onClick={() => { showStatsFilter(st); }} >
    {st.count}
    {/* Show the description of the status, if defined, diff --git a/src/components/shared/Table.tsx b/src/components/shared/Table.tsx index 8648c643e4..a471f63987 100644 --- a/src/components/shared/Table.tsx +++ b/src/components/shared/Table.tsx @@ -90,7 +90,7 @@ const Table = ({ loadResource(); // Fetch resources every minute - const fetchResourceInterval = setInterval(loadResource, 5000); + const fetchResourceInterval = setInterval(() => { loadResource(); }, 5000); return () => { allowLoadIntoTable = false; diff --git a/src/components/shared/TableFilters.tsx b/src/components/shared/TableFilters.tsx index a9473d1f42..642fc1379f 100644 --- a/src/components/shared/TableFilters.tsx +++ b/src/components/shared/TableFilters.tsx @@ -159,7 +159,7 @@ const TableFilters = ({ useEffect(() => { if (itemValue) { // Call to apply filter changes with 600MS debounce! - const applyFilterChangesDebouncedTimeoutId = setTimeout(applyFilterChangesDebounced, 600); + const applyFilterChangesDebouncedTimeoutId = setTimeout(() => { applyFilterChangesDebounced(); }, 600); return () => clearTimeout(applyFilterChangesDebouncedTimeoutId); } @@ -225,7 +225,7 @@ const TableFilters = ({ useHotkeys( availableHotkeys.general.REMOVE_FILTERS.sequence, - () => removeFilters(), + () => { removeFilters(); }, { description: t(availableHotkeys.general.REMOVE_FILTERS.description) ?? undefined }, [removeFilters], ); @@ -348,7 +348,7 @@ const TableFilters = ({ } {/* Remove icon in blue area around filter */} removeFilter(filter)} + onClick={() => { removeFilter(filter); }} tooltipText="TABLE_FILTERS.REMOVE" > @@ -361,7 +361,7 @@ const TableFilters = ({ {/* Remove icon to clear all filters */} {filterMap.some(e => e.value) && { removeFilters(); }} tooltipText="TABLE_FILTERS.CLEAR" className="table-filter-button" > diff --git a/src/components/shared/wizard/RenderField.tsx b/src/components/shared/wizard/RenderField.tsx index 3e031d86af..dc62489b3d 100644 --- a/src/components/shared/wizard/RenderField.tsx +++ b/src/components/shared/wizard/RenderField.tsx @@ -178,7 +178,7 @@ const EditableDateValue = ({ setFieldValue(field.name, value)} + onChange={value => { setFieldValue(field.name, value); }} showTimeInput showYearDropdown showMonthDropdown @@ -311,7 +311,7 @@ const EditableSingleValueTime = ({ setFieldValue(field.name, value)} + onChange={value => { setFieldValue(field.name, value); }} showTimeSelect showTimeSelectOnly dateFormat="p" @@ -406,7 +406,11 @@ const EditableSingleSelectDropDown = ({ options={options} fetchOptions={fetchOptions} required={metadataField.required} - handleChange={element => element && setFieldValue(field.name, element.value)} + handleChange={element => { + if (element) { + setFieldValue(field.name, element.value); + } + }} placeholder={focused ? `-- ${t("SELECT_NO_OPTION_SELECTED")} --` : `${t("SELECT_NO_OPTION_SELECTED")}` diff --git a/src/components/systems/partials/ServersMaintenanceCell.tsx b/src/components/systems/partials/ServersMaintenanceCell.tsx index b72247266b..f5156de73a 100644 --- a/src/components/systems/partials/ServersMaintenanceCell.tsx +++ b/src/components/systems/partials/ServersMaintenanceCell.tsx @@ -31,7 +31,7 @@ const ServersMaintenanceCell = ({ {hasAccess("ROLE_UI_SERVERS_MAINTENANCE_EDIT", user) && ( onClickCheckbox(e)} + onChange={e => { onClickCheckbox(e); }} name="maintenanceStatus" checked={row.maintenance} /> diff --git a/src/components/systems/partials/ServicesActionsCell.tsx b/src/components/systems/partials/ServicesActionsCell.tsx index ed20e8d871..d9b35e1654 100644 --- a/src/components/systems/partials/ServicesActionsCell.tsx +++ b/src/components/systems/partials/ServicesActionsCell.tsx @@ -23,7 +23,7 @@ const ServicesActionCell = ({ return ( row.status !== "SYSTEMS.SERVICES.STATUS.NORMAL" ? ( onClickRestart()} + onClick={() => { onClickRestart(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_SERVICES_STATUS_EDIT"} // tooltipText={"SYSTEMS.SERVICES.TABLE.SANITIZE"} // Disabled due to performance concerns diff --git a/src/components/users/partials/AclsActionsCell.tsx b/src/components/users/partials/AclsActionsCell.tsx index 0792917dd2..cc2e598916 100644 --- a/src/components/users/partials/AclsActionsCell.tsx +++ b/src/components/users/partials/AclsActionsCell.tsx @@ -40,7 +40,7 @@ const AclsActionsCell = ({ <> {/* edit/show ACL details */} { showAclDetails(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_ACLS_EDIT"} // tooltipText={"USERS.ACLS.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns diff --git a/src/components/users/partials/GroupsActionsCell.tsx b/src/components/users/partials/GroupsActionsCell.tsx index 4400e40217..f7f6ddf278 100644 --- a/src/components/users/partials/GroupsActionsCell.tsx +++ b/src/components/users/partials/GroupsActionsCell.tsx @@ -38,7 +38,7 @@ const GroupsActionsCell = ({ <> {/* edit/show group */} showGroupDetails()} + onClick={() => { showGroupDetails(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_GROUPS_EDIT"} // tooltipText={"USERS.GROUPS.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns diff --git a/src/components/users/partials/UsersActionsCell.tsx b/src/components/users/partials/UsersActionsCell.tsx index c7a35d3394..12035a6778 100644 --- a/src/components/users/partials/UsersActionsCell.tsx +++ b/src/components/users/partials/UsersActionsCell.tsx @@ -40,7 +40,7 @@ const UsersActionCell = ({ <> {/* edit/show user details */} showUserDetails()} + onClick={() => { showUserDetails(); }} className={"action-cell-button"} editAccessRole={"ROLE_UI_USERS_EDIT"} // tooltipText={"USERS.USERS.TABLE.TOOLTIP.DETAILS"} // Disabled due to performance concerns