Skip to content

Commit 42bc389

Browse files
committed
Activate eslint no-unsafe-return
Enable eslint rule no-unsafe-return
1 parent 0324cb4 commit 42bc389

6 files changed

Lines changed: 26 additions & 36 deletions

File tree

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default [
1313
// // TODO: We want to turn these on eventually
1414
"@typescript-eslint/no-base-to-string": "off",
1515
"@typescript-eslint/no-floating-promises": "off",
16-
"@typescript-eslint/no-unsafe-return": "off",
1716
"@typescript-eslint/restrict-template-expressions": "off",
1817
},
1918
},

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-return */
12
/* eslint-disable @typescript-eslint/no-explicit-any */
23
/* eslint-disable @typescript-eslint/no-unsafe-argument */
34
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

src/main/Metadata.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ const Metadata: React.FC = () => {
403403
* @param value
404404
*/
405405
// eslint-disable-next-line max-len
406-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
406+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
407407
const parseValue = (field: MetadataField | null, value: any) => {
408408
let returnValue = value;
409409

@@ -448,7 +448,7 @@ const Metadata: React.FC = () => {
448448
return returnValue;
449449
};
450450
// eslint-disable-next-line max-len
451-
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
451+
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
452452

453453
/**
454454
* Callback for when the form is submitted

src/redux/metadataSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const fetchMetadata = createAppAsyncThunk("metadata/fetchMetadata", async
4343
}
4444

4545
const response = await client.get(`${settings.opencast.url}/editor/${settings.id}/metadata.json`);
46-
return JSON.parse(response);
46+
return JSON.parse(response) as metadata["catalogs"];
4747
});
4848

4949
/**

src/redux/videoSlice.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,32 @@ export const initialState: video & httpRequestState = {
8484
errorReason: "unknown",
8585
};
8686

87+
type FetchVideoInformation = {
88+
segments: Omit<Segment, "id">[],
89+
workflows: video["workflows"],
90+
tracks: video["tracks"],
91+
title: video["title"],
92+
date: string, // Date string
93+
duration: video["duration"],
94+
workflow_active: boolean,
95+
locking_active: video["lockingActive"],
96+
lock_refresh: video["lockRefresh"],
97+
lock_uuid: video["lock"]["uuid"],
98+
lock_user: video["lock"]["user"], // username
99+
waveformURIs: string[],
100+
subtitles: video["subtitlesFromOpencast"],
101+
local: boolean,
102+
customizedTrackSelection: boolean, // TODO: Figure out if this still exists
103+
}
104+
87105
export const fetchVideoInformation = createAppAsyncThunk("video/fetchVideoInformation", async () => {
88106
if (!settings.id) {
89107
throw new Error("Missing media package identifier");
90108
}
91109

92110
// const response = await client.get("https://legacy.opencast.org/admin-ng/tools/ID-dual-stream-demo/editor.json")
93111
const response = await client.get(`${settings.opencast.url}/editor/${settings.id}/edit.json`);
94-
return JSON.parse(response);
112+
return JSON.parse(response) as FetchVideoInformation;
95113
});
96114

97115
const updateCurrentlyAt = (state: video, milliseconds: number) => {
@@ -318,23 +336,7 @@ const videoSlice = createSlice({
318336
state.status = "loading";
319337
});
320338
builder.addCase(
321-
fetchVideoInformation.fulfilled, (state, action: PayloadAction<{
322-
segments: Omit<Segment, "id">[],
323-
workflows: video["workflows"],
324-
tracks: video["tracks"],
325-
title: video["title"],
326-
date: string, // Date string
327-
duration: video["duration"],
328-
workflow_active: boolean,
329-
locking_active: video["lockingActive"],
330-
lock_refresh: video["lockRefresh"],
331-
lock_uuid: video["lock"]["uuid"],
332-
lock_user: video["lock"]["user"], // username
333-
waveformURIs: string[],
334-
subtitles: video["subtitlesFromOpencast"],
335-
local: boolean,
336-
customizedTrackSelection: boolean, // TODO: Figure out if this still exists
337-
}>) => {
339+
fetchVideoInformation.fulfilled, (state, action: PayloadAction<FetchVideoInformation>) => {
338340
state.status = "success";
339341
const payload = action.payload;
340342

src/util/utilityFunctions.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,8 @@ export const convertMsToReadableString = (ms: number): string => {
2727
return result.join("");
2828
};
2929

30-
/**
31-
* Parses JSON. Returns [err, result]
32-
* @param str string that should be parsed
33-
*/
34-
export function safeJsonParse(str: string) {
35-
try {
36-
return [null, JSON.parse(str)];
37-
} catch (err) {
38-
return [err];
39-
}
40-
}
41-
4230
// eslint-disable-next-line max-len
43-
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
31+
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
4432
/**
4533
* Converts a working subtitle representation into a string
4634
*/
@@ -131,7 +119,7 @@ export function parseSubtitle(subtitle: string): SubtitleCue[] {
131119
return tree.cues;
132120
}
133121
// eslint-disable-next-line max-len
134-
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
122+
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
135123

136124
/**
137125
* Parse language code to language name

0 commit comments

Comments
 (0)