From a2f3b014f682fffe62b8f9ff9cdb75f979c024ee Mon Sep 17 00:00:00 2001 From: Tarun Chauhan Date: Wed, 11 Jan 2023 00:46:25 +0530 Subject: [PATCH] fix eslint errors --- website/static/js/code-block-buttons.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/website/static/js/code-block-buttons.js b/website/static/js/code-block-buttons.js index 0279288ca263..68f1953d1ce9 100644 --- a/website/static/js/code-block-buttons.js +++ b/website/static/js/code-block-buttons.js @@ -1,6 +1,6 @@ -// Turn off ESLint for this file because it's sent down to users as-is. -/* eslint-disable */ -window.addEventListener("load", function () { +"use strict"; + +window.addEventListener("load", () => { function button(label, ariaLabel, icon, className) { const btn = document.createElement("button"); btn.classList.add("btnIcon", className); @@ -17,9 +17,9 @@ window.addEventListener("load", function () { } function addButtons(codeBlockSelector, btn) { - document.querySelectorAll(codeBlockSelector).forEach(function (code) { + for (const code of document.querySelectorAll(codeBlockSelector)) { code.parentNode.appendChild(btn.cloneNode(true)); - }); + } } const copyIcon = @@ -29,18 +29,18 @@ window.addEventListener("load", function () { ".hljs", button("Copy", "Copy code to clipboard", copyIcon, "btnClipboard") ); - + // eslint-disable-next-line no-undef const clipboard = new ClipboardJS(".btnClipboard", { - target: function (trigger) { + target(trigger) { return trigger.parentNode.querySelector("code"); }, }); - clipboard.on("success", function (event) { + clipboard.on("success", (event) => { event.clearSelection(); const textEl = event.trigger.querySelector(".btnIcon__label"); textEl.textContent = "Copied"; - setTimeout(function () { + setTimeout(() => { textEl.textContent = "Copy"; }, 2000); });