From e0b94a372a7d67430802f11bb58880de4a5c7f94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 5 Jan 2021 16:53:49 +0100 Subject: [PATCH] Use async function for event listener in `Core/Bbcode/Code` --- .eslintrc.js | 5 +++++ .../install/files/js/WoltLabSuite/Core/Bbcode/Code.js | 7 +++---- .../install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 70cc12846f..95884323e7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,6 +32,11 @@ module.exports = { "error", { "argsIgnorePattern": "^_" } + ], + "@typescript-eslint/no-misused-promises": [ + "error", { + "checksVoidReturn": false + } ] } }; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Code.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Code.js index c2c881189d..daae7e54b5 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Code.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Code.js @@ -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); } diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts index a05d4a2d85..65c73a6a8c 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Bbcode/Code.ts @@ -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); -- 2.20.1