Skip to content

Commit 6054354

Browse files
chore: fix incorrect or missing 'await' usages
1 parent 0b33e05 commit 6054354

47 files changed

Lines changed: 99 additions & 51 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugins/course-apps/live/Settings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const LiveSettings = ({
7272
};
7373

7474
const handleSettingsSave = async (values) => {
75-
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
75+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
7676
await dispatch(saveLiveConfiguration(courseId, values, navigate));
7777
};
7878

plugins/course-apps/ora_settings/Settings.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const ORASettings = ({ onClose }) => {
5050
success = success && await handleSettingsSave(formValues);
5151
setSaveError(!success);
5252
if ((initialFormValues.enableFlexiblePeerGrade !== formValues.enableFlexiblePeerGrade) && success) {
53+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
5354
success = await dispatch(updateModel({
5455
modelType: 'courseApps',
5556
model: {

plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ const SettingsModal = ({
239239
const values = { ...rest, enabled: enabled ? checked === 'true' : undefined };
240240

241241
if (enabled) {
242-
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
242+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
243243
success = await dispatch(updateXpertSettings(courseId, values));
244244
} else {
245-
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
245+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
246246
success = await dispatch(removeXpertSettings(courseId));
247247
}
248248

src/certificates/certificates-list/hooks/useCertificatesList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const useCertificatesList = (courseId) => {
2525
}));
2626

2727
const handleSubmit = async (values) => {
28-
// oxlint-disable-next-line @typescript-eslint/await-thenable - this IS a promise; it just has wrong type info.
28+
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.
2929
await dispatch(updateCourseCertificate(courseId, values));
3030
setEditModes({});
3131
dispatch(setMode(MODE_STATES.view));

src/content-tags-drawer/data/apiHooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export const useContentTaxonomyTagsUpdater = (contentId: string) => {
172172
// feature to support the legacy Django template courseware page.
173173

174174
// Sends content tags.
175+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
175176
getContentTaxonomyTagsData(contentId).then((data) => {
176177
const contentData = { contentId, ...data };
177178

@@ -187,6 +188,7 @@ export const useContentTaxonomyTagsUpdater = (contentId: string) => {
187188
});
188189

189190
// Sends tags count.
191+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
190192
getContentTaxonomyTagsCount(contentId).then((count) => {
191193
const contentData = { contentId, count };
192194

src/course-libraries/LegacyLibContentBlockAlert.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ const LegacyLibContentBlockAlert = ({ courseId }: Props) => {
3131
if (taskStatus.data?.state === UserTaskStatus.Succeeded) {
3232
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskCompleted));
3333
setTaskId(undefined);
34+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3435
refetch();
3536
} else if (taskStatus.data?.state === UserTaskStatus.Failed
3637
|| taskStatus.data?.state === UserTaskStatus.Cancelled) {
3738
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskFailed));
3839
setTaskId(undefined);
40+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3941
refetch();
4042
} else if (taskId) {
4143
showToast(intl.formatMessage(messages.legacyLibReadyToMigrateTaskInProgress));

src/course-outline/CourseOutline.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,11 @@ describe('<CourseOutline />', () => {
471471
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
472472
fireEvent.click(dummyBtn);
473473

474-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
474+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
475475

476476
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
477477
const [subsection] = section.childInfo.children;
478-
waitFor(() => {
478+
await waitFor(() => {
479479
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
480480
type: COMPONENT_TYPES.libraryV2,
481481
category: 'vertical',
@@ -509,10 +509,10 @@ describe('<CourseOutline />', () => {
509509
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
510510
fireEvent.click(dummyBtn);
511511

512-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
512+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
513513

514514
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
515-
waitFor(() => {
515+
await waitFor(() => {
516516
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
517517
type: COMPONENT_TYPES.libraryV2,
518518
category: 'sequential',
@@ -545,10 +545,10 @@ describe('<CourseOutline />', () => {
545545
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
546546
fireEvent.click(dummyBtn);
547547

548-
waitFor(() => expect(axiosMock.history.post.length).toBe(3));
548+
await waitFor(() => expect(axiosMock.history.post.length).toBe(3));
549549

550550
const courseUsageKey = courseOutlineIndexMock.courseStructure.id;
551-
waitFor(() => {
551+
await waitFor(() => {
552552
expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
553553
type: COMPONENT_TYPES.libraryV2,
554554
category: 'chapter',

src/course-outline/OutlineAddChildButtons.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const LegacyOutlineAddChildButtons = ({
321321
}
322322

323323
const handleOnComponentSelected = (selected: SelectedComponent) => {
324+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
324325
onUseLibraryContent(selected);
325326
closeAddLibrarySectionModal();
326327
};

src/course-outline/card-header/CardHeader.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('<CardHeader />', () => {
229229
});
230230

231231
expect(await screen.findByTestId('subsection-edit-field')).toBeInTheDocument();
232-
waitFor(() => {
232+
await waitFor(() => {
233233
expect(screen.queryByTestId('subsection-card-header__expanded-btn')).not.toBeInTheDocument();
234234
expect(screen.queryByTestId('edit-button')).not.toBeInTheDocument();
235235
});

src/course-outline/hooks.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const useCourseOutline = ({ courseId }) => {
113113

114114
const headerNavigationsActions = {
115115
handleNewSection: () => {
116+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
116117
handleAddSection.mutateAsync({
117118
type: ContainerType.Chapter,
118119
parentLocator: courseStructure?.id,

0 commit comments

Comments
 (0)