Skip to content

Commit 635ba46

Browse files
committed
Activate eslint no-unsafe-call
Enables the eslint rule no-unsafe-call.
1 parent d4e68e5 commit 635ba46

11 files changed

Lines changed: 36 additions & 29 deletions

File tree

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default [
2020
"@typescript-eslint/no-floating-promises": "off",
2121
"@typescript-eslint/no-misused-promises": "off",
2222
"@typescript-eslint/no-unsafe-argument": "off",
23-
"@typescript-eslint/no-unsafe-call": "off",
2423
"@typescript-eslint/no-unsafe-member-access": "off",
2524
"@typescript-eslint/no-unused-vars": "off",
2625
"@typescript-eslint/no-unsafe-return": "off",

src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const EventDetailsSchedulingTab = ({
152152
};
153153

154154
// checks validity of the formik form
155-
const checkValidity = (formik: FormikProps<any>) => {
155+
const checkValidity = (formik: FormikProps<InitialValues>) => {
156156
if (
157157
formik.dirty &&
158158
formik.isValid &&

src/components/events/partials/ModalTabsAndPages/NewAssetUploadPage.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ModalContentTable from "../../../shared/modals/ModalContentTable";
1414
*/
1515
interface RequiredFormProps {
1616
sourceMode: string,
17-
[key: string]: any,
17+
[key: string]: unknown,
1818
}
1919

2020
const NewAssetUploadPage = <T extends RequiredFormProps>({
@@ -73,11 +73,17 @@ const NewAssetUploadPage = <T extends RequiredFormProps>({
7373
type="file"
7474
tabIndex={0}
7575
/>
76-
{formik.values[asset.id] && (
77-
<span className="ui-helper">
78-
{formik.values[asset.id].name.substr(0, 50)}
79-
</span>
80-
)}
76+
{(() => {
77+
const val = formik.values[asset.id];
78+
if (val instanceof File) {
79+
return (
80+
<span className="ui-helper">
81+
{val.name.substring(0, 50)}
82+
</span>
83+
);
84+
}
85+
return null;
86+
})()}
8187
</div>
8288
</td>
8389
{/*Button to remove asset*/}

src/components/events/partials/modals/DeleteEventsModal.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ const DeleteEventsModal = ({
114114
<td>{isEvent(event) && event.title}</td>
115115
<td>
116116
{/* Repeat for each presenter*/}
117-
{/* @ts-expect-error TS(7006): Parameter 'presenter' implicitly has an 'any' type... Remove this comment to see the full error message */}
118-
{event.presenters.map((presenter, key) => (
119-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
117+
{isEvent(event) && event.presenters.map((presenter, key) => (
120118
<span className="metadata-entry" key={key}>
121119
{presenter}
122120
</span>

src/components/events/partials/modals/DeleteSeriesModal.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ const DeleteSeriesModal = ({
192192
<td>{isSeries(series) && series.title}</td>
193193
<td>
194194
{/*Repeat for each creator*/}
195-
{/* @ts-expect-error TS(7006): Parameter 'organizer' implicitly has an 'any' type */}
196-
{series.organizers.map((organizer, key) => (
197-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
195+
{isSeries(series) && series.organizers.map((organizer, key) => (
198196
<span className="metadata-entry" key={key}>
199197
{organizer}
200198
</span>

src/components/events/partials/wizards/NewEventSummary.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { TransformedAcl } from "../../../../slices/aclDetailsSlice";
1616
import { renderValidDate } from "../../../../utils/dateUtils";
1717
import { ParseKeys } from "i18next";
1818
import ModalContentTable from "../../../shared/modals/ModalContentTable";
19+
import { UploadAssetsTrack } from "../../../../slices/eventSlice";
1920

2021
/**
2122
* This component renders the summary page for new events in the new event wizard.
@@ -37,6 +38,7 @@ interface RequiredFormProps {
3738
deviceInputs?: string[]
3839
configuration: { [key: string]: string }
3940
policies: TransformedAcl[]
41+
uploadAssetsTrack?: UploadAssetsTrack[]
4042
[key: string]: unknown, // Metadata fields
4143
}
4244

@@ -155,10 +157,8 @@ const NewEventSummary = <T extends RequiredFormProps>({
155157
<table className="main-tbl">
156158
<tbody>
157159
{/*Insert row for each upload asset of type track user has provided*/}
158-
{/* @ts-expect-error TS(7006): Parameter 'asset' implicitly has an 'any' type. */}
159-
{formik.values.uploadAssetsTrack.map((asset, key) =>
160+
{formik.values.uploadAssetsTrack && formik.values.uploadAssetsTrack.map((asset, key) =>
160161
asset.file ? (
161-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
162162
<tr key={key}>
163163
<td>
164164
{translateOverrideFallback(asset, t, "SHORT")}

src/components/shared/wizard/RenderField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ const RenderField = ({
4040
onClick={() => {
4141
if (editableRef.current) {
4242
if (editableRef.current.focus) {
43+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
4344
editableRef.current.focus();
4445
}
4546
if (editableRef.current.setFocus) {
47+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
4648
editableRef.current.setFocus(); // For DatePicker
4749
}
4850
}

src/slices/aclSlice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { transformToIdValueArray } from "../utils/utils";
66
import { NOTIFICATION_CONTEXT_ACCESS } from "../configs/modalConfig";
77
import { addNotification, removeNotificationWizardAccess } from "./notificationSlice";
88
import { getUserInformation } from "../selectors/userInfoSelectors";
9-
import { AppDispatch } from "../store";
9+
import { AppDispatch, RootState } from "../store";
1010
import { createAppAsyncThunk } from "../createAsyncThunkWithTypes";
1111
import { initialFormValuesNewAcl } from "../configs/modalConfig";
1212
import { TransformedAcl } from "./aclDetailsSlice";
@@ -174,8 +174,8 @@ export const deleteAcl = (id: number) => async (dispatch: AppDispatch) => {
174174
});
175175
};
176176

177-
// @ts-expect-error TS(7006):
178-
export const checkAcls = (acls: TransformedAcl[]) => async (dispatch: AppDispatch, getState) => {
177+
178+
export const checkAcls = (acls: TransformedAcl[]) => async (dispatch: AppDispatch, getState: () => RootState) => {
179179
// Remove old notifications of context event-access
180180
// Helps to prevent multiple notifications for same problem
181181
dispatch(removeNotificationWizardAccess());

src/slices/eventDetailsSlice.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,11 @@ type EventDetailsState = {
273273
}[],
274274
},
275275
video: {
276-
previews: {
277-
uri: string,
278-
}[]
276+
video: {
277+
previews: {
278+
uri: string,
279+
}[]
280+
},
279281
url: string,
280282
} | undefined,
281283
},
@@ -838,28 +840,29 @@ export const fetchAssetMediaDetails = createAppAsyncThunk("eventDetails/fetchAss
838840
const searchParams = new URLSearchParams();
839841
searchParams.append("id1", "media");
840842

841-
const mediaDetailsRequest = await axios.get<EventDetailsState["assetMediaDetails"]>(
843+
const mediaDetailsRequest = await axios.get<Omit<EventDetailsState["assetMediaDetails"], "video">>(
842844
`/admin-ng/event/${eventId}/asset/media/${mediaId}.json`,
843845
{ params },
844846
);
845847
const mediaDetailsResponse = await mediaDetailsRequest.data;
846848

847-
let mediaDetails;
849+
let mediaDetails: EventDetailsState["assetMediaDetails"];
848850

849851
if (typeof mediaDetailsResponse === "string") {
850852
// TODO: Handle JSON parsing errors
851853
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
852854
mediaDetails = JSON.parse(mediaDetailsResponse);
853855
} else {
854-
mediaDetails = mediaDetailsResponse;
856+
mediaDetails = {
857+
...mediaDetailsResponse,
858+
video: undefined,
859+
};
855860
}
856861

857862
mediaDetails.video = {
858863
video: {
859-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
860864
previews: [{ uri: mediaDetails.url }],
861865
},
862-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
863866
url: mediaDetails.url.split("?")[0],
864867
};
865868

src/utils/statisticsUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function createXAxisTickCallback(
3737

3838
return function (tickValue: number | string) {
3939
// @ts-expect-error: Typescript does not like "this", but the chart.js documentation insists we should do it this way
40+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
4041
return moment(this.getLabelForValue(tickValue)).locale(language).format(formatString);
4142
};
4243
};

0 commit comments

Comments
 (0)