Skip to content

Commit a4150a6

Browse files
committed
Activate eslint no-unsafe-return
Enable the eslint rule no-unsafe-return
1 parent 4da7bf0 commit a4150a6

19 files changed

Lines changed: 126 additions & 102 deletions

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-unused-vars": "off",
23-
"@typescript-eslint/no-unsafe-return": "off",
2423
"@typescript-eslint/require-await": "off",
2524
},
2625
},

src/components/shared/MainNav.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ const MainNav = ({
166166
if (firstPathFragment.length > 0) {
167167
const arrToSort = linkMap[firstPathFragment as keyof typeof linkMap].links;
168168
if (arrToSort != undefined && arrToSort.length > 1) {
169-
arrToSort.forEach((item : any) => {
169+
arrToSort.forEach(item => {
170+
// @ts-expect-error: TODO: Someone else can fix this
170171
if (item.path === pathname) { item.tmpIndex = 0; } else { item.tmpIndex = 1; }
171172
});
172-
arrToSort.sort((a: any, b: any) => a.tmpIndex - b.tmpIndex);
173+
// @ts-expect-error: TODO: Someone else can fix this
174+
arrToSort.sort((a, b) => a.tmpIndex - b.tmpIndex);
173175
}
174176
}
175177

src/i18n/i18n.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ i18n
6363
return moment(value).format(format);
6464
}
6565

66+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
6667
return value;
6768
},
6869
},

src/slices/aclSlice.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ import { TransformedAcl } from "./aclDetailsSlice";
1414
/**
1515
* This file contains redux reducer for actions affecting the state of acls
1616
*/
17+
type FetchAcls = {
18+
total: AclsState["total"],
19+
count: AclsState["count"],
20+
limit: AclsState["limit"],
21+
offset: AclsState["offset"],
22+
results: AclsState["results"],
23+
};
24+
1725
export type Ace = {
1826
action: string,
1927
allow: boolean,
@@ -79,7 +87,7 @@ export const fetchAcls = createAppAsyncThunk("acls/fetchAcls", async (_, { getSt
7987
// Just make the async request here, and return the response.
8088
// This will automatically dispatch a `pending` action first,
8189
// and then `fulfilled` or `rejected` actions based on the promise.
82-
const res = await axios.get("/admin-ng/acl/acls.json", { params: params });
90+
const res = await axios.get<FetchAcls>("/admin-ng/acl/acls.json", { params: params });
8391
return res.data;
8492
});
8593

@@ -245,13 +253,7 @@ const aclsSlice = createSlice({
245253
state.status = "loading";
246254
})
247255
// Pass the generated action creators to `.addCase()`
248-
.addCase(fetchAcls.fulfilled, (state, action: PayloadAction<{
249-
total: AclsState["total"],
250-
count: AclsState["count"],
251-
limit: AclsState["limit"],
252-
offset: AclsState["offset"],
253-
results: AclsState["results"],
254-
}>) => {
256+
.addCase(fetchAcls.fulfilled, (state, action: PayloadAction<FetchAcls>) => {
255257
// Same "mutating" update syntax thanks to Immer
256258
state.status = "succeeded";
257259
const acls = action.payload;

src/slices/eventDetailsSlice.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ export const fetchAssetAttachments = createAppAsyncThunk("eventDetails/fetchAsse
750750
const params = new URLSearchParams();
751751
params.append("id1", "attachment");
752752

753-
const attachmentsRequest = await axios.get(
753+
const attachmentsRequest = await axios.get<EventDetailsState["assetAttachments"]>(
754754
`/admin-ng/event/${eventId}/asset/attachment/attachments.json`,
755755
{ params },
756756
);
@@ -765,7 +765,7 @@ export const fetchAssetAttachmentDetails = createAppAsyncThunk("eventDetails/fet
765765
const searchParams = new URLSearchParams();
766766
searchParams.append("id1", "attachment");
767767

768-
const attachmentDetailsRequest = await axios.get(
768+
const attachmentDetailsRequest = await axios.get<EventDetailsState["assetAttachmentDetails"]>(
769769
`/admin-ng/event/${eventId}/asset/attachment/${attachmentId}.json`,
770770
{ params },
771771
);
@@ -776,7 +776,7 @@ export const fetchAssetCatalogs = createAppAsyncThunk("eventDetails/fetchAssetCa
776776
const params = new URLSearchParams();
777777
params.append("id1", "catalog");
778778

779-
const catalogsRequest = await axios.get(
779+
const catalogsRequest = await axios.get<EventDetailsState["assetCatalogs"]>(
780780
`/admin-ng/event/${eventId}/asset/catalog/catalogs.json`,
781781
{ params },
782782
);
@@ -791,7 +791,7 @@ export const fetchAssetCatalogDetails = createAppAsyncThunk("eventDetails/fetchA
791791
const searchParams = new URLSearchParams();
792792
searchParams.append("id1", "catalog");
793793

794-
const catalogDetailsRequest = await axios.get(
794+
const catalogDetailsRequest = await axios.get<EventDetailsState["assetCatalogDetails"]>(
795795
`/admin-ng/event/${eventId}/asset/catalog/${catalogId}.json`,
796796
{ params },
797797
);
@@ -873,7 +873,7 @@ export const fetchAssetPublications = createAppAsyncThunk("eventDetails/fetchAss
873873
const params = new URLSearchParams();
874874
params.append("id1", "publication");
875875

876-
const publicationsRequest = await axios.get(
876+
const publicationsRequest = await axios.get<EventDetailsState["assetPublications"]>(
877877
`/admin-ng/event/${eventId}/asset/publication/publications.json`,
878878
{ params },
879879
);
@@ -888,7 +888,7 @@ export const fetchAssetPublicationDetails = createAppAsyncThunk("eventDetails/fe
888888
const searchParams = new URLSearchParams();
889889
searchParams.append("id1", "publication");
890890

891-
const publicationDetailsRequest = await axios.get(
891+
const publicationDetailsRequest = await axios.get<EventDetailsState["assetPublicationDetails"]>(
892892
`/admin-ng/event/${eventId}/asset/publication/${publicationId}.json`,
893893
{ params },
894894
);
@@ -1351,7 +1351,7 @@ export const fetchWorkflowDetails = createAppAsyncThunk("eventDetails/fetchWorkf
13511351
workflowId: string
13521352
}) => {
13531353
const { eventId, workflowId } = params;
1354-
const data = await axios.get(
1354+
const data = await axios.get<EventDetailsState["workflows"]["workflow"]>(
13551355
`/admin-ng/event/${eventId}/workflows/${workflowId}.json`,
13561356
);
13571357
return await data.data;
@@ -1501,7 +1501,7 @@ export const fetchWorkflowOperationDetails = createAppAsyncThunk("eventDetails/f
15011501
operationId?: number
15021502
}) => {
15031503
const { eventId, workflowId, operationId } = params;
1504-
const data = await axios.get(
1504+
const data = await axios.get<EventDetailsState["workflowOperationDetails"]>(
15051505
`/admin-ng/event/${eventId}/workflows/${workflowId}/operations/${operationId}`,
15061506
);
15071507
return await data.data;
@@ -1525,7 +1525,7 @@ export const fetchWorkflowErrorDetails = createAppAsyncThunk("eventDetails/fetch
15251525
errorId?: number
15261526
}) => {
15271527
const { eventId, workflowId, errorId } = params;
1528-
const data = await axios.get(
1528+
const data = await axios.get<EventDetailsState["workflowErrorDetails"]>(
15291529
`/admin-ng/event/${eventId}/workflows/${workflowId}/errors/${errorId}.json`,
15301530
);
15311531
return await data.data;
@@ -1831,6 +1831,7 @@ export const saveWorkflowConfig = createAppAsyncThunk("eventDetails/saveWorkflow
18311831
const header = getHttpHeaders();
18321832
const data = new URLSearchParams();
18331833
// Scheduler service in Opencast expects values to be strings, so we convert them here
1834+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
18341835
data.append("configuration", JSON.stringify(jsonData, (_k, v) => v && typeof v === "object" ? v : "" + v));
18351836

18361837
axios

src/slices/groupSlice.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import { initialFormValuesNewGroup } from "../configs/modalConfig";
1010
/**
1111
* This file contains redux reducer for actions affecting the state of groups
1212
*/
13+
type FetchGroups = {
14+
total: GroupState["total"],
15+
count: GroupState["count"],
16+
limit: GroupState["limit"],
17+
offset: GroupState["offset"],
18+
results: GroupState["results"],
19+
};
20+
1321
export type Group = {
1422
description: string,
1523
id: string,
@@ -54,7 +62,7 @@ export const fetchGroups = createAppAsyncThunk("groups/fetchGroups", async (_, {
5462
// Just make the async request here, and return the response.
5563
// This will automatically dispatch a `pending` action first,
5664
// and then `fulfilled` or `rejected` actions based on the promise.
57-
const res = await axios.get("/admin-ng/groups/groups.json", { params: params });
65+
const res = await axios.get<FetchGroups>("/admin-ng/groups/groups.json", { params: params });
5866
return res.data;
5967
});
6068

@@ -114,13 +122,7 @@ const groupSlice = createSlice({
114122
.addCase(fetchGroups.pending, state => {
115123
state.status = "loading";
116124
})
117-
.addCase(fetchGroups.fulfilled, (state, action: PayloadAction<{
118-
total: GroupState["total"],
119-
count: GroupState["count"],
120-
limit: GroupState["limit"],
121-
offset: GroupState["offset"],
122-
results: GroupState["results"],
123-
}>) => {
125+
.addCase(fetchGroups.fulfilled, (state, action: PayloadAction<FetchGroups>) => {
124126
state.status = "succeeded";
125127
const groups = action.payload;
126128
state.total = groups.total;

src/slices/jobSlice.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { createAppAsyncThunk } from "../createAsyncThunkWithTypes";
88
/**
99
* This file contains redux reducer for actions affecting the state of jobs
1010
*/
11+
type FetchJobs = {
12+
total: JobState["total"],
13+
count: JobState["count"],
14+
limit: JobState["limit"],
15+
offset: JobState["offset"],
16+
results: JobState["results"],
17+
};
18+
1119
export type Job = {
1220
creator: string,
1321
id: number,
@@ -56,7 +64,7 @@ export const fetchJobs = createAppAsyncThunk("jobs/fetchJobs", async (_, { getSt
5664
// This will automatically dispatch a `pending` action first,
5765
// and then `fulfilled` or `rejected` actions based on the promise.
5866
// /jobs.json?limit=0&offset=0&filter={filter}&sort={sort}
59-
const res = await axios.get("/admin-ng/job/jobs.json?", { params: params });
67+
const res = await axios.get<FetchJobs>("/admin-ng/job/jobs.json?", { params: params });
6068
return res.data;
6169
});
6270

@@ -76,13 +84,7 @@ const jobSlice = createSlice({
7684
.addCase(fetchJobs.pending, state => {
7785
state.status = "loading";
7886
})
79-
.addCase(fetchJobs.fulfilled, (state, action: PayloadAction<{
80-
total: JobState["total"],
81-
count: JobState["count"],
82-
limit: JobState["limit"],
83-
offset: JobState["offset"],
84-
results: JobState["results"],
85-
}>) => {
87+
.addCase(fetchJobs.fulfilled, (state, action: PayloadAction<FetchJobs>) => {
8688
state.status = "succeeded";
8789
const jobs = action.payload;
8890
state.total = jobs.total;

src/slices/recordingDetailsSlice.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { createAppAsyncThunk } from "../createAsyncThunkWithTypes";
55
/**
66
* This file contains redux reducer for actions affecting the state of a recording/capture agent
77
*/
8+
type FetchRecordingDetails = {
9+
Name: RecordingDetailsState["name"],
10+
Status: RecordingDetailsState["status"],
11+
Update: RecordingDetailsState["update"],
12+
URL: RecordingDetailsState["url"],
13+
capabilities: RecordingDetailsState["capabilities"],
14+
configuration: RecordingDetailsState["configuration"],
15+
inputs: RecordingDetailsState["inputs"],
16+
}
17+
818
export interface RecordingDetails {
919
name: string,
1020
status: string,
@@ -38,7 +48,7 @@ export const fetchRecordingDetails = createAppAsyncThunk("recordingDetails/fetch
3848
// Just make the async request here, and return the response.
3949
// This will automatically dispatch a `pending` action first,
4050
// and then `fulfilled` or `rejected` actions based on the promise.
41-
const res = await axios.get(`/admin-ng/capture-agents/${name}`);
51+
const res = await axios.get<FetchRecordingDetails>(`/admin-ng/capture-agents/${name}`);
4252
return res.data;
4353
});
4454

@@ -52,15 +62,7 @@ const recordingDetailsSlice = createSlice({
5262
.addCase(fetchRecordingDetails.pending, state => {
5363
state.statusRecordingDetails = "loading";
5464
})
55-
.addCase(fetchRecordingDetails.fulfilled, (state, action: PayloadAction<{
56-
Name: RecordingDetailsState["name"],
57-
Status: RecordingDetailsState["status"],
58-
Update: RecordingDetailsState["update"],
59-
URL: RecordingDetailsState["url"],
60-
capabilities: RecordingDetailsState["capabilities"],
61-
configuration: RecordingDetailsState["configuration"],
62-
inputs: RecordingDetailsState["inputs"],
63-
}>) => {
65+
.addCase(fetchRecordingDetails.fulfilled, (state, action: PayloadAction<FetchRecordingDetails>) => {
6466
state.statusRecordingDetails = "succeeded";
6567
const recordingDetails = action.payload;
6668
state.name = recordingDetails.Name;

src/slices/seriesDetailsSlice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export const updateSeriesTobiraPath = createAppAsyncThunk("series/updateSeriesTo
380380
}
381381

382382
try {
383-
const response = await axios.post(`/admin-ng/series/${params.seriesId}/tobira/path`, tobiraParams.toString(), {
383+
const response = await axios.post<unknown>(`/admin-ng/series/${params.seriesId}/tobira/path`, tobiraParams.toString(), {
384384
headers: {
385385
"Content-Type": "application/x-www-form-urlencoded",
386386
},
@@ -412,7 +412,7 @@ export const removeSeriesTobiraPath = createAppAsyncThunk("series/removeSeriesTo
412412
const path = encodeURIComponent(params.currentPath);
413413

414414
try {
415-
const response = await axios.delete(
415+
const response = await axios.delete<unknown>(
416416
`/admin-ng/series/${params.seriesId}/tobira/${path}`,
417417
);
418418

src/slices/seriesSlice.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ import { handleTobiraError } from "./shared/tobiraErrors";
2020
/**
2121
* This file contains redux reducer for actions affecting the state of series
2222
*/
23+
type FetchSeries = {
24+
total: SeriesState["total"],
25+
count: SeriesState["count"],
26+
limit: SeriesState["limit"],
27+
offset: SeriesState["offset"],
28+
results: SeriesState["results"],
29+
};
30+
2331
export type Series = {
2432
contributors: string[],
2533
createdBy?: string,
@@ -127,7 +135,7 @@ export const fetchSeries = createAppAsyncThunk("series/fetchSeries", async (_, {
127135
// This will automatically dispatch a `pending` action first,
128136
// and then `fulfilled` or `rejected` actions based on the promise.
129137
// /series.json?sortorganizer={sortorganizer}&sort={sort}&filter={filter}&offset=0&limit=100
130-
const res = await axios.get("/admin-ng/series/series.json", { params: params });
138+
const res = await axios.get<FetchSeries>("/admin-ng/series/series.json", { params: params });
131139
return res.data;
132140
});
133141

@@ -429,13 +437,7 @@ const seriesSlice = createSlice({
429437
.addCase(fetchSeries.pending, state => {
430438
state.status = "loading";
431439
})
432-
.addCase(fetchSeries.fulfilled, (state, action: PayloadAction<{
433-
total: SeriesState["total"],
434-
count: SeriesState["count"],
435-
limit: SeriesState["limit"],
436-
offset: SeriesState["offset"],
437-
results: SeriesState["results"],
438-
}>) => {
440+
.addCase(fetchSeries.fulfilled, (state, action: PayloadAction<FetchSeries>) => {
439441
state.status = "succeeded";
440442
const series = action.payload;
441443
state.total = series.total;

0 commit comments

Comments
 (0)