Perform dead code analysis with Knip (#2575)

* Install Knip

* Clarify an import that was confusing Knip

* Fix issues detected by Knip

Including cleaning up some unused code and dependencies, using a React hook that we unintentionally stopped using, and also adding some previously undeclared dependencies.

* Run dead code analysis in lint script and CI

---------

Co-authored-by: Timo <toger5@hotmail.de>
This commit is contained in:
Robin
2024-08-27 20:06:57 -04:00
committed by GitHub
parent 51ae4c0a88
commit 7bca541cb6
20 changed files with 271 additions and 774 deletions

View File

@@ -15,7 +15,6 @@ limitations under the License.
*/
import { useEffect } from "react";
import EventEmitter, { EventMap } from "typed-emitter";
import type {
Listener,
@@ -60,20 +59,3 @@ export function useTypedEventEmitter<
};
}, [emitter, eventType, listener]);
}
// Shortcut for registering a listener on an eventemitter3 EventEmitter (ie. what the LiveKit SDK uses)
export function useEventEmitterThree<
EventType extends keyof T,
T extends EventMap,
>(
emitter: EventEmitter<T>,
eventType: EventType,
listener: T[EventType],
): void {
useEffect(() => {
emitter.on(eventType, listener);
return (): void => {
emitter.off(eventType, listener);
};
}, [emitter, eventType, listener]);
}