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

@@ -246,38 +246,6 @@ export function sanitiseRoomNameInput(input: string): string {
return input;
}
/**
* XXX: What is this trying to do? It looks like it's getting the localpart from
* a room alias, but why is it splitting on hyphens and then putting spaces in??
* @param roomId
* @returns
*/
export function roomNameFromRoomId(roomId: string): string {
return roomId
.match(/([^:]+):.*$/)![1]
.substring(1)
.split("-")
.map((part) =>
part.length > 0 ? part.charAt(0).toUpperCase() + part.slice(1) : part,
)
.join(" ")
.toLowerCase();
}
export function isLocalRoomId(roomId: string, client: MatrixClient): boolean {
if (!roomId) {
return false;
}
const parts = roomId.match(/[^:]+:(.*)$/)!;
if (parts.length < 2) {
return false;
}
return parts[1] === client.getDomain();
}
interface CreateRoomResult {
roomId: string;
alias?: string;