From 2a77509f9e19dba3f321f999ed9c8eba77665a4f Mon Sep 17 00:00:00 2001 From: David Teller Date: Thu, 22 Jul 2021 08:24:12 +0200 Subject: [PATCH] Lint: Enabling 'noImplicitReturns' --- src/commands/AddRemoveRoomFromDirectoryCommand.ts | 3 ++- src/commands/AliasCommands.ts | 9 ++++++--- src/commands/DeactivateCommand.ts | 3 ++- src/commands/ImportCommand.ts | 3 ++- src/commands/SetDefaultBanListCommand.ts | 3 ++- src/commands/ShutdownRoomCommand.ts | 3 ++- src/commands/WatchUnwatchCommand.ts | 6 ++++-- src/models/ListRule.ts | 6 +++++- tsconfig.json | 2 ++ 9 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/commands/AddRemoveRoomFromDirectoryCommand.ts b/src/commands/AddRemoveRoomFromDirectoryCommand.ts index fa81452..1dd1459 100644 --- a/src/commands/AddRemoveRoomFromDirectoryCommand.ts +++ b/src/commands/AddRemoveRoomFromDirectoryCommand.ts @@ -23,7 +23,8 @@ async function addRemoveFromDirectory(inRoomId: string, event: any, mjolnir: Mjo const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(inRoomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(inRoomId, reply); + mjolnir.client.sendMessage(inRoomId, reply); + return; } const targetRoomId = await mjolnir.client.resolveRoom(roomRef); diff --git a/src/commands/AliasCommands.ts b/src/commands/AliasCommands.ts index 5ba5851..2539fab 100644 --- a/src/commands/AliasCommands.ts +++ b/src/commands/AliasCommands.ts @@ -28,7 +28,8 @@ export async function execMoveAliasCommand(roomId: string, event: any, mjolnir: const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(roomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.client.deleteRoomAlias(movingAlias); @@ -48,7 +49,8 @@ export async function execAddAliasCommand(roomId: string, event: any, mjolnir: M const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(roomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } const newRoomId = await mjolnir.client.resolveRoom(targetRoom); @@ -66,7 +68,8 @@ export async function execRemoveAliasCommand(roomId: string, event: any, mjolnir const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(roomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.client.deleteRoomAlias(aliasToRemove); diff --git a/src/commands/DeactivateCommand.ts b/src/commands/DeactivateCommand.ts index 7df2ac4..39743f4 100644 --- a/src/commands/DeactivateCommand.ts +++ b/src/commands/DeactivateCommand.ts @@ -26,7 +26,8 @@ export async function execDeactivateCommand(roomId: string, event: any, mjolnir: const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(roomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.deactivateSynapseUser(victim); diff --git a/src/commands/ImportCommand.ts b/src/commands/ImportCommand.ts index d7e67c3..56f9646 100644 --- a/src/commands/ImportCommand.ts +++ b/src/commands/ImportCommand.ts @@ -28,7 +28,8 @@ export async function execImportCommand(roomId: string, event: any, mjolnir: Mjo const errMessage = "Unable to find list - check your shortcode."; const errReply = RichReply.createFor(roomId, event, errMessage, errMessage); errReply["msgtype"] = "m.notice"; - return mjolnir.client.sendMessage(roomId, errReply); + mjolnir.client.sendMessage(roomId, errReply); + return; } let importedRules = 0; diff --git a/src/commands/SetDefaultBanListCommand.ts b/src/commands/SetDefaultBanListCommand.ts index b7116a1..f4927f1 100644 --- a/src/commands/SetDefaultBanListCommand.ts +++ b/src/commands/SetDefaultBanListCommand.ts @@ -27,7 +27,8 @@ export async function execSetDefaultListCommand(roomId: string, event: any, mjol const replyText = "No ban list with that shortcode was found."; const reply = RichReply.createFor(roomId, event, replyText, replyText); reply["msgtype"] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.client.setAccountData(DEFAULT_LIST_EVENT_TYPE, {shortcode}); diff --git a/src/commands/ShutdownRoomCommand.ts b/src/commands/ShutdownRoomCommand.ts index 71990c5..29d58b4 100644 --- a/src/commands/ShutdownRoomCommand.ts +++ b/src/commands/ShutdownRoomCommand.ts @@ -26,7 +26,8 @@ export async function execShutdownRoomCommand(roomId: string, event: any, mjolni const message = "I am not a Synapse administrator, or the endpoint is blocked"; const reply = RichReply.createFor(roomId, event, message, message); reply['msgtype'] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.shutdownSynapseRoom(await mjolnir.client.resolveRoom(victim)); diff --git a/src/commands/WatchUnwatchCommand.ts b/src/commands/WatchUnwatchCommand.ts index b63ea80..d0c695d 100644 --- a/src/commands/WatchUnwatchCommand.ts +++ b/src/commands/WatchUnwatchCommand.ts @@ -24,7 +24,8 @@ export async function execWatchCommand(roomId: string, event: any, mjolnir: Mjol const replyText = "Cannot watch list due to error - is that a valid room alias?"; const reply = RichReply.createFor(roomId, event, replyText, replyText); reply["msgtype"] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅'); } @@ -36,7 +37,8 @@ export async function execUnwatchCommand(roomId: string, event: any, mjolnir: Mj const replyText = "Cannot unwatch list due to error - is that a valid room alias?"; const reply = RichReply.createFor(roomId, event, replyText, replyText); reply["msgtype"] = "m.notice"; - return mjolnir.client.sendMessage(roomId, reply); + mjolnir.client.sendMessage(roomId, reply); + return; } await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅'); } diff --git a/src/models/ListRule.ts b/src/models/ListRule.ts index 5e69ed2..a5a9066 100644 --- a/src/models/ListRule.ts +++ b/src/models/ListRule.ts @@ -32,8 +32,12 @@ export class ListRule { this.glob = new MatrixGlob(entity); } - public get recommendation(): string { + /** + * The recommendation for this rule, or `null` if there is no recommendation or the recommendation is invalid. + */ + public get recommendation(): string|null { if (RECOMMENDATION_BAN_TYPES.includes(this.action)) return RECOMMENDATION_BAN; + return null; } public isMatch(entity: string): boolean { diff --git a/tsconfig.json b/tsconfig.json index 90b6b94..0cfc74e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,11 @@ { "compilerOptions": { + "alwaysStrict": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "module": "commonjs", "moduleResolution": "node", + "noImplicitReturns": true, "target": "es2015", "noImplicitAny": false, "sourceMap": true,