From c7b55c9c06265193fda136e81ed3be52df8dd722 Mon Sep 17 00:00:00 2001 From: xhyrom Date: Sun, 2 Jan 2022 19:02:40 +0100 Subject: [PATCH] refactor(*): eslint --- packages/website/.eslintignore | 2 + packages/website/next.config.js | 24 +++---- packages/website/public/script.js | 102 +++++++++++++++--------------- 3 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 packages/website/.eslintignore diff --git a/packages/website/.eslintignore b/packages/website/.eslintignore new file mode 100644 index 0000000..0727aad --- /dev/null +++ b/packages/website/.eslintignore @@ -0,0 +1,2 @@ +public/script.js +next.config.js \ No newline at end of file diff --git a/packages/website/next.config.js b/packages/website/next.config.js index fc09198..d0dcbcd 100644 --- a/packages/website/next.config.js +++ b/packages/website/next.config.js @@ -1,14 +1,14 @@ -const { createSecureHeaders } = require("next-secure-headers"); +const { createSecureHeaders } = require('next-secure-headers'); module.exports = { - assetPrefix: '/roles-bot/', - async headers() { - return [{ - source: "/(.*)", - headers: createSecureHeaders({ - forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }], - referrerPolicy: "same-origin", - }), - }]; - }, -} \ No newline at end of file + assetPrefix: '/roles-bot/', + async headers() { + return [{ + source: '/(.*)', + headers: createSecureHeaders({ + forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }], + referrerPolicy: 'same-origin', + }), + }]; + }, +}; \ No newline at end of file diff --git a/packages/website/public/script.js b/packages/website/public/script.js index 9a8c471..a13d399 100644 --- a/packages/website/public/script.js +++ b/packages/website/public/script.js @@ -1,68 +1,68 @@ -let json = { - roles: [] -} +const json = { + roles: [] +}; $('input').change((e) => { - json[e.currentTarget.id] = e.currentTarget.value; + json[e.currentTarget.id] = e.currentTarget.value; - document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; -}) + document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; +}); $('button[id=addRole]').click((e) => { - Swal.fire({ - title: 'Add Role', - html: + Swal.fire({ + title: 'Add Role', + html: '' + '' + '', - preConfirm: function () { - return new Promise(function (resolve) { - resolve([ - $('#swal-input1').val(), - $('#swal-input2').val(), - $('#swal-input3').val() - ]) - }) - } - }).then(function (result) { - if (result.value?.[0] && result.value?.[1]) { - json.roles.push({ - id: result.value[1], - label: result.value[0], - emoji: result.value[2] || null - }) + preConfirm: function () { + return new Promise(function (resolve) { + resolve([ + $('#swal-input1').val(), + $('#swal-input2').val(), + $('#swal-input3').val() + ]); + }); + } + }).then(function (result) { + if (result.value?.[0] && result.value?.[1]) { + json.roles.push({ + id: result.value[1], + label: result.value[0], + emoji: result.value[2] || null + }); - document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; - } else Swal.fire('Missing parameters') - }).catch(swal.noop) -}) + document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; + } else Swal.fire('Missing parameters'); + }).catch(swal.noop); +}); $('pre[id=jsonPre].copy').click((e) => { - navigator.clipboard.writeText(e?.currentTarget?.textContent || e.textContent); + navigator.clipboard.writeText(e?.currentTarget?.textContent || e.textContent); - Swal.fire({ - position: 'top-end', - icon: 'success', - title: 'Copied!', - showConfirmButton: false, - timer: 1500 - }) -}) + Swal.fire({ + position: 'top-end', + icon: 'success', + title: 'Copied!', + showConfirmButton: false, + timer: 1500 + }); +}); $('button[id=buttonCopy]').click((e) => { - const element = $('pre[id=jsonPre].copy')[0]; - navigator.clipboard.writeText(element?.currentTarget?.textContent || element.textContent); + const element = $('pre[id=jsonPre].copy')[0]; + navigator.clipboard.writeText(element?.currentTarget?.textContent || element.textContent); - Swal.fire({ - position: 'top-end', - icon: 'success', - title: 'Copied!', - showConfirmButton: false, - timer: 1500 - }) -}) + Swal.fire({ + position: 'top-end', + icon: 'success', + title: 'Copied!', + showConfirmButton: false, + timer: 1500 + }); +}); $(window).on('load', () => { - $('input').toArray().forEach((i) => i.value = ''); - document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; -}) \ No newline at end of file + $('input').toArray().forEach((i) => i.value = ''); + document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value; +}); \ No newline at end of file