Skip to content

Activate eslint require-await #1372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default [
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/require-await": "off",
},
},
];
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsStatusCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const EventsStatusCell = ({
}

dispatch(fetchWorkflows(row.id)).unwrap()
.then(async workflows => {
.then(workflows => {
// Open workflow overview modal if no workflows available
if (!workflows.entries.length) {
return dispatch(openModal(EventDetailsPage.Workflow, row));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ const EditScheduledEventsEditPage = <T extends RequiredFormProps>({
<WizardNavigationButtons
formik={formik}
nextPage={
async () => {
() => {
dispatch(removeNotificationWizardForm());
if (
await checkSchedulingConflicts(
checkSchedulingConflicts(
formik.values,
setConflicts,
dispatch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const EventDetailsSchedulingTab = ({
};

// submits the formik form
const submitForm = async (values: SchedulingInfo) => {
const submitForm = (values: SchedulingInfo) => {
dispatch(removeNotificationWizardForm());
const startDate = makeDate(
values.scheduleStartDate,
Expand Down Expand Up @@ -250,7 +250,7 @@ const EventDetailsSchedulingTab = ({
<Formik<InitialValues>
enableReinitialize
initialValues={getInitialValues()}
onSubmit={values => submitForm(values).then(() => {})}
onSubmit={values => submitForm(values)}
innerRef={formikRef}
>
{formik => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ const OperationsPreview = ({
workflowDone = !(workflowStatus === "SUCCEEDED" || workflowStatus === "FAILED" || workflowStatus === "STOPPED");
}

const loadWorkflowOperations = async () => {
const loadWorkflowOperations = () => {
// Fetching workflow operations from server
if (workflowId) {
dispatch(fetchWorkflowOperations({ eventId, workflowId }));
Expand All @@ -340,7 +340,7 @@ const OperationsPreview = ({

useEffect(() => {
// Fetch workflow operations initially
loadWorkflowOperations().then();
loadWorkflowOperations();

// Fetch workflow operations every 5 seconds
const fetchWorkflowOperationsInterval = setInterval(loadWorkflowOperations, 5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const EventDetailsWorkflowOperations = ({
const workflowId = useAppSelector(state => getModalWorkflowId(state));
const operations = useAppSelector(state => getWorkflowOperations(state));

const loadWorkflowOperations = async () => {
const loadWorkflowOperations = () => {
// Fetching workflow operations from server
dispatch(fetchWorkflowOperations({ eventId, workflowId }));
};

useEffect(() => {
// Fetch workflow operations initially
loadWorkflowOperations().then();
loadWorkflowOperations();

// Fetch workflow operations every 5 seconds
const fetchWorkflowOperationsInterval = setInterval(loadWorkflowOperations, 5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const NewAccessPage = <T extends RequiredFormProps>({
{/* Button for navigation to next page and previous page */}
<WizardNavigationButtons
formik={formik}
nextPage={async () => {
if (await dispatch(checkAcls(formik.values.policies))) {
nextPage={() => {
if (dispatch(checkAcls(formik.values.policies))) {
nextPage(formik.values);
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,15 @@ const EditScheduledEventsModal = ({
errors.events = "Not all events editable!";
}
if (steps[page].name !== "general") {
return checkSchedulingConflicts(
const isConflict = checkSchedulingConflicts(
values,
setConflicts,
dispatch,
).then(result => {
if (!result) {
errors.editedEvents = "Scheduling conflicts exist!";
}
return errors;
});
);
if (!isConflict) {
errors.editedEvents = "Scheduling conflicts exist!";
}
return errors;
} else {
return errors;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/RegistrationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const RegistrationModalContent = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const onClickContinue = async () => {
const onClickContinue = () => {
// if state is deleteSubmit then delete infos about adaptor else show next state
if (state === "deleteSubmit") {
resetRegistrationData();
Expand Down
1 change: 0 additions & 1 deletion src/components/shared/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { loadEventsIntoTable } from "../../thunks/tableThunks";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchEvents } from "../../slices/eventSlice";
import { ParseKeys } from "i18next";
import { Tooltip } from "./Tooltip";
import BaseButton from "./BaseButton";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const Table = ({
}
};

const showEditTableViewModal = async () => {
const showEditTableViewModal = () => {
editTableViewModalRef.current?.open();
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/TableFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const TableFilters = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [itemValue]);

const handleDatepicker = async (dates?: [Date | undefined | null, Date | undefined | null]) => {
const handleDatepicker = (dates?: [Date | undefined | null, Date | undefined | null]) => {
if (dates != null) {
const [start, end] = dates;

Expand All @@ -185,7 +185,7 @@ const TableFilters = ({

// Workaround for entering a date range by only entering one date
// (e.g. 01/01/2025 results in a range of 01/01/2025 - 01/01/2025)
const handleDatePickerOnKeyDown = async (keyEvent: React.KeyboardEvent<HTMLElement>) => {
const handleDatePickerOnKeyDown = (keyEvent: React.KeyboardEvent<HTMLElement>) => {
if (keyEvent.key === "Enter") {
const end = endDate ?? (startDate ? new Date(startDate) : undefined);
end?.setHours(23);
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/TimeSeriesStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const TimeSeriesStatistics = ({
};

// change time mode in formik and get new values from API
const changeTimeMode = async (
const changeTimeMode = (
newTimeMode: TimeMode,
setFormikValue: (field: string, value: any) => Promise<void | FormikErrors<any>>,
from: string,
Expand All @@ -119,7 +119,7 @@ const TimeSeriesStatistics = ({
};

// change custom time granularity in formik and get new values from API
const changeGranularity = async (
const changeGranularity = (
granularity: DataResolution,
setFormikValue: (field: string, value: any) => Promise<void | FormikErrors<any>>,
timeMode: TimeMode,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/wizard/SelectContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const SelectContainer = ({
setItems(defaultItems);
};

const handleChangeSearch = async (input: string) => {
const handleChangeSearch = (input: string) => {
const filtered = defaultItems.filter(item => {
return item.name.toLowerCase().includes(input.toLowerCase());
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/wizard/WizardStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const WizardStepper = ({
const { t } = useTranslation();
const dispatch = useAppDispatch();

const handleOnClick = async (key: number) => {
const handleOnClick = (key: number) => {
if (isSummaryReachable(key, steps, completed)) {
if (acls) {
const check = await dispatch(checkAcls(acls));
const check = dispatch(checkAcls(acls));
if (!check) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/systems/partials/ServersMaintenanceCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ServersMaintenanceCell = ({
const dispatch = useAppDispatch();

const onClickCheckbox = async (e: React.ChangeEvent<HTMLInputElement>) => {
await dispatch(setServerMaintenance({ host: row.hostname, maintenance: e.target.checked }));
setServerMaintenance({ host: row.hostname, maintenance: e.target.checked });
await dispatch(fetchServers());
dispatch(loadServersIntoTable());
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/systems/partials/ServicesActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ServicesActionCell = ({
const dispatch = useAppDispatch();

const onClickRestart = async () => {
await dispatch(restartService({ host: row.hostname, serviceType: row.name }));
restartService({ host: row.hostname, serviceType: row.name });
await dispatch(fetchServices());
dispatch(loadServicesIntoTable());
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/partials/modal/AclDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const AclDetails = ({
formik={formik}
previousPage={close}
submitPage={
async () => {
if (await dispatch(checkAcls(formik.values.policies))) {
() => {
if (dispatch(checkAcls(formik.values.policies))) {
formik.handleSubmit();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/partials/wizard/AclAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ const AclAccessPage = <T extends RequiredFormProps>({
<WizardNavigationButtons
formik={formik}
nextPage={
async () => {
if (await dispatch(checkAcls(formik.values.policies))) {
() => {
if (dispatch(checkAcls(formik.values.policies))) {
nextPage(formik.values);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const UserEffectiveRolesTab = <T extends RequiredFormProps>({
setItems(defaultItems);
};

const handleChangeSearch = async (input: string) => {
const handleChangeSearch = (input: string) => {
const filtered = defaultItems.filter(item => {
return item.name.toLowerCase().includes(input.toLowerCase());
});
Expand Down
7 changes: 4 additions & 3 deletions src/slices/aclDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { prepareAccessPolicyRulesForPost } from "../utils/resourceUtils";
import { addNotification } from "./notificationSlice";
import { createAppAsyncThunk } from "../createAsyncThunkWithTypes";
import { Acl } from "./aclSlice";
import { AppThunk } from "../store";

/**
* This file contains redux reducer for actions affecting the state of details of an ACL
Expand Down Expand Up @@ -132,13 +133,13 @@ export const fetchAclDetails = createAppAsyncThunk("aclDetails/fetchAclDetails",
});

// update details of a certain acl
export const updateAclDetails = createAppAsyncThunk("aclDetails/updateAclDetails", async (params: {
export const updateAclDetails = (params: {
values: {
name: string,
policies: TransformedAcl[],
},
aclId: number,
}, { dispatch }) => {
}): AppThunk => dispatch => {
const { values, aclId } = params;
// transform ACLs back to structure used by backend
const acls = prepareAccessPolicyRulesForPost(values.policies);
Expand All @@ -159,7 +160,7 @@ export const updateAclDetails = createAppAsyncThunk("aclDetails/updateAclDetails
console.error(response);
dispatch(addNotification({ type: "error", key: "ACL_NOT_SAVED" }));
});
});
};

const aclDetailsSlice = createSlice({
name: "aclDetails",
Expand Down
9 changes: 5 additions & 4 deletions src/slices/aclSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { transformToIdValueArray } from "../utils/utils";
import { NOTIFICATION_CONTEXT_ACCESS } from "../configs/modalConfig";
import { addNotification, removeNotificationWizardAccess } from "./notificationSlice";
import { getUserInformation } from "../selectors/userInfoSelectors";
import { AppDispatch, RootState } from "../store";
import { AppDispatch, AppThunk, RootState } from "../store";
import { createAppAsyncThunk } from "../createAsyncThunkWithTypes";
import { initialFormValuesNewAcl } from "../configs/modalConfig";
import { TransformedAcl } from "./aclDetailsSlice";
Expand Down Expand Up @@ -144,7 +144,7 @@ export const fetchRolesWithTarget = async (target: string) => {
};

// post new acl to backend
export const postNewAcl = (values: typeof initialFormValuesNewAcl) => async (dispatch: AppDispatch) => {
export const postNewAcl = (values: typeof initialFormValuesNewAcl): AppThunk => dispatch => {
const acls = prepareAccessPolicyRulesForPost(values.policies);

const data = new URLSearchParams();
Expand All @@ -166,8 +166,9 @@ export const postNewAcl = (values: typeof initialFormValuesNewAcl) => async (dis
dispatch(addNotification({ type: "error", key: "ACL_NOT_SAVED" }));
});
};

// delete acl with provided id
export const deleteAcl = (id: number) => async (dispatch: AppDispatch) => {
export const deleteAcl = (id: number): AppThunk => dispatch => {
axios
.delete(`/admin-ng/acl/${id}`)
.then(res => {
Expand All @@ -183,7 +184,7 @@ export const deleteAcl = (id: number) => async (dispatch: AppDispatch) => {
};


export const checkAcls = (acls: TransformedAcl[]) => async (dispatch: AppDispatch, getState: () => RootState) => {
export const checkAcls = (acls: TransformedAcl[]) => (dispatch: AppDispatch, getState: () => RootState) => {
// Remove old notifications of context event-access
// Helps to prevent multiple notifications for same problem
dispatch(removeNotificationWizardAccess());
Expand Down
21 changes: 14 additions & 7 deletions src/slices/eventDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
EventDetailsPage,
WorkflowTabHierarchy,
} from "../components/events/partials/modals/EventDetails";
import { AppDispatch } from "../store";
import { AppDispatch, AppThunk } from "../store";
import { Ace } from "./aclSlice";
import { setTobiraTabHierarchy, TobiraData } from "./seriesDetailsSlice";
import { handleTobiraError } from "./shared/tobiraErrors";
Expand Down Expand Up @@ -1642,10 +1642,10 @@ export const fetchHasActiveTransactions = createAppAsyncThunk("eventDetails/fetc
return hasActiveTransactions;
});

export const updateAssets = createAppAsyncThunk("eventDetails/updateAssets", async (params: {
export const updateAssets = (params: {
values: { [key: string]: File },
eventId: Event["id"]
}, { dispatch, getState }) => {
}): AppThunk => (dispatch, getState) => {
const { values, eventId } = params;
// get asset upload options from redux store
const state = getState();
Expand Down Expand Up @@ -1725,7 +1725,7 @@ export const updateAssets = createAppAsyncThunk("eventDetails/updateAssets", asy
}),
);
});
});
};

export const saveAccessPolicies = createAppAsyncThunk("eventDetails/saveAccessPolicies", async (
params: {
Expand Down Expand Up @@ -1815,13 +1815,20 @@ export const deleteCommentReply = createAppAsyncThunk("eventDetails/deleteCommen
return true;
});

export const saveWorkflowConfig = createAppAsyncThunk("eventDetails/saveWorkflowConfig", async (params: {
export const saveWorkflowConfig = (params: {
values: {
workflowDefinition: string,
configuration: { [key: string]: unknown } | undefined
},
eventId: Event["id"]
}, { dispatch }) => {
}): AppThunk => dispatch => {
// export const saveWorkflowConfig = createAppAsyncThunk("eventDetails/saveWorkflowConfig", async (params: {
// values: {
// workflowDefinition: string,
// configuration: { [key: string]: unknown } | undefined
// },
// eventId: Event["id"]
// }, { dispatch }) => {
const { values, eventId } = params;
const jsonData = {
id: values.workflowDefinition,
Expand Down Expand Up @@ -1852,7 +1859,7 @@ export const saveWorkflowConfig = createAppAsyncThunk("eventDetails/saveWorkflow
}),
);
});
});
};

const eventDetailsSlice = createSlice({
name: "eventDetails",
Expand Down
Loading
Loading