Use async function for event listener in `Core/Bbcode/Code`
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 5 Jan 2021 15:53:49 +0000 (16:53 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 5 Jan 2021 15:56:40 +0000 (16:56 +0100)
.eslintrc.js
wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Code.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts

index 70cc12846f54007658a4f468531b7c0932eb4df8..95884323e792e5718ec8ad6fb08e93ef175b7f06 100644 (file)
@@ -32,6 +32,11 @@ module.exports = {
       "error", {
         "argsIgnorePattern": "^_"
       }
+    ],
+    "@typescript-eslint/no-misused-promises": [
+      "error", {
+        "checksVoidReturn": false
+      }
     ]
   }
 };
index c2c881189d7e3893dc537def60e71dea528ceac2..daae7e54b5d8644950dcab6c14d2c63e75a4bbfd 100644 (file)
@@ -50,10 +50,9 @@ define(["require", "exports", "tslib", "../Language", "../Clipboard", "../Ui/Not
             const button = document.createElement("span");
             button.className = "icon icon24 fa-files-o pointer jsTooltip";
             button.setAttribute("title", Language.get("wcf.message.bbcode.code.copy"));
-            button.addEventListener("click", () => {
-                void Clipboard.copyElementTextToClipboard(this.codeContainer).then(() => {
-                    UiNotification.show(Language.get("wcf.message.bbcode.code.copy.success"));
-                });
+            button.addEventListener("click", async () => {
+                await Clipboard.copyElementTextToClipboard(this.codeContainer);
+                UiNotification.show(Language.get("wcf.message.bbcode.code.copy.success"));
             });
             header.appendChild(button);
         }
index a05d4a2d850798933842d65d28306cd4ad40558a..65c73a6a8cac3831a82d483b32362e9a4d640951 100644 (file)
@@ -64,10 +64,10 @@ class Code {
     const button = document.createElement("span");
     button.className = "icon icon24 fa-files-o pointer jsTooltip";
     button.setAttribute("title", Language.get("wcf.message.bbcode.code.copy"));
-    button.addEventListener("click", () => {
-      void Clipboard.copyElementTextToClipboard(this.codeContainer).then(() => {
-        UiNotification.show(Language.get("wcf.message.bbcode.code.copy.success"));
-      });
+    button.addEventListener("click", async () => {
+      await Clipboard.copyElementTextToClipboard(this.codeContainer);
+
+      UiNotification.show(Language.get("wcf.message.bbcode.code.copy.success"));
     });
 
     header.appendChild(button);