From f54b62768511d7fa51a3fb33e32fc19e239f9c74 Mon Sep 17 00:00:00 2001
From: Christian Paul <christianp@matrix.org>
Date: Wed, 2 Dec 2020 13:19:26 +0100
Subject: [PATCH] Migrate tslint:disable no-console

---
 .eslintrc                    |  1 +
 src/discordas.ts             |  2 +-
 tools/addRoomsToDirectory.ts | 24 +++++++++-------
 tools/addbot.ts              | 56 ++++++++++++++++++------------------
 tools/adminme.ts             |  4 +--
 tools/chanfix.ts             |  2 +-
 tools/ghostfix.ts            | 22 +++++++-------
 tools/userClientTools.ts     |  2 +-
 8 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index 69c5598..fe208ed 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -33,6 +33,7 @@
         "@typescript-eslint/array-type": "error",
         "@typescript-eslint/promise-function-async": "error",
         "no-bitwise": "error",
+        "no-console": "error",
         "no-debugger": "error",
         "prefer-template": "error",
         // Disable these as they were introduced by @typescript-eslint/recommended
diff --git a/src/discordas.ts b/src/discordas.ts
index ad6c6ca..621ddce 100644
--- a/src/discordas.ts
+++ b/src/discordas.ts
@@ -106,7 +106,7 @@ function setupLogging(): void {
 async function run(): Promise<void> {
     const opts = cliArgs(commandOptions);
     if (opts.help) {
-        /* tslint:disable:no-console */
+        // eslint-disable-next-line no-console
         console.log(usage([
             {
                 content: "The matrix appservice for discord",
diff --git a/tools/addRoomsToDirectory.ts b/tools/addRoomsToDirectory.ts
index 520a247..6b06ac7 100644
--- a/tools/addRoomsToDirectory.ts
+++ b/tools/addRoomsToDirectory.ts
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-/* tslint:disable:no-console */
+/* eslint-disable no-console */
 /**
  * Allows you to become an admin for a room the bot is in control of.
  */
@@ -53,30 +53,32 @@ const optionDefinitions = [
 const options = args(optionDefinitions);
 
 if (options.help) {
-    /* tslint:disable:no-console */
+    /* eslint-disable no-console */
     console.log(usage([
-    {
-        content: "A tool to set all the bridged rooms to visible in the directory.",
-        header: "Add rooms to directory",
-    },
-    {
-        header: "Options",
-        optionList: optionDefinitions,
-    },
+        {
+            content: "A tool to set all the bridged rooms to visible in the directory.",
+            header: "Add rooms to directory",
+        },
+        {
+            header: "Options",
+            optionList: optionDefinitions,
+        },
     ]));
     process.exit(0);
 }
 
 const {store, appservice} = ToolsHelper.getToolDependencies(options.config, options.registration);
 
-async function run() {
+async function run(): Promise<void> {
     try {
         await store!.init();
     } catch (e) {
         log.error(`Failed to load database`, e);
     }
     let rooms = await store!.roomStore.getEntriesByRemoteRoomData({
+        /* eslint-disable @typescript-eslint/camelcase */
         discord_type: "text",
+        /* eslint-disable @typescript-eslint/camelcase */
     });
     rooms = rooms.filter((r) => r.remote && r.remote.get("plumbed") !== true );
     log.info(`Got ${rooms.length} rooms to set`);
diff --git a/tools/addbot.ts b/tools/addbot.ts
index d505fdd..6fd4517 100644
--- a/tools/addbot.ts
+++ b/tools/addbot.ts
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-/* tslint:disable:no-bitwise no-console no-var-requires */
+/* eslint-disable no-bitwise, no-console */
 /**
  * Generates a URL you can use to authorize a bot with a guild.
  */
@@ -26,42 +26,42 @@ import { Util } from "../src/util";
 import { DiscordBridgeConfig } from "../src/config";
 
 const optionDefinitions = [
-  {
-      alias: "h",
-      description: "Display this usage guide.",
-      name: "help",
-      type: Boolean,
-  },
-  {
-      alias: "c",
-      defaultValue: "config.yaml",
-      description: "The AS config file.",
-      name: "config",
-      type: String,
-      typeLabel: "<config.yaml>",
-  },
+    {
+        alias: "h",
+        description: "Display this usage guide.",
+        name: "help",
+        type: Boolean,
+    },
+    {
+        alias: "c",
+        defaultValue: "config.yaml",
+        description: "The AS config file.",
+        name: "config",
+        type: String,
+        typeLabel: "<config.yaml>",
+    },
 ];
 
 const options = args(optionDefinitions);
 
 if (options.help) {
-  /* tslint:disable:no-console */
-  console.log(usage([
-  {
-      content: "A tool to obtain the Discord bot invitation URL.",
-      header: "Add bot",
-  },
-  {
-      header: "Options",
-      optionList: optionDefinitions,
-  },
-  ]));
-  process.exit(0);
+    // eslint-disable-next-line no-console
+    console.log(usage([
+        {
+            content: "A tool to obtain the Discord bot invitation URL.",
+            header: "Add bot",
+        },
+        {
+            header: "Options",
+            optionList: optionDefinitions,
+        },
+    ]));
+    process.exit(0);
 }
 
 const yamlConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8"));
 if (yamlConfig === null || typeof yamlConfig !== "object") {
-  throw Error("You have an error in your discord config.");
+    throw Error("You have an error in your discord config.");
 }
 const url = Util.GetBotLink(yamlConfig as DiscordBridgeConfig);
 console.log(`Go to ${url} to invite the bot into a guild.`);
diff --git a/tools/adminme.ts b/tools/adminme.ts
index 1504d0e..06e756d 100644
--- a/tools/adminme.ts
+++ b/tools/adminme.ts
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-/* tslint:disable:no-console */
+/* eslint-disable no-console */
 /**
  * Allows you to become an admin for a room that the bot is in control of.
  */
@@ -71,7 +71,7 @@ const optionDefinitions = [
 const options = args(optionDefinitions);
 
 if (options.help) {
-    /* tslint:disable:no-console */
+    /* eslint-disable no-console */
     console.log(usage([
         {
             content: "A tool to give a user a power level in a bot user controlled room.",
diff --git a/tools/chanfix.ts b/tools/chanfix.ts
index 9b293e8..5c186c6 100644
--- a/tools/chanfix.ts
+++ b/tools/chanfix.ts
@@ -51,7 +51,7 @@ const optionDefinitions = [
 const options = args(optionDefinitions);
 
 if (options.help) {
-    /* tslint:disable:no-console */
+    /* eslint-disable no-console */
     console.log(usage([
     {
         content: "A tool to fix channels of rooms already bridged " +
diff --git a/tools/ghostfix.ts b/tools/ghostfix.ts
index f542b2a..d5f6b40 100644
--- a/tools/ghostfix.ts
+++ b/tools/ghostfix.ts
@@ -60,17 +60,17 @@ const optionDefinitions = [
 const options = args(optionDefinitions);
 
 if (options.help) {
-    /* tslint:disable:no-console */
+    /* eslint-disable no-console */
     console.log(usage([
-    {
-        content: "A tool to fix usernames of ghosts already in " +
-        "matrix rooms, to make sure they represent the correct discord usernames.",
-        header: "Fix usernames of joined ghosts",
-    },
-    {
-        header: "Options",
-        optionList: optionDefinitions,
-    },
+        {
+            content: "A tool to fix usernames of ghosts already in " +
+            "matrix rooms, to make sure they represent the correct discord usernames.",
+            header: "Fix usernames of joined ghosts",
+        },
+        {
+            header: "Options",
+            optionList: optionDefinitions,
+        },
     ]));
     process.exit(0);
 }
@@ -130,4 +130,4 @@ async function run() {
     process.exit(0);
 }
 
-run(); // tslint:disable-line no-floating-promises
+run(); // eslint-disable no-floating-promises
diff --git a/tools/userClientTools.ts b/tools/userClientTools.ts
index a6d923f..a959101 100644
--- a/tools/userClientTools.ts
+++ b/tools/userClientTools.ts
@@ -57,7 +57,7 @@ const optionDefinitions = [
 
 const options = args(optionDefinitions);
 if (options.help || (options.add && options.remove) || !(options.add || options.remove)) {
-    /* tslint:disable:no-console */
+    /* eslint-disable no-console */
     console.log(usage([
         {
             content: "A tool to give a user a power level in a bot user controlled room.",
-- 
GitLab