diff --git a/README.md b/README.md index 9516bb29..dd3b1ac2 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,12 @@ configure linting support for your editor as well. If you're using Visual Studio Code, make sure to install the ESLint extension and add the following to your workspace settings: -``` +```json { "eslint.validate": [ "javascript", "javascriptreact", "vue" ] -}``` \ No newline at end of file +} +``` \ No newline at end of file diff --git a/src/modules/chat/badges.jsx b/src/modules/chat/badges.jsx index 14a74392..673acba0 100644 --- a/src/modules/chat/badges.jsx +++ b/src/modules/chat/badges.jsx @@ -54,9 +54,8 @@ const NO_REPEAT = 'background-repeat:no-repeat;background-position:center;', export function generateOverrideCSS(data, style) { - const urls = data.urls || {1: data.image}; - - let image = `url("${urls[1]}")`, + const urls = data.urls || {1: data.image}, + image = `url("${urls[1]}")`, image_set = `${WEBKIT}image-set(${image} 1x${urls[2] ? `, url("${urls[2]}") 2x` : ''}${urls[4] ? `, url("${urls[4]}") 4x` : ''})`; if ( style === 3 || style === 4 ) @@ -172,6 +171,7 @@ export default class Badges extends Module { if ( version && version.image1x ) vs.push({ + version: key, name: version.title, image: version.image1x, styleImage: `url("${version.image1x}")` @@ -431,7 +431,8 @@ export default class Badges extends Module { } if ( has_image && urls ) { - let image_set, image = `url("${urls[1]}")`; + const image = `url("${urls[1]}")`; + let image_set; if ( urls[2] || urls[4] ) image_set = `${WEBKIT}image-set(${image} 1x${urls[2] ? `, url("${urls[2]}") 2x` : ''}${urls[4] ? `, url("${urls[4]}") 4x` : ''})`; diff --git a/src/modules/chat/index.js b/src/modules/chat/index.js index c0eb3ce7..9fa6f989 100644 --- a/src/modules/chat/index.js +++ b/src/modules/chat/index.js @@ -352,7 +352,7 @@ export default class Chat extends Module { } - * iterateRooms() { + *iterateRooms() { const visited = new Set; for(const id in this.room_ids) @@ -373,16 +373,15 @@ export default class Chat extends Module { } - formatTime(time) { + formatTime(time) { // eslint-disable-line class-methods-use-this if (!( time instanceof Date )) time = new Date(time); let hours = time.getHours(); - const minutes = time.getMinutes(), - seconds = time.getSeconds(), - - fmt = this.settings.get('chat.timestamp-format'); + const minutes = time.getMinutes(); //, + // seconds = time.getSeconds(), + // fmt = this.settings.get('chat.timestamp-format'); if ( hours > 12 ) hours -= 12; diff --git a/src/modules/chat/tokenizers.jsx b/src/modules/chat/tokenizers.jsx index 893dfb3e..ce77e5ba 100644 --- a/src/modules/chat/tokenizers.jsx +++ b/src/modules/chat/tokenizers.jsx @@ -8,8 +8,8 @@ import {sanitize, createElement} from 'utilities/dom'; import {has, split_chars} from 'utilities/object'; const EMOTE_CLASS = 'chat-line__message--emote', - LINK_REGEX = /([^\w@#%\-+=:~])?((?:(https?:\/\/)?(?:[\w@#%\-+=:~]+\.)+[a-z]{2,6}(?:\/[\w.\/@#%&()\-+=:?~]*)?))([^\w.\/@#%&()\-+=:?~]|\s|$)/g, - MENTION_REGEX = /([^\w@#%\-+=:~])?(@([^\u0000-\u007F]+|\w+)+)([^\w.\/@#%&()\-+=:?~]|\s|$)/g, + LINK_REGEX = /([^\w@#%\-+=:~])?((?:(https?:\/\/)?(?:[\w@#%\-+=:~]+\.)+[a-z]{2,6}(?:\/[\w./@#%&()\-+=:?~]*)?))([^\w./@#%&()\-+=:?~]|\s|$)/g, + MENTION_REGEX = /([^\w@#%\-+=:~])?(@([^\u0000-\u007F]+|\w+)+)([^\w./@#%&()\-+=:?~]|\s|$)/g, TWITCH_BASE = '//static-cdn.jtvnw.net/emoticons/v1/', REPLACEMENT_BASE = '//cdn.frankerfacez.com/script/replacements/', @@ -109,7 +109,7 @@ export const Links = { ); }, - process(tokens, msg) { + process(tokens) { if ( ! tokens || ! tokens.length ) return tokens; @@ -149,7 +149,7 @@ export const Links = { } } -Links.tooltip.interactive = function(target, tip) { +Links.tooltip.interactive = function(target) { if ( ! this.context.get('tooltip.rich-links') || ! this.context.get('tooltip.link-interaction') || target.dataset.isMail === 'true' ) return false; @@ -157,7 +157,7 @@ Links.tooltip.interactive = function(target, tip) { return info && info.interactive; }; -Links.tooltip.delayHide = function(target, tip) { +Links.tooltip.delayHide = function(target) { if ( ! this.context.get('tooltip.rich-links') || ! this.context.get('tooltip.link-interaction') || target.dataset.isMail === 'true' ) return 0; @@ -472,7 +472,7 @@ export const AddonEmotes = { data-set={token.set} > {emote} - {mods.map(t => {this.tokenizers.emote.render(t, createElement)})} + {mods.map(t => {this.tokenizers.emote.render(t, createElement)})} ); }, diff --git a/src/modules/main_menu/components/badge-visibility.vue b/src/modules/main_menu/components/badge-visibility.vue index 46f31e7d..9c900a55 100644 --- a/src/modules/main_menu/components/badge-visibility.vue +++ b/src/modules/main_menu/components/badge-visibility.vue @@ -57,7 +57,7 @@ >
-
+
{ - return target.dataset.title; - } + this.types.html = target => target.dataset.title; } onEnable() { diff --git a/src/modules/translation_ui/nondex.js b/src/modules/translation_ui/nondex.js index 4c237e57..cbd37336 100644 --- a/src/modules/translation_ui/nondex.js +++ b/src/modules/translation_ui/nondex.js @@ -5,7 +5,7 @@ // ============================================================================ import Module from 'utilities/module'; -import {createElement} from 'utilities/dom'; +//import {createElement} from 'utilities/dom'; export default class TranslationUI extends Module { constructor(...args) { @@ -27,7 +27,7 @@ export default class TranslationUI extends Module { ); } - async onEnable(event) { + async onEnable() { await this.site.awaitElement('.twilight-root'); this.ps = this.site.web_munch.getModule('ps'); } diff --git a/src/settings/context.js b/src/settings/context.js index 28b183d8..d54ee8db 100644 --- a/src/settings/context.js +++ b/src/settings/context.js @@ -273,7 +273,7 @@ export default class SettingsContext extends EventEmitter { return type.get(key, this.profiles(), this.manager.log); } -/* for(const profile of this.__profiles) + /* for(const profile of this.__profiles) if ( profile.has(key) ) return [profile.get(key), profile] }*/ diff --git a/src/settings/index.js b/src/settings/index.js index 703f4ce5..5e152ec2 100644 --- a/src/settings/index.js +++ b/src/settings/index.js @@ -76,7 +76,7 @@ export default class SettingsManager extends Module { this.loadProfiles(true); // Handle migrations. - await this.migrations.process('core'); + //await this.migrations.process('core'); // Now we can tell our context(s) about the profiles we have. for(const context of this.__contexts) diff --git a/src/settings/migration.js b/src/settings/migration.js index 54916422..de997ccf 100644 --- a/src/settings/migration.js +++ b/src/settings/migration.js @@ -10,7 +10,7 @@ export default class MigrationManager { this.provider = manager.provider; } - process(key) { - return false; + process() { // eslint-disable-line class-methods-use-this + throw new Error('Not Implemented'); } } \ No newline at end of file diff --git a/src/sites/twitch-twilight/modules/compat_emote_menu.js b/src/sites/twitch-twilight/modules/compat_emote_menu.js index 9f0520d4..082cdbaf 100644 --- a/src/sites/twitch-twilight/modules/compat_emote_menu.js +++ b/src/sites/twitch-twilight/modules/compat_emote_menu.js @@ -1,5 +1,7 @@ 'use strict'; +/* global emoteMenu: false */ + // ============================================================================ // Compatibility Layer // Emote Menu for Twitch (BTTV Emote Menu) diff --git a/src/sites/twitch-twilight/modules/directory/index.jsx b/src/sites/twitch-twilight/modules/directory/index.jsx index 5d4bd1cd..c3f697a4 100644 --- a/src/sites/twitch-twilight/modules/directory/index.jsx +++ b/src/sites/twitch-twilight/modules/directory/index.jsx @@ -289,7 +289,7 @@ export default class Directory extends SiteModule { return; // Get the old element. - let channel_avatar = card.querySelector('.ffz-channel-avatar'); + const channel_avatar = card.querySelector('.ffz-channel-avatar'); if ( ! data || ! data.profileImageURL || setting === 0 ) { if ( channel_avatar !== null ) diff --git a/src/sites/twitch-twilight/modules/host_button.js b/src/sites/twitch-twilight/modules/host_button.js index 3ccb50d7..22ed601f 100644 --- a/src/sites/twitch-twilight/modules/host_button.js +++ b/src/sites/twitch-twilight/modules/host_button.js @@ -56,9 +56,7 @@ export default class HostButton extends Module { order: 150, button: true, - disabled: () => { - return this._host_updating || this._host_error; - }, + disabled: () => this._host_updating || this._host_error, click: data => { if (data.channel) this.sendHostUnhostCommand(data.channel.login); @@ -108,9 +106,9 @@ export default class HostButton extends Module { } else { return this.i18n.t('metadata.host.button.tooltip', 'Currently hosting: %{channel}', - { - channel: this._last_hosted_channel || this.i18n.t('metadata.host.button.tooltip.none', 'None') - }); + { + channel: this._last_hosted_channel || this.i18n.t('metadata.host.button.tooltip.none', 'None') + }); } } }; diff --git a/src/socket.js b/src/socket.js index cce44be6..16155c63 100644 --- a/src/socket.js +++ b/src/socket.js @@ -107,12 +107,13 @@ export default class SocketClient extends Module { selectHost() { const cluster_id = this.settings.get('socket.cluster'), - cluster = WS_CLUSTERS[cluster_id]; + cluster = WS_CLUSTERS[cluster_id], + l = cluster && cluster.length; - if ( ! cluster || ! cluster.length ) + if ( ! l ) return null; - let total = 0, i = cluster.length, l = i; + let total = 0, i = l; while(i-- > 0) total += cluster[i][1]; diff --git a/src/utilities/compat/apollo.js b/src/utilities/compat/apollo.js index 01bb3a3d..30f246fa 100644 --- a/src/utilities/compat/apollo.js +++ b/src/utilities/compat/apollo.js @@ -19,7 +19,7 @@ export default class Apollo extends Module { this.inject('..fine'); } - async onEnable() { + onEnable() { // TODO: Come up with a better way to await something existing. let client = this.client; @@ -48,7 +48,7 @@ export default class Apollo extends Module { const old_qm_init = this.client.queryManager.queryStore.initQuery; this.hooked_query_init = true; this.client.queryManager.queryStore.initQuery = function(e) { - let t = this.store[e.queryId]; + const t = this.store[e.queryId]; if ( t && t.queryString !== e.queryString ) t.queryString = e.queryString; @@ -59,7 +59,8 @@ export default class Apollo extends Module { const ApolloLink = this.ApolloLink = this.client.link.constructor; this.link = new ApolloLink((operation, forward) => { - //this.log.info('Link Start', operation.operationName, operation); + if ( ! this.enabled ) + return forward(operation); try { // ONLY do this if we've hooked query init, thus letting us ignore certain issues @@ -120,23 +121,8 @@ export default class Apollo extends Module { onDisable() { - // TODO: Remove Apollo middleware. - - // Tear down the parsed queries. - for(const key in this.modifiers) - if ( has(this.modifiers, key) ) { - const modifiers = this.modifiers[key]; - if ( modifiers ) - for(const mod of modifiers) { - if ( typeof mod === 'function' ) - continue; - - mod[1] = null; - } - } - - // And finally, remove our references. - this.client = this.graphql = null; + // Remove our references to things. + this.client = this.printer = this.gql_print = this.old_link = this.old_qm_dedup = this.old_qm_link = null; } diff --git a/src/utilities/dom.js b/src/utilities/dom.js index ca30cdf1..da7e72ad 100644 --- a/src/utilities/dom.js +++ b/src/utilities/dom.js @@ -135,7 +135,7 @@ export class ManagedStyle { } set(key, value) { - let block = this._blocks[key]; + const block = this._blocks[key]; if ( block ) block.textContent = value; else diff --git a/src/utilities/module.js b/src/utilities/module.js index 856fc475..47817881 100644 --- a/src/utilities/module.js +++ b/src/utilities/module.js @@ -521,9 +521,9 @@ export class Module extends EventEmitter { for(const raw_path of ctx.keys()) { const raw_module = ctx(raw_path), module = raw_module.module || raw_module.default, - name = raw_path.slice(2, raw_path.length - (raw_path.endsWith('/index.jsx') ? 10 : raw_path.endsWith('/index.js') ? 9 : raw_path.endsWith('.jsx') ? 4 : 3)); - - // TODO: rewrite the name code to not have like 4 endsWith in it. + lix = raw_path.lastIndexOf('.'), + trimmed = lix > 2 ? raw_path.slice(2, lix) : raw_path, + name = trimmed.endsWith('/index') ? trimmed.slice(0, -6) : trimmed; try { added[name] = this.register(name, module); diff --git a/src/utilities/tooltip.js b/src/utilities/tooltip.js index 892b46c8..0b1cd382 100644 --- a/src/utilities/tooltip.js +++ b/src/utilities/tooltip.js @@ -229,7 +229,7 @@ export class Tooltip { el.classList.toggle('interactive', interactive || false); if ( ! opts.manual ) { - el.addEventListener('mouseover', () => { + el.addEventListener('mouseover', el._ffz_over_handler = () => { if ( ! document.contains(target) ) this.hide(tip); @@ -239,7 +239,7 @@ export class Tooltip { this._exit(target); }); - el.addEventListener('mouseout', () => this._exit(target)); + el.addEventListener('mouseout', el._ffz_out_handler = () => this._exit(target)); } // Assign our content. If there's a Promise, we'll need @@ -311,13 +311,19 @@ export class Tooltip { } if ( tip.outer ) { - tip.outer.remove(); - tip.outer = null; + const el = tip.outer; + if ( el._ffz_over_handler ) + el.removeEventListener('mouseover', el._ffz_over_handler); + + if ( el._ffz_out_handler ) + el.removeEventListener('mouseout', el._ffz_out_handler); + + el.remove(); + tip.outer = el._ffz_out_handler = el._ffz_over_handler = null; } - tip.update = null; tip._update = noop; - tip.element = null; + tip.update = tip.element = null; tip.visible = false; } }