From 8e0cc426598777bf20d822d50f11f4a6b54c62af Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Wed, 6 Sep 2023 10:59:01 -0700 Subject: [PATCH] Reformat files for Prettier 3 The new defaults add trailing commas whenever possible. --- assets/chat/css/style.scss | 5 +- assets/chat/js/autocomplete.js | 8 +- assets/chat/js/chat.js | 240 +++++++++--------- assets/chat/js/commands.js | 4 +- assets/chat/js/commands.test.js | 8 +- assets/chat/js/const.js | 8 +- assets/chat/js/emotes.js | 2 +- .../formatters/BadWordsCensorshipFormatter.js | 2 +- .../chat/js/formatters/EmbedUrlFormatter.js | 2 +- .../js/formatters/MentionedUserFormatter.js | 4 +- .../chat/js/formatters/UrlFormatter.test.js | 8 +- assets/chat/js/hashlinkconverter.js | 2 +- assets/chat/js/menus/ChatEmoteMenu.js | 10 +- assets/chat/js/menus/ChatEmoteTooltip.js | 2 +- assets/chat/js/menus/ChatSettingsMenu.js | 12 +- assets/chat/js/menus/ChatUserInfoMenu.js | 18 +- assets/chat/js/menus/ChatUserMenu.js | 31 ++- assets/chat/js/menus/ChatWhisperUsers.js | 8 +- .../chat/js/messages/ChatDonationMessage.js | 2 +- assets/chat/js/messages/ChatEmoteMessage.js | 8 +- assets/chat/js/messages/ChatMessage.js | 4 +- assets/chat/js/messages/ChatUIMessage.js | 2 +- assets/chat/js/messages/ChatUserMessage.js | 8 +- assets/chat/js/messages/MessageBuilder.js | 8 +- assets/chat/js/poll.js | 16 +- assets/chat/js/scroll.js | 4 +- assets/chat/js/store.js | 2 +- assets/chat/js/user.js | 2 +- assets/chat/js/window.js | 4 +- assets/demo.js | 2 +- scripts/glue.js | 2 +- typings/globals/jquery/index.d.ts | 194 +++++++------- typings/globals/moment/index.d.ts | 12 +- 33 files changed, 325 insertions(+), 319 deletions(-) diff --git a/assets/chat/css/style.scss b/assets/chat/css/style.scss index c3ede0b3..00834d9c 100644 --- a/assets/chat/css/style.scss +++ b/assets/chat/css/style.scss @@ -920,7 +920,10 @@ hr { .combo, .count, .x { - text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, + text-shadow: + -1px -1px 0 #000, + 1px -1px 0 #000, + -1px 1px 0 #000, 1px 1px 0 #000; } .combo { diff --git a/assets/chat/js/autocomplete.js b/assets/chat/js/autocomplete.js index 329a006e..3ff9cd3f 100644 --- a/assets/chat/js/autocomplete.js +++ b/assets/chat/js/autocomplete.js @@ -85,7 +85,7 @@ class ChatAutoComplete { /** @member jQuery */ this.ui = $(`
`); this.ui.on('click', 'li', (e) => - this.select(parseInt(e.currentTarget.getAttribute('data-index'), 10)) + this.select(parseInt(e.currentTarget.getAttribute('data-index'), 10)), ); this.container = $(this.ui[0].firstElementChild); this.buckets = new Map(); @@ -111,7 +111,7 @@ class ChatAutoComplete { if (keycode === KEYCODES.TAB) { if (this.results.length > 0) this.select( - this.selected >= this.results.length - 1 ? 0 : this.selected + 1 + this.selected >= this.results.length - 1 ? 0 : this.selected + 1, ); e.preventDefault(); e.stopPropagation(); @@ -192,7 +192,7 @@ class ChatAutoComplete { .filter( (a) => (!a.isemote || !(criteria.useronly || useronly)) && - regex.test(a.data) + regex.test(a.data), ) .sort(sortResults) .slice(0, maxResults); @@ -239,7 +239,7 @@ class ChatAutoComplete { const pre = this.criteria.orig.substr(0, this.criteria.startCaret); let post = this.criteria.orig.substr( - this.criteria.startCaret + this.criteria.word.length + this.criteria.startCaret + this.criteria.word.length, ); // always add a space after our completion if there isn't one since people diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index a2bcccf0..351abc62 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -157,10 +157,10 @@ class Chat { this.control.on('SUBONLY', (data) => this.cmdSUBONLY(data, 'SUBONLY')); this.control.on('MAXLINES', (data) => this.cmdMAXLINES(data, 'MAXLINES')); this.control.on('UNHIGHLIGHT', (data) => - this.cmdHIGHLIGHT(data, 'UNHIGHLIGHT') + this.cmdHIGHLIGHT(data, 'UNHIGHLIGHT'), ); this.control.on('HIGHLIGHT', (data) => - this.cmdHIGHLIGHT(data, 'HIGHLIGHT') + this.cmdHIGHLIGHT(data, 'HIGHLIGHT'), ); this.control.on('TIMESTAMPFORMAT', (data) => this.cmdTIMESTAMPFORMAT(data)); this.control.on('BROADCAST', (data) => this.cmdBROADCAST(data)); @@ -286,48 +286,48 @@ class Chat { new ChatSettingsMenu( this.ui.find('#chat-settings'), this.ui.find('#chat-settings-btn'), - this - ) + this, + ), ); this.menus.set( 'emotes', new ChatEmoteMenu( this.ui.find('#chat-emote-list'), this.ui.find('#chat-emoticon-btn'), - this - ) + this, + ), ); this.menus.set( 'emote-tooltip', new ChatEmoteTooltip( this.ui.find('#chat-emote-tooltip'), this.output.find('.msg-user .text .emote'), - this - ) + this, + ), ); this.menus.set( 'users', new ChatUserMenu( this.ui.find('#chat-user-list'), this.ui.find('#chat-users-btn'), - this - ) + this, + ), ); this.menus.set( 'whisper-users', new ChatWhisperUsers( this.ui.find('#chat-whisper-users'), this.ui.find('#chat-whisper-btn'), - this - ) + this, + ), ); this.menus.set( 'user-info', new ChatUserInfoMenu( this.ui.find('#chat-user-info'), this.output.find('.msg-user .user'), - this - ) + this, + ), ); this.commands @@ -384,9 +384,9 @@ class Chat { if (!this.ishidden) this.focusIfNothingSelected(); else ChatMenu.closeMenus(this); }, - { atBegin: false } + { atBegin: false }, ), - true + true, ); // Resize @@ -397,7 +397,7 @@ class Chat { resizing = false; this.focusIfNothingSelected(); }, - { atBegin: false } + { atBegin: false }, ); const onresize = () => { // If this is a mobile screen, don't close menus. @@ -450,7 +450,7 @@ class Chat { try { if (window.self === window.top) { window.location.href = `${uri}/login?follow=${encodeURIComponent( - window.location.pathname + window.location.pathname, )}`; } else { window.location.href = `${uri}/login`; @@ -505,10 +505,10 @@ class Chat { async loadEmotes() { Chat.loadCss( - `${this.config.cdn.base}/emotes/emotes.css?_=${this.config.cacheKey}` + `${this.config.cdn.base}/emotes/emotes.css?_=${this.config.cacheKey}`, ); return fetch( - `${this.config.cdn.base}/emotes/emotes.json?_=${this.config.cacheKey}` + `${this.config.cdn.base}/emotes/emotes.json?_=${this.config.cacheKey}`, ) .then((res) => res.json()) .then((json) => { @@ -519,10 +519,10 @@ class Chat { async loadFlairs() { Chat.loadCss( - `${this.config.cdn.base}/flairs/flairs.css?_=${this.config.cacheKey}` + `${this.config.cdn.base}/flairs/flairs.css?_=${this.config.cacheKey}`, ); return fetch( - `${this.config.cdn.base}/flairs/flairs.json?_=${this.config.cacheKey}` + `${this.config.cdn.base}/flairs/flairs.json?_=${this.config.cacheKey}`, ) .then((res) => res.json()) .then((json) => { @@ -552,7 +552,7 @@ class Chat { nick: e.username, unread: Number(e.unread), open: false, - }) + }), ); }) .then(() => this.menus.get('whisper-users').redraw()) @@ -629,10 +629,10 @@ class Chat { // Highlight Regex const cust = [...(this.settings.get('customhighlight') || [])].filter( - (a) => a !== '' + (a) => a !== '', ); const nicks = [...(this.settings.get('highlightnicks') || [])].filter( - (a) => a !== '' + (a) => a !== '', ); this.regexhighlightself = this.user.nick ? new RegExp(`\\b(?:${this.user.nick})\\b`, 'i') @@ -646,7 +646,7 @@ class Chat { Array.from(this.settings.keys()) .filter((key) => typeof this.settings.get(key) === 'boolean') .forEach((key) => - this.ui.toggleClass(`pref-${key}`, this.settings.get(key)) + this.ui.toggleClass(`pref-${key}`, this.settings.get(key)), ); // Update maxlines @@ -723,7 +723,7 @@ class Chat { this.user.username.toLowerCase(); // get mentions from message message.mentioned = Chat.extractNicks(message.message).filter((a) => - this.users.has(a.toLowerCase()) + this.users.has(a.toLowerCase()), ); // set tagged state message.tag = this.taggednicks.get(message.user.nick.toLowerCase()); @@ -770,7 +770,7 @@ class Chat { `${message.user.username} said ...`, message.message, message.timestamp.valueOf(), - this.settings.get('notificationtimeout') + this.settings.get('notificationtimeout'), ); } @@ -846,7 +846,7 @@ class Chat { this.windowselect.append( `` + } ${w.visible ? 'active' : ''}">`, ); } else { const conv = this.whispers.get(w.name); @@ -856,8 +856,8 @@ class Chat { w.visible ? 'active' : '' } ${conv.unread > 0 ? 'unread' : ''}"> ${w.label}${ - conv.unread > 0 ? ` (${conv.unread})` : '' - } + conv.unread > 0 ? ` (${conv.unread})` : '' + } `); } @@ -949,7 +949,7 @@ class Chat { // Show scrollbars if the input's height exceeds the max. this.input.css( 'overflow-y', - calculatedHeight >= maxHeight ? 'scroll' : 'hidden' + calculatedHeight >= maxHeight ? 'scroll' : 'hidden', ); this.input.css('height', calculatedHeight); @@ -983,14 +983,14 @@ class Chat { if (this.chatpoll.isPollStarted()) this.chatpoll.endPoll(); // end poll on disconnect so it is not there forever. if (retryMilli > 0) MessageBuilder.error( - `Disconnected, retry in ${Math.round(retryMilli / 1000)} seconds ...` + `Disconnected, retry in ${Math.round(retryMilli / 1000)} seconds ...`, ).into(this); else MessageBuilder.error(`Disconnected.`).into(this); } onCONNECTING(url) { MessageBuilder.status( - `Connecting to ${Chat.extractHostname(url)} ...` + `Connecting to ${Chat.extractHostname(url)} ...`, ).into(this); } @@ -1016,7 +1016,7 @@ class Chat { this.authenticated ? this.user.username : 'Guest' }. Serving ${data.connectioncount || 0} connections and ${ data.users.length - } users.` + } users.`, ).into(this); if (this.showmotd) { this.cmdHINT([Math.floor(Math.random() * hintstrings.size)]); @@ -1034,7 +1034,7 @@ class Chat { msg.data, usr, msg.timestamp, - msg.uuid + msg.uuid, ) .into(this) .pin(this, !checkIfPinWasDismissed(msg.uuid)); @@ -1090,7 +1090,7 @@ class Chat { if (this.user.username.toLowerCase() === data.data.toLowerCase()) { MessageBuilder.command( `You have been muted by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); // Every cached mute message calls `onMUTE()`. We perform this check @@ -1102,7 +1102,7 @@ class Chat { } else { MessageBuilder.command( `${data.data} muted by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); } this.censor(data.data); @@ -1112,14 +1112,14 @@ class Chat { if (this.user.username.toLowerCase() === data.data.toLowerCase()) { MessageBuilder.command( `You have been unmuted by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); this.mutedtimer.stopTimer(); } else { MessageBuilder.command( `${data.data} unmuted by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); } } @@ -1129,13 +1129,13 @@ class Chat { if (this.user.username.toLowerCase() === data.data.toLowerCase()) { MessageBuilder.command( `You have been banned by ${data.nick}. Check your profile for more information.`, - data.timestamp + data.timestamp, ).into(this); this.cmdBANINFO(); } else { MessageBuilder.command( `${data.data} banned by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); } this.censor(data.data); @@ -1145,7 +1145,7 @@ class Chat { if (this.user.username.toLowerCase() === data.data.toLowerCase()) { MessageBuilder.command( `You have been unbanned by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); // Unbanning a user unmutes them, too. @@ -1153,7 +1153,7 @@ class Chat { } else { MessageBuilder.command( `${data.data} unbanned by ${data.nick}.`, - data.timestamp + data.timestamp, ).into(this); } } @@ -1186,7 +1186,7 @@ class Chat { this.mutedtimer.startTimer(); message = MessageBuilder.error( - `You are temporarily muted! You can chat again ${this.mutedtimer.getReadableDuration()}. Subscribe to remove the mute immediately.` + `You are temporarily muted! You can chat again ${this.mutedtimer.getReadableDuration()}. Subscribe to remove the mute immediately.`, ); break; default: @@ -1209,7 +1209,7 @@ class Chat { `Subscriber only mode ${this.subonly ? 'enabled' : 'disabled'}${ data.nick ? ` by ${data.nick}` : '' }.`, - data.timestamp + data.timestamp, ).into(this); if (this.subonly && !this.user.isSubscriber()) { this.subonlyicon.show(); @@ -1225,7 +1225,7 @@ class Chat { const retryMilli = Math.floor(Math.random() * 30000) + 4000; setTimeout(() => window.location.reload(true), retryMilli); MessageBuilder.broadcast( - `Restart incoming in ${Math.round(retryMilli / 1000)} seconds ...` + `Restart incoming in ${Math.round(retryMilli / 1000)} seconds ...`, ).into(this); } } else { @@ -1277,21 +1277,21 @@ class Chat { user, this.user.username, data.timestamp, - messageid + messageid, ).into(this); if (this.settings.get('notificationwhisper') && this.ishidden) Chat.showNotification( `${data.nick} whispered ...`, data.data, data.timestamp, - this.settings.get('notificationtimeout') + this.settings.get('notificationtimeout'), ); const win = this.getWindow(normalized); if (win) MessageBuilder.historical(data.data, user, data.timestamp).into( this, - win + win, ); if (win === this.getActiveWindow()) { fetch(`${this.config.api.base}/api/messages/msg/${messageid}/open`, { @@ -1332,11 +1332,11 @@ class Chat { if (win !== this.mainwindow && normalized !== 'EXIT') { MessageBuilder.error( - `No commands in private windows. Try /exit` + `No commands in private windows. Try /exit`, ).into(this, win); } else if (this.control.listeners.has(normalized)) { const parts = (raw.substring(command.length + 1) || '').match( - /([^ ]+)/g + /([^ ]+)/g, ); this.control.emit(normalized, parts || []); } else { @@ -1416,7 +1416,7 @@ class Chat { parseQuestionAndTime(textOnly); } catch { MessageBuilder.info( - `Usage: ${slashCommand} ?