Skip to content

Commit d270762

Browse files
committed
Remove+Fix all lint suppressions
1 parent d6e7286 commit d270762

38 files changed

Lines changed: 298 additions & 307 deletions

web/eslint.config.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
11
import js from "@eslint/js";
22
import tseslint from "@typescript-eslint/eslint-plugin";
3-
import tsParser from "@typescript-eslint/parser";
43
import react from "eslint-plugin-react";
54
import reactHooks from "eslint-plugin-react-hooks";
65
import globals from "globals";
76

87
export default [
98
js.configs.recommended,
9+
...tseslint.configs["flat/recommended"],
10+
react.configs.flat.recommended,
11+
react.configs.flat["jsx-runtime"],
12+
reactHooks.configs.flat.recommended,
1013
{
1114
files: ["**/*.ts", "**/*.tsx"],
1215
languageOptions: {
13-
parser: tsParser,
1416
parserOptions: {
1517
ecmaVersion: "latest",
16-
sourceType: "module",
1718
ecmaFeatures: { jsx: true },
1819
},
1920
globals: {
2021
...globals.browser,
2122
...globals.node,
2223
},
2324
},
24-
plugins: {
25-
react,
26-
"react-hooks": reactHooks,
27-
"@typescript-eslint": tseslint,
28-
},
29-
rules: {
30-
// React rules
31-
"react/react-in-jsx-scope": "off",
32-
"react-hooks/rules-of-hooks": "error",
33-
"react-hooks/exhaustive-deps": "warn",
34-
35-
// TypeScript rules
36-
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
37-
"@typescript-eslint/explicit-function-return-type": "off",
38-
},
3925
settings: {
4026
react: { version: "detect" },
4127
},
4228
},
4329
];
44-

web/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import { Routes, Route } from "react-router-dom";
32

43
import BrowserBroadcaster from "./components/broadcast/Broadcast";

web/src/components/admin/Frontpage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState } from "react";
1+
import { useContext, useState } from "react";
22
import { useNavigate } from "react-router-dom";
33
import Card from "../shared/Card";
44
import Button from "../shared/Button";

web/src/components/admin/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState } from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import TextInputDialog from "../shared/TextInputDialog";
33
import ErrorMessagePanel from "../shared/ErrorMessagePanel";
44
import AdminFrontpage from "./Frontpage";

web/src/components/admin/menus/ApiPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState } from "react";
1+
import { useContext, useState } from "react";
22
import { LocaleContext } from "../../../providers/LocaleProvider";
33

44
interface ApiSettingsResult {

web/src/components/admin/menus/LoggingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState } from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import { LocaleContext } from "../../../providers/LocaleProvider";
33
import {
44
clearAdminToken,

web/src/components/admin/menus/ProfilesPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ArrowPathIcon, XMarkIcon } from "@heroicons/react/16/solid";
2-
import React, { useContext, useEffect, useState } from "react";
2+
import { useContext, useEffect, useState } from "react";
33
import Button from "../../shared/Button";
44
import ModalTextInput from "../../shared/ModalTextInput";
55
import ModalMessageBox from "../../shared/ModalMessageBox";
@@ -25,10 +25,6 @@ const ProfilesPage = () => {
2525
const [isRemoveProfileModalOpen, setIsRemoveProfileModalOpen] = useState<string>("");
2626
const [errorMessage, setErrorMessage] = useState<string>();
2727

28-
useEffect(() => {
29-
refreshProfiles();
30-
}, []);
31-
3228
const copyTokenToClipboard = (token: string) => navigator.clipboard.writeText(token)
3329

3430
const refreshProfiles = () => {
@@ -113,6 +109,10 @@ const ProfilesPage = () => {
113109
});
114110
};
115111

112+
useEffect(() => {
113+
refreshProfiles();
114+
}, []);
115+
116116

117117
return (
118118
<div className="p-6 w-full h-full max-w-6xl mx-auto flex flex-col justify-between">

web/src/components/admin/menus/StatusPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState } from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import { LocaleContext } from "../../../providers/LocaleProvider";
33
import {
44
clearAdminToken,

web/src/components/broadcast/Broadcast.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useRef, useState } from 'react'
1+
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
22
import { useLocation } from 'react-router-dom'
33
import { useNavigate } from 'react-router-dom'
44
import PlayerHeader from '../playerHeader/PlayerHeader';
@@ -45,25 +45,30 @@ function BrowserBroadcaster() {
4545

4646
const endStream = () => navigate('/')
4747
const requestMedia = (source: MediaSource) => {
48+
if (!navigator.mediaDevices) {
49+
setMediaAccessError(() => ErrorMessageEnum.NoMediaDevices);
50+
return
51+
}
52+
4853
setUseDisplayMedia(source)
4954
setMediaRequestCount(prev => prev + 1)
5055
}
5156

52-
const stopLocalMediaStream = (localMediaStream: MediaStream | null) => {
57+
const stopLocalMediaStream = useCallback((localMediaStream: MediaStream | null) => {
5358
if (!localMediaStream) {
5459
return
5560
}
5661

5762
localMediaStream
5863
.getTracks()
5964
.forEach((streamTrack: MediaStreamTrack) => streamTrack.stop())
60-
}
65+
}, [])
6166

62-
const getSenderByKind = (peerConnection: RTCPeerConnection, kind: "audio" | "video") => {
67+
const getSenderByKind = useCallback((peerConnection: RTCPeerConnection, kind: "audio" | "video") => {
6368
return peerConnection.getTransceivers().find(transceiver => transceiver.sender.track?.kind === kind)?.sender ??
6469
peerConnection.getTransceivers().find(transceiver => transceiver.receiver.track.kind === kind)?.sender ??
6570
null
66-
}
71+
}, [])
6772

6873
useEffect(() => {
6974
return () => {
@@ -73,20 +78,14 @@ function BrowserBroadcaster() {
7378
peerConnectionRef.current?.close()
7479
peerConnectionRef.current = null
7580
}
76-
}, [])
81+
}, [stopLocalMediaStream])
7782

7883
useEffect(() => {
7984
if (useDisplayMedia === "None") {
8085
return;
8186
}
8287

83-
if (!navigator.mediaDevices) {
84-
setMediaAccessError(() => ErrorMessageEnum.NoMediaDevices);
85-
setUseDisplayMedia(() => "None")
86-
return
87-
}
88-
89-
let cancelled = false
88+
let cancelled = false
9089

9190
const mediaPromise = useDisplayMedia == "Screen" ?
9291
navigator.mediaDevices.getDisplayMedia(mediaOptions) :
@@ -230,8 +229,7 @@ function BrowserBroadcaster() {
230229
return () => {
231230
cancelled = true
232231
}
233-
// eslint-disable-next-line react-hooks/exhaustive-deps
234-
}, [videoRef, useDisplayMedia, mediaRequestCount, location.pathname])
232+
}, [getSenderByKind, mediaRequestCount, stopLocalMediaStream, streamKey, useDisplayMedia])
235233

236234
useEffect(() => {
237235
hasSignalRef.current = hasSignal;

web/src/components/broadcast/ProfileSettings.tsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useLayoutEffect, useState } from "react";
1+
import { useCallback, useContext, useLayoutEffect, useState } from "react";
22
import Card from "../shared/Card";
33
import Input from "../shared/Input";
44
import Toggle from "../shared/Toggle";
@@ -14,38 +14,20 @@ interface Profile {
1414
}
1515

1616
interface ProfileSettingsProps {
17-
// eslint-disable-next-line no-unused-vars
1817
stateHasChanged: (isActive: boolean, streamKey: string) => void;
1918
}
2019

2120
export default function ProfileSettings(props: ProfileSettingsProps) {
2221
const { locale } = useContext(LocaleContext)
22+
const { stateHasChanged } = props
2323
const streamKey = location.pathname.split('/').pop()
2424

2525
const [profileType, setProfileType] = useState<"Public" | "Reserved">("Public")
2626
const [isPublic, setIsPublic] = useState<"Public" | "Private">("Public")
2727
const [motd, setMotd] = useState<string>("")
2828

29-
const updateSettings = () => {
30-
fetch(`/api/whip/profile`, {
31-
method: "POST",
32-
headers: {
33-
Authorization: `Bearer ${toBase64Utf8(streamKey)}`,
34-
},
35-
body: JSON.stringify({
36-
motd: motd,
37-
isPublic: isPublic === "Public"
38-
}),
39-
}).then((result) => {
40-
if (result.status > 400 && result.status < 500) {
41-
return;
42-
}
43-
44-
getSettings();
45-
});
46-
};
47-
const getSettings = () => {
48-
fetch(`/api/whip/profile`, {
29+
const getSettings = useCallback(() => {
30+
return fetch(`/api/whip/profile`, {
4931
method: "GET",
5032
headers: {
5133
Authorization: `Bearer ${toBase64Utf8(streamKey)}`,
@@ -56,7 +38,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
5638
}
5739

5840
return result.json()
59-
}).then((result: Profile) => {
41+
}).then((result: Profile | undefined) => {
6042

6143
if (result === undefined) {
6244
setProfileType(() => "Public")
@@ -66,14 +48,32 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
6648
setProfileType(() => "Reserved")
6749
setIsPublic(() => result.isPublic ? "Public" : "Private")
6850
setMotd(() => result.motd)
69-
props.stateHasChanged?.(result.isActive, result.streamKey)
51+
stateHasChanged?.(result.isActive, result.streamKey)
52+
});
53+
}, [stateHasChanged, streamKey])
54+
55+
const updateSettings = useCallback(() => {
56+
fetch(`/api/whip/profile`, {
57+
method: "POST",
58+
headers: {
59+
Authorization: `Bearer ${toBase64Utf8(streamKey)}`,
60+
},
61+
body: JSON.stringify({
62+
motd: motd,
63+
isPublic: isPublic === "Public"
64+
}),
65+
}).then((result) => {
66+
if (result.status > 400 && result.status < 500) {
67+
return;
68+
}
69+
70+
void getSettings();
7071
});
71-
};
72+
}, [getSettings, isPublic, motd, streamKey]);
7273

7374
useLayoutEffect(() => {
74-
getSettings()
75-
// eslint-disable-next-line react-hooks/exhaustive-deps
76-
}, [])
75+
void getSettings()
76+
}, [getSettings])
7777

7878
if (profileType === "Public") {
7979
return <></>

0 commit comments

Comments
 (0)