Update eslint rules

This commit is contained in:
Jiiks 2018-08-15 09:01:47 +03:00
parent c1ac349211
commit 9f8a1f08be
46 changed files with 235 additions and 221 deletions

41
.eslintrc.json Normal file
View File

@ -0,0 +1,41 @@
{
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"env": {
"browser": true,
"node": true
},
"plugins": [
"vue"
],
"extends": [
"eslint:recommended",
"plugin:vue/recommended"
],
"rules": {
"no-unused-vars": "off",
"no-console": "off",
"no-empty": "off",
"quotes": [
"error",
"single",
{ "allowTemplateLiterals": true }
],
"prefer-template": "warn",
"no-return-await": "error",
"indent": [ "error", 4 ],
"no-lonely-if": "error",
"no-multiple-empty-lines": [
"warn",
{ "max": 1 }
],
"no-tabs": "error",
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-useless-constructor": "warn",
"no-var": "error",
"prefer-const": "error"
}
}

View File

@ -1,21 +0,0 @@
---
parserOptions:
ecmaVersion: 8
sourceType: module
env:
browser: true
node: true
plugins:
- vue
extends:
- eslint:recommended
- plugin:vue/recommended
rules:
no-unused-vars: 'off'
no-console: 'off'
no-empty: 'off'

View File

@ -19,8 +19,8 @@ import E2EEComponent from './E2EEComponent.vue';
import E2EEMessageButton from './E2EEMessageButton.vue'; import E2EEMessageButton from './E2EEMessageButton.vue';
import nodecrypto from 'node-crypto'; import nodecrypto from 'node-crypto';
const userMentionPattern = new RegExp(`<@!?([0-9]{10,})>`, "g"); const userMentionPattern = new RegExp(`<@!?([0-9]{10,})>`, 'g');
const roleMentionPattern = new RegExp(`<@&([0-9]{10,})>`, "g"); const roleMentionPattern = new RegExp(`<@&([0-9]{10,})>`, 'g');
const everyoneMentionPattern = new RegExp(`(?:\\s+|^)@everyone(?:\\s+|$)`); const everyoneMentionPattern = new RegExp(`(?:\\s+|^)@everyone(?:\\s+|$)`);
const START_DATE = new Date(); const START_DATE = new Date();
@ -43,7 +43,7 @@ export default new class E2EE extends BuiltinModule {
this.setMaster(newMaster); this.setMaster(newMaster);
this.patchDispatcher(); this.patchDispatcher();
this.patchMessageContent(); this.patchMessageContent();
const selector = '.' + WebpackModules.getClassName('channelTextArea', 'emojiButton'); const selector = `.${WebpackModules.getClassName('channelTextArea', 'emojiButton')}`;
const cta = await ReactComponents.getComponent('ChannelTextArea', { selector }); const cta = await ReactComponents.getComponent('ChannelTextArea', { selector });
this.patchChannelTextArea(cta); this.patchChannelTextArea(cta);
this.patchChannelTextAreaSubmit(cta); this.patchChannelTextAreaSubmit(cta);
@ -72,7 +72,6 @@ export default new class E2EE extends BuiltinModule {
return ['security', 'default', 'e2ee']; return ['security', 'default', 'e2ee'];
} }
get database() { get database() {
return Settings.getSetting('security', 'e2eedb', 'e2ekvps').value; return Settings.getSetting('security', 'e2eedb', 'e2ekvps').value;
} }
@ -112,8 +111,8 @@ export default new class E2EE extends BuiltinModule {
const items = Settings.getSetting('security', 'e2eedb', 'e2ekvps').items; const items = Settings.getSetting('security', 'e2eedb', 'e2ekvps').items;
const index = items.findIndex(kvp => kvp.value.key === channelId); const index = items.findIndex(kvp => kvp.value.key === channelId);
if (index > -1) { if (index > -1) {
items[index].value = {key: channelId, value: key}; items[index].value = {key: channelId, value: key};
return; return;
} }
Settings.getSetting('security', 'e2eedb', 'e2ekvps').addItem({ value: { key: channelId, value: key } }); Settings.getSetting('security', 'e2eedb', 'e2ekvps').addItem({ value: { key: channelId, value: key } });
} }
@ -178,7 +177,7 @@ export default new class E2EE extends BuiltinModule {
patchDispatcher() { patchDispatcher() {
const Dispatcher = WebpackModules.getModuleByName('Dispatcher'); const Dispatcher = WebpackModules.getModuleByName('Dispatcher');
MonkeyPatch('BD:E2EE', Dispatcher).before('dispatch', (_, [event]) => { MonkeyPatch('BD:E2EE', Dispatcher).before('dispatch', (_, [event]) => {
if (event.type !== "MESSAGE_CREATE") return; if (event.type !== 'MESSAGE_CREATE') return;
const key = this.getKey(event.message.channel_id); const key = this.getKey(event.message.channel_id);
if (!key) return; // We don't have a key for this channel if (!key) return; // We don't have a key for this channel
@ -208,11 +207,11 @@ export default new class E2EE extends BuiltinModule {
} }
async patchMessageContent() { async patchMessageContent() {
const selector = '.' + WebpackModules.getClassName('container', 'containerCozy', 'containerCompact', 'edited'); const selector = `.${WebpackModules.getClassName('container', 'containerCozy', 'containerCompact', 'edited')}`;
const MessageContent = await ReactComponents.getComponent('MessageContent', { selector }); const MessageContent = await ReactComponents.getComponent('MessageContent', { selector });
MonkeyPatch('BD:E2EE', MessageContent.component.prototype).before('render', this.beforeRenderMessageContent.bind(this)); MonkeyPatch('BD:E2EE', MessageContent.component.prototype).before('render', this.beforeRenderMessageContent.bind(this));
MonkeyPatch('BD:E2EE', MessageContent.component.prototype).after('render', this.renderMessageContent.bind(this)); MonkeyPatch('BD:E2EE', MessageContent.component.prototype).after('render', this.renderMessageContent.bind(this));
const ImageWrapper = await ReactComponents.getComponent('ImageWrapper', { selector: '.' + WebpackModules.getClassName('imageWrapper') }); const ImageWrapper = await ReactComponents.getComponent('ImageWrapper', { selector: `.${WebpackModules.getClassName('imageWrapper')}` });
MonkeyPatch('BD:E2EE', ImageWrapper.component.prototype).before('render', this.beforeRenderImageWrapper.bind(this)); MonkeyPatch('BD:E2EE', ImageWrapper.component.prototype).before('render', this.beforeRenderImageWrapper.bind(this));
} }
@ -293,13 +292,13 @@ export default new class E2EE extends BuiltinModule {
try { try {
const decrypt = Security.decrypt(seed, [this.master, haveKey, cached.image]); const decrypt = Security.decrypt(seed, [this.master, haveKey, cached.image]);
component.props.className = 'bd-decryptedImage'; component.props.className = 'bd-decryptedImage';
component.props.src = component.props.original = 'data:;base64,' + decrypt; component.props.src = component.props.original = `data:;base64,${decrypt}`;
} catch (err) { return } finally { component.props.readyState = 'READY' } } catch (err) { return } finally { component.props.readyState = 'READY' }
return; return;
} }
component.props.readyState = 'LOADING'; component.props.readyState = 'LOADING';
Logger.info('E2EE', 'Decrypting image: ' + src); Logger.info('E2EE', `Decrypting image: ${src}`);
request.get(src, { encoding: 'binary' }).then(res => { request.get(src, { encoding: 'binary' }).then(res => {
(async () => { (async () => {
const arr = new Uint8Array(new ArrayBuffer(res.length)); const arr = new Uint8Array(new ArrayBuffer(res.length));

View File

@ -58,7 +58,7 @@ export default new class EmoteModule {
async load(dataPath) { async load(dataPath) {
const emotes = await FileUtils.readJsonFromFile(dataPath); const emotes = await FileUtils.readJsonFromFile(dataPath);
for (let [index, emote] of emotes.entries()) { for (const [index, emote] of emotes.entries()) {
// Pause every 10000 emotes so the window doesn't freeze // Pause every 10000 emotes so the window doesn't freeze
if ((index % 10000) === 0) if ((index % 10000) === 0)
await Utils.wait(); await Utils.wait();
@ -179,7 +179,7 @@ export default new class EmoteModule {
let startIndex = 0; let startIndex = 0;
const matching = this.searchCache[key] = []; const matching = this.searchCache[key] = [];
for (let emote of this.emotes.values()) { for (const emote of this.emotes.values()) {
if (index >= limit) break; if (index >= limit) break;
if (regex.test(emote.id)) { if (regex.test(emote.id)) {
if (startIndex < start) { if (startIndex < start) {
@ -195,7 +195,7 @@ export default new class EmoteModule {
} }
async patchMessageContent() { async patchMessageContent() {
const selector = '.' + WebpackModules.getClassName('container', 'containerCozy', 'containerCompact', 'edited'); const selector = `.${WebpackModules.getClassName('container', 'containerCozy', 'containerCompact', 'edited')}`;
const MessageContent = await ReactComponents.getComponent('MessageContent', {selector}); const MessageContent = await ReactComponents.getComponent('MessageContent', {selector});
this.unpatchRender = MonkeyPatch('BD:EmoteModule', MessageContent.component.prototype).after('render', (component, args, retVal) => { this.unpatchRender = MonkeyPatch('BD:EmoteModule', MessageContent.component.prototype).after('render', (component, args, retVal) => {
@ -213,7 +213,7 @@ export default new class EmoteModule {
} }
async patchChannelTextArea() { async patchChannelTextArea() {
const selector = '.' + WebpackModules.getClassName('channelTextArea', 'emojiButton'); const selector = `.${WebpackModules.getClassName('channelTextArea', 'emojiButton')}`;
const ChannelTextArea = await ReactComponents.getComponent('ChannelTextArea', {selector}); const ChannelTextArea = await ReactComponents.getComponent('ChannelTextArea', {selector});
this.unpatchChannelTextArea = MonkeyPatch('BD:EmoteModule', ChannelTextArea.component.prototype).after('render', (component, args, retVal) => { this.unpatchChannelTextArea = MonkeyPatch('BD:EmoteModule', ChannelTextArea.component.prototype).after('render', (component, args, retVal) => {

View File

@ -42,7 +42,7 @@ export default new class ReactDevtoolsModule extends BuiltinModule {
try { try {
const res = electron.remote.BrowserWindow.addDevToolsExtension(path.join(Globals.getPath('ext'), 'extensions', 'rdt')); const res = electron.remote.BrowserWindow.addDevToolsExtension(path.join(Globals.getPath('ext'), 'extensions', 'rdt'));
if (res !== undefined) { if (res !== undefined) {
Toasts.success(res + ' Installed'); Toasts.success(`${res} Installed`);
return; return;
} }
Toasts.error('React Developer Tools install failed'); Toasts.error('React Developer Tools install failed');

View File

@ -42,7 +42,7 @@ export default new class VueDevtoolsModule extends BuiltinModule {
try { try {
const res = electron.remote.BrowserWindow.addDevToolsExtension(path.join(Globals.getPath('ext'), 'extensions', 'vdt')); const res = electron.remote.BrowserWindow.addDevToolsExtension(path.join(Globals.getPath('ext'), 'extensions', 'vdt'));
if (res !== undefined) { if (res !== undefined) {
Toasts.success(res + ' Installed'); Toasts.success(`${res } Installed`);
return; return;
} }
Toasts.error('Vue.js devtools install failed'); Toasts.error('Vue.js devtools install failed');

View File

@ -76,7 +76,7 @@ export default class {
await FileUtils.ensureDirectory(this.contentPath); await FileUtils.ensureDirectory(this.contentPath);
const directories = await FileUtils.listDirectory(this.contentPath); const directories = await FileUtils.listDirectory(this.contentPath);
for (let dir of directories) { for (const dir of directories) {
try { try {
await FileUtils.directoryExists(path.join(this.contentPath, dir)); await FileUtils.directoryExists(path.join(this.contentPath, dir));
} catch (err) { continue; } } catch (err) { continue; }
@ -119,7 +119,7 @@ export default class {
await FileUtils.ensureDirectory(this.contentPath); await FileUtils.ensureDirectory(this.contentPath);
const directories = await FileUtils.listDirectory(this.contentPath); const directories = await FileUtils.listDirectory(this.contentPath);
for (let dir of directories) { for (const dir of directories) {
// If content is already loaded this should resolve // If content is already loaded this should resolve
if (this.getContentByDirName(dir)) continue; if (this.getContentByDirName(dir)) continue;
@ -142,7 +142,7 @@ export default class {
} }
} }
for (let content of this.localContent) { for (const content of this.localContent) {
if (directories.includes(content.dirName)) continue; if (directories.includes(content.dirName)) continue;
try { try {
@ -219,13 +219,13 @@ export default class {
userConfig.config = defaultConfig.clone({ settings: userConfig.config }); userConfig.config = defaultConfig.clone({ settings: userConfig.config });
userConfig.config.setSaved(); userConfig.config.setSaved();
for (let setting of userConfig.config.findSettings(() => true)) { for (const setting of userConfig.config.findSettings(() => true)) {
// This will load custom settings // This will load custom settings
// Setting the content's path on only the live config (and not the default config) ensures that custom settings will not be loaded on the default settings // Setting the content's path on only the live config (and not the default config) ensures that custom settings will not be loaded on the default settings
setting.setContentPath(contentPath); setting.setContentPath(contentPath);
} }
for (let scheme of userConfig.config.schemes) { for (const scheme of userConfig.config.schemes) {
scheme.setContentPath(contentPath); scheme.setContentPath(contentPath);
} }

View File

@ -119,7 +119,7 @@ export default new class {
* @param {String} scss SCSS string * @param {String} scss SCSS string
*/ */
async compile(scss) { async compile(scss) {
return await ClientIPC.send('bd-compileSass', { return ClientIPC.send('bd-compileSass', {
data: scss, data: scss,
path: await this.fileExists() ? this.filePath : undefined path: await this.fileExists() ? this.filePath : undefined
}); });
@ -130,7 +130,7 @@ export default new class {
* @return {Promise} * @return {Promise}
*/ */
async recompile() { async recompile() {
return await this.updateScss(this.scss); return this.updateScss(this.scss);
} }
/** /**
@ -160,7 +160,7 @@ export default new class {
// For some reason this doesn't work // For some reason this doesn't work
// if (!electron.shell.openItem(this.filePath)) // if (!electron.shell.openItem(this.filePath))
if (!electron.shell.openExternal('file://' + this.filePath)) if (!electron.shell.openExternal(`file://${this.filePath}`))
throw {message: 'Failed to open system editor.'}; throw {message: 'Failed to open system editor.'};
} }
@ -267,7 +267,7 @@ export default new class {
* @param {Array} files Files to watch * @param {Array} files Files to watch
*/ */
set watchfiles(files) { set watchfiles(files) {
for (let file of files) { for (const file of files) {
if (!this.watchfiles.includes(file)) { if (!this.watchfiles.includes(file)) {
this.filewatcher.add(file); this.filewatcher.add(file);
this.watchfiles.push(file); this.watchfiles.push(file);
@ -275,7 +275,7 @@ export default new class {
} }
} }
for (let index in this.watchfiles) { for (const index in this.watchfiles) {
let file = this.watchfiles[index]; let file = this.watchfiles[index];
while (file && !files.find(f => f === file)) { while (file && !files.find(f => f === file)) {
this.filewatcher.remove(file); this.filewatcher.remove(file);

View File

@ -62,8 +62,8 @@ export default class extends EventListener {
*/ */
emit(e, action, data) { emit(e, action, data) {
switch (e) { switch (e) {
case 'dispatch': case 'dispatch':
return this.dispatch(action, data); return this.dispatch(action, data);
} }
} }

View File

@ -14,7 +14,7 @@ import Events from './events';
export default class extends Module { export default class extends Module {
events() { events() {
for (let event of this.eventBindings) { for (const event of this.eventBindings) {
Events.on(event.id, event.callback); Events.on(event.id, event.callback);
} }
} }

View File

@ -38,7 +38,7 @@ export default class EventsWrapper {
get off() { return this.unsubscribe } get off() { return this.unsubscribe }
unsubscribe(event, callback) { unsubscribe(event, callback) {
for (let index in this.eventSubs) { for (const index in this.eventSubs) {
if (this.eventSubs[index].event !== event || (callback && this.eventSubs[index].callback === callback)) continue; if (this.eventSubs[index].event !== event || (callback && this.eventSubs[index].callback === callback)) continue;
eventemitters.get(this).removeListener(event, this.eventSubs[index].boundCallback); eventemitters.get(this).removeListener(event, this.eventSubs[index].boundCallback);
this.eventSubs.splice(index, 1); this.eventSubs.splice(index, 1);
@ -46,7 +46,7 @@ export default class EventsWrapper {
} }
unsubscribeAll() { unsubscribeAll() {
for (let event of this.eventSubs) { for (const event of this.eventSubs) {
eventemitters.get(this).removeListener(event.event, event.boundCallback); eventemitters.get(this).removeListener(event.event, event.boundCallback);
} }
this.eventSubs.splice(0, this.eventSubs.length); this.eventSubs.splice(0, this.eventSubs.length);

View File

@ -37,7 +37,7 @@ export default class {
* @return {Promise} * @return {Promise}
*/ */
static async initModules() { static async initModules() {
for (let module of this.modules) { for (const module of this.modules) {
try { try {
if (module.init && module.init instanceof Function) module.init(); if (module.init && module.init instanceof Function) module.init();
} catch (err) { } catch (err) {

View File

@ -182,7 +182,7 @@ export default class PluginApi {
Utils.removeFromArray(this.menuItems, item); Utils.removeFromArray(this.menuItems, item);
} }
removeAllMenuItems() { removeAllMenuItems() {
for (let item of this.menuItems) for (const item of this.menuItems)
BdMenu.items.remove(item); BdMenu.items.remove(item);
} }
get BdMenuItems() { get BdMenuItems() {
@ -232,7 +232,7 @@ export default class PluginApi {
DOM.deleteStyle(styleid); DOM.deleteStyle(styleid);
} }
deleteAllStyles(id) { deleteAllStyles(id) {
for (let id of this.injectedStyles) { for (const id of this.injectedStyles) {
this.deleteStyle(id); this.deleteStyle(id);
} }
} }
@ -273,7 +273,7 @@ export default class PluginApi {
} }
closeAllModals(force) { closeAllModals(force) {
const promises = []; const promises = [];
for (let modal of this.modalStack) for (const modal of this.modalStack)
promises.push(modal.close(force)); promises.push(modal.close(force));
return Promise.all(promises); return Promise.all(promises);
} }
@ -305,7 +305,6 @@ export default class PluginApi {
}); });
} }
/** /**
* Toasts * Toasts
*/ */
@ -335,7 +334,6 @@ export default class PluginApi {
}; };
} }
/** /**
* Emotes * Emotes
*/ */
@ -388,7 +386,7 @@ export default class PluginApi {
async getPlugin(plugin_id) { async getPlugin(plugin_id) {
// This should require extra permissions // This should require extra permissions
return await PluginManager.waitForPlugin(plugin_id); return PluginManager.waitForPlugin(plugin_id);
} }
listPlugins() { listPlugins() {
return PluginManager.localContent.map(plugin => plugin.id); return PluginManager.localContent.map(plugin => plugin.id);
@ -406,7 +404,7 @@ export default class PluginApi {
async getTheme(theme_id) { async getTheme(theme_id) {
// This should require extra permissions // This should require extra permissions
return await ThemeManager.waitForContent(theme_id); return ThemeManager.waitForContent(theme_id);
} }
listThemes() { listThemes() {
return ThemeManager.localContent.map(theme => theme.id); return ThemeManager.localContent.map(theme => theme.id);
@ -424,7 +422,7 @@ export default class PluginApi {
async getModule(module_id) { async getModule(module_id) {
// This should require extra permissions // This should require extra permissions
return await ExtModuleManager.waitForContent(module_id); return ExtModuleManager.waitForContent(module_id);
} }
listModules() { listModules() {
return ExtModuleManager.localContent.map(module => module.id); return ExtModuleManager.localContent.map(module => module.id);

View File

@ -41,7 +41,7 @@ export default class extends ContentManager {
this.loaded = false; this.loaded = false;
const loadAll = await this.loadAllContent(true); const loadAll = await this.loadAllContent(true);
this.loaded = true; this.loaded = true;
for (let plugin of this.localPlugins) { for (const plugin of this.localPlugins) {
if (!plugin.enabled) continue; if (!plugin.enabled) continue;
plugin.userConfig.enabled = false; plugin.userConfig.enabled = false;
@ -76,7 +76,7 @@ export default class extends ContentManager {
static get loadContent() { return this.loadPlugin } static get loadContent() { return this.loadPlugin }
static async loadPlugin(paths, configs, info, main, dependencies, permissions, mainExport) { static async loadPlugin(paths, configs, info, main, dependencies, permissions, mainExport) {
if (permissions && permissions.length > 0) { if (permissions && permissions.length > 0) {
for (let perm of permissions) { for (const perm of permissions) {
Logger.log(this.moduleName, `Permission: ${Permissions.permissionText(perm).HEADER} - ${Permissions.permissionText(perm).BODY}`); Logger.log(this.moduleName, `Permission: ${Permissions.permissionText(perm).HEADER} - ${Permissions.permissionText(perm).BODY}`);
} }
try { try {

View File

@ -50,7 +50,7 @@ class Helpers {
const item = parent[key]; const item = parent[key];
yield { item, parent, key, index, count }; yield { item, parent, key, index, count };
if (item && item.props && item.props.children) { if (item && item.props && item.props.children) {
for (let { parent, key, index, count } of this.recursiveArrayCount(item.props, 'children')) { for (const { parent, key, index, count } of this.recursiveArrayCount(item.props, 'children')) {
yield* this.recursiveChildren(parent, key, index, count); yield* this.recursiveChildren(parent, key, index, count);
} }
} }
@ -58,7 +58,7 @@ class Helpers {
} }
static returnFirst(iterator, process) { static returnFirst(iterator, process) {
for (let child of iterator) { for (const child of iterator) {
const retVal = process(child); const retVal = process(child);
if (retVal !== undefined) return retVal; if (retVal !== undefined) return retVal;
} }
@ -175,7 +175,7 @@ class ReactComponent {
forceUpdateAll() { forceUpdateAll() {
if (!this.important || !this.important.selector) return; if (!this.important || !this.important.selector) return;
for (let e of document.querySelectorAll(this.important.selector)) { for (const e of document.querySelectorAll(this.important.selector)) {
Reflection(e).forceUpdate(this); Reflection(e).forceUpdate(this);
} }
} }
@ -237,7 +237,7 @@ export class ReactComponents {
if (!elements.length) return; if (!elements.length) return;
let component, reflect; let component, reflect;
for (let element of elements) { for (const element of elements) {
reflect = Reflection(element); reflect = Reflection(element);
component = filter ? reflect.components.find(filter) : reflect.component; component = filter ? reflect.components.find(filter) : reflect.component;
if (component) break; if (component) break;
@ -328,7 +328,7 @@ export class ReactAutoPatcher {
} }
static async patchMessage() { static async patchMessage() {
const selector = '.' + WebpackModules.getClassName('message', 'messageCozy', 'messageCompact'); const selector = `.${WebpackModules.getClassName('message', 'messageCozy', 'messageCompact')}`;
this.Message = await ReactComponents.getComponent('Message', {selector}, m => m.prototype && m.prototype.renderCozy); this.Message = await ReactComponents.getComponent('Message', {selector}, m => m.prototype && m.prototype.renderCozy);
this.unpatchMessageRender = MonkeyPatch('BD:ReactComponents', this.Message.component.prototype).after('render', (component, args, retVal) => { this.unpatchMessageRender = MonkeyPatch('BD:ReactComponents', this.Message.component.prototype).after('render', (component, args, retVal) => {
@ -352,7 +352,7 @@ export class ReactAutoPatcher {
} }
static async patchMessageGroup() { static async patchMessageGroup() {
const selector = '.' + WebpackModules.getClassName('container', 'message', 'messageCozy'); const selector = `.${WebpackModules.getClassName('container', 'message', 'messageCozy')}`;
this.MessageGroup = await ReactComponents.getComponent('MessageGroup', {selector}); this.MessageGroup = await ReactComponents.getComponent('MessageGroup', {selector});
this.unpatchMessageGroupRender = MonkeyPatch('BD:ReactComponents', this.MessageGroup.component.prototype).after('render', (component, args, retVal) => { this.unpatchMessageGroupRender = MonkeyPatch('BD:ReactComponents', this.MessageGroup.component.prototype).after('render', (component, args, retVal) => {
@ -370,7 +370,7 @@ export class ReactAutoPatcher {
} }
static async patchChannelMember() { static async patchChannelMember() {
const selector = '.' + WebpackModules.getClassName('member', 'memberInner', 'activity'); const selector = `.${WebpackModules.getClassName('member', 'memberInner', 'activity')}`;
this.ChannelMember = await ReactComponents.getComponent('ChannelMember', {selector}, m => m.prototype.renderActivity); this.ChannelMember = await ReactComponents.getComponent('ChannelMember', {selector}, m => m.prototype.renderActivity);
this.unpatchChannelMemberRender = MonkeyPatch('BD:ReactComponents', this.ChannelMember.component.prototype).after('render', (component, args, retVal) => { this.unpatchChannelMemberRender = MonkeyPatch('BD:ReactComponents', this.ChannelMember.component.prototype).after('render', (component, args, retVal) => {
@ -423,7 +423,7 @@ export class ReactAutoPatcher {
* The GuildTextChannel component represents a text channel in the guild channel list. * The GuildTextChannel component represents a text channel in the guild channel list.
*/ */
static async patchGuildTextChannel() { static async patchGuildTextChannel() {
const selector = '.' + WebpackModules.getClassName('containerDefault', 'actionIcon'); const selector = `.${WebpackModules.getClassName('containerDefault', 'actionIcon')}`;
this.GuildTextChannel = await ReactComponents.getComponent('GuildTextChannel', {selector}, c => c.prototype.renderMentionBadge); this.GuildTextChannel = await ReactComponents.getComponent('GuildTextChannel', {selector}, c => c.prototype.renderMentionBadge);
this.unpatchGuildTextChannel = MonkeyPatch('BD:ReactComponents', this.GuildTextChannel.component.prototype).after('render', this._afterChannelRender); this.unpatchGuildTextChannel = MonkeyPatch('BD:ReactComponents', this.GuildTextChannel.component.prototype).after('render', this._afterChannelRender);
@ -435,7 +435,7 @@ export class ReactAutoPatcher {
* The GuildVoiceChannel component represents a voice channel in the guild channel list. * The GuildVoiceChannel component represents a voice channel in the guild channel list.
*/ */
static async patchGuildVoiceChannel() { static async patchGuildVoiceChannel() {
const selector = '.' + WebpackModules.getClassName('containerDefault', 'actionIcon'); const selector = `.${WebpackModules.getClassName('containerDefault', 'actionIcon')}`;
this.GuildVoiceChannel = await ReactComponents.getComponent('GuildVoiceChannel', {selector}, c => c.prototype.handleVoiceConnect); this.GuildVoiceChannel = await ReactComponents.getComponent('GuildVoiceChannel', {selector}, c => c.prototype.handleVoiceConnect);
this.unpatchGuildVoiceChannel = MonkeyPatch('BD:ReactComponents', this.GuildVoiceChannel.component.prototype).after('render', this._afterChannelRender); this.unpatchGuildVoiceChannel = MonkeyPatch('BD:ReactComponents', this.GuildVoiceChannel.component.prototype).after('render', this._afterChannelRender);
@ -469,7 +469,7 @@ export class ReactAutoPatcher {
} }
static async patchUserProfileModal() { static async patchUserProfileModal() {
const selector = '.' + WebpackModules.getClassName('root', 'topSectionNormal'); const selector = `.${WebpackModules.getClassName('root', 'topSectionNormal')}`;
this.UserProfileModal = await ReactComponents.getComponent('UserProfileModal', {selector}, Filters.byPrototypeFields(['renderHeader', 'renderBadges'])); this.UserProfileModal = await ReactComponents.getComponent('UserProfileModal', {selector}, Filters.byPrototypeFields(['renderHeader', 'renderBadges']));
this.unpatchUserProfileModal = MonkeyPatch('BD:ReactComponents', this.UserProfileModal.component.prototype).after('render', (component, args, retVal) => { this.unpatchUserProfileModal = MonkeyPatch('BD:ReactComponents', this.UserProfileModal.component.prototype).after('render', (component, args, retVal) => {
@ -484,7 +484,7 @@ export class ReactAutoPatcher {
} }
static async patchUserPopout() { static async patchUserPopout() {
const selector = '.' + WebpackModules.getClassName('userPopout', 'headerNormal'); const selector = `.${WebpackModules.getClassName('userPopout', 'headerNormal')}`;
this.UserPopout = await ReactComponents.getComponent('UserPopout', {selector}); this.UserPopout = await ReactComponents.getComponent('UserPopout', {selector});
this.unpatchUserPopout = MonkeyPatch('BD:ReactComponents', this.UserPopout.component.prototype).after('render', (component, args, retVal) => { this.unpatchUserPopout = MonkeyPatch('BD:ReactComponents', this.UserPopout.component.prototype).after('render', (component, args, retVal) => {
@ -503,7 +503,7 @@ export class ReactAutoPatcher {
} }
static async patchUploadArea() { static async patchUploadArea() {
const selector = '.' + WebpackModules.getClassName('uploadArea'); const selector = `.${WebpackModules.getClassName('uploadArea')}`;
this.UploadArea = await ReactComponents.getComponent('UploadArea', {selector}); this.UploadArea = await ReactComponents.getComponent('UploadArea', {selector});
const reflect = Reflection(selector); const reflect = Reflection(selector);
@ -514,7 +514,7 @@ export class ReactAutoPatcher {
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
stateNode.clearDragging(); stateNode.clearDragging();
Modals.confirm("Function not ready", `You tried to install "${e.dataTransfer.files[0].path}", but installing .bd files isn't ready yet.`) Modals.confirm('Function not ready', `You tried to install "${e.dataTransfer.files[0].path}", but installing .bd files isn't ready yet.`)
// Possibly something like Events.emit('install-file', e.dataTransfer.files[0]); // Possibly something like Events.emit('install-file', e.dataTransfer.files[0]);
}; };

View File

@ -54,7 +54,7 @@ export default new class Settings {
const user_config = await FileUtils.readJsonFromFile(settingsPath); const user_config = await FileUtils.readJsonFromFile(settingsPath);
const { settings, scss, css, css_editor_files, scss_error, css_editor_bounds, favourite_emotes } = user_config; const { settings, scss, css, css_editor_files, scss_error, css_editor_bounds, favourite_emotes } = user_config;
for (let set of this.settings) { for (const set of this.settings) {
const newSet = settings.find(s => s.id === set.id); const newSet = settings.find(s => s.id === set.id);
if (!newSet) continue; if (!newSet) continue;
await set.merge(newSet, {dont_save: true}); await set.merge(newSet, {dont_save: true});
@ -91,7 +91,7 @@ export default new class Settings {
favourite_emotes: EmoteModule.favourite_emotes favourite_emotes: EmoteModule.favourite_emotes
}); });
for (let set of this.settings) { for (const set of this.settings) {
set.setSaved(); set.setSaved();
} }
} catch (err) { } catch (err) {

View File

@ -150,7 +150,7 @@ export default class Theme extends Content {
set watchfiles(files) { set watchfiles(files) {
if (!files) files = []; if (!files) files = [];
for (let file of files) { for (const file of files) {
if (!this.watchfiles.includes(file)) { if (!this.watchfiles.includes(file)) {
this.filewatcher.add(file); this.filewatcher.add(file);
this.watchfiles.push(file); this.watchfiles.push(file);
@ -158,7 +158,7 @@ export default class Theme extends Content {
} }
} }
for (let index in this.watchfiles) { for (const index in this.watchfiles) {
let file = this.watchfiles[index]; let file = this.watchfiles[index];
while (file && !files.find(f => f === file)) { while (file && !files.find(f => f === file)) {
this.filewatcher.remove(file); this.filewatcher.remove(file);

View File

@ -80,8 +80,8 @@ export default class ThemeManager extends ContentManager {
static async getConfigAsSCSS(settingsset) { static async getConfigAsSCSS(settingsset) {
const variables = []; const variables = [];
for (let category of settingsset.categories) { for (const category of settingsset.categories) {
for (let setting of category.settings) { for (const setting of category.settings) {
const setting_scss = await this.parseSetting(setting); const setting_scss = await this.parseSetting(setting);
if (setting_scss) variables.push(`$${setting_scss[0]}: ${setting_scss[1]};`); if (setting_scss) variables.push(`$${setting_scss[0]}: ${setting_scss[1]};`);
} }
@ -98,14 +98,14 @@ export default class ThemeManager extends ContentManager {
static async getConfigAsSCSSMap(settingsset) { static async getConfigAsSCSSMap(settingsset) {
const variables = []; const variables = [];
for (let category of settingsset.categories) { for (const category of settingsset.categories) {
for (let setting of category.settings) { for (const setting of category.settings) {
const setting_scss = await this.parseSetting(setting); const setting_scss = await this.parseSetting(setting);
if (setting_scss) variables.push(`${setting_scss[0]}: (${setting_scss[1]})`); if (setting_scss) variables.push(`${setting_scss[0]}: (${setting_scss[1]})`);
} }
} }
return '(' + variables.join(', ') + ')'; return `(${variables.join(', ')})`;
} }
/** /**

View File

@ -21,11 +21,11 @@ const KnownModules = {
GuildStore: Filters.byProperties(['getGuild']), GuildStore: Filters.byProperties(['getGuild']),
SortedGuildStore: Filters.byProperties(['getSortedGuilds']), SortedGuildStore: Filters.byProperties(['getSortedGuilds']),
SelectedGuildStore: Filters.byProperties(['getLastSelectedGuildId']), SelectedGuildStore: Filters.byProperties(['getLastSelectedGuildId']),
GuildSync: Filters.byProperties(["getSyncedGuilds"]), GuildSync: Filters.byProperties(['getSyncedGuilds']),
GuildInfo: Filters.byProperties(["getAcronym"]), GuildInfo: Filters.byProperties(['getAcronym']),
GuildChannelsStore: Filters.byProperties(['getChannels', 'getDefaultChannel']), GuildChannelsStore: Filters.byProperties(['getChannels', 'getDefaultChannel']),
GuildMemberStore: Filters.byProperties(['getMember']), GuildMemberStore: Filters.byProperties(['getMember']),
MemberCountStore: Filters.byProperties(["getMemberCounts"]), MemberCountStore: Filters.byProperties(['getMemberCounts']),
GuildEmojiStore: Filters.byProperties(['getEmojis']), GuildEmojiStore: Filters.byProperties(['getEmojis']),
GuildActions: Filters.byProperties(['markGuildAsRead']), GuildActions: Filters.byProperties(['markGuildAsRead']),
GuildPermissions: Filters.byProperties(['getGuildPermissions']), GuildPermissions: Filters.byProperties(['getGuildPermissions']),
@ -33,20 +33,20 @@ const KnownModules = {
/* Channel Store & Actions */ /* Channel Store & Actions */
ChannelStore: Filters.byProperties(['getChannels', 'getDMFromUserId']), ChannelStore: Filters.byProperties(['getChannels', 'getDMFromUserId']),
SelectedChannelStore: Filters.byProperties(['getLastSelectedChannelId']), SelectedChannelStore: Filters.byProperties(['getLastSelectedChannelId']),
ChannelActions: Filters.byProperties(["selectChannel"]), ChannelActions: Filters.byProperties(['selectChannel']),
PrivateChannelActions: Filters.byProperties(["openPrivateChannel"]), PrivateChannelActions: Filters.byProperties(['openPrivateChannel']),
ChannelSelector: Filters.byProperties(["selectGuild", "selectChannel"]), ChannelSelector: Filters.byProperties(['selectGuild', 'selectChannel']),
/* Current User Info, State and Settings */ /* Current User Info, State and Settings */
UserInfoStore: Filters.byProperties(["getToken"]), UserInfoStore: Filters.byProperties(['getToken']),
UserSettingsStore: Filters.byProperties(["guildPositions"]), UserSettingsStore: Filters.byProperties(['guildPositions']),
AccountManager: Filters.byProperties(['register', 'login']), AccountManager: Filters.byProperties(['register', 'login']),
UserSettingsUpdater: Filters.byProperties(['updateRemoteSettings']), UserSettingsUpdater: Filters.byProperties(['updateRemoteSettings']),
OnlineWatcher: Filters.byProperties(['isOnline']), OnlineWatcher: Filters.byProperties(['isOnline']),
CurrentUserIdle: Filters.byProperties(['getIdleTime']), CurrentUserIdle: Filters.byProperties(['getIdleTime']),
RelationshipStore: Filters.byProperties(['isBlocked']), RelationshipStore: Filters.byProperties(['isBlocked']),
RelationshipManager: Filters.byProperties(['addRelationship']), RelationshipManager: Filters.byProperties(['addRelationship']),
MentionStore: Filters.byProperties(["getMentions"]), MentionStore: Filters.byProperties(['getMentions']),
/* User Stores and Utils */ /* User Stores and Utils */
UserStore: Filters.byProperties(['getCurrentUser']), UserStore: Filters.byProperties(['getCurrentUser']),
@ -64,18 +64,18 @@ const KnownModules = {
EmojiStore: Filters.byProperties(['getByCategory', 'EMOJI_NAME_RE']), EmojiStore: Filters.byProperties(['getByCategory', 'EMOJI_NAME_RE']),
/* Invite Store and Utils */ /* Invite Store and Utils */
InviteStore: Filters.byProperties(["getInvites"]), InviteStore: Filters.byProperties(['getInvites']),
InviteResolver: Filters.byProperties(['findInvite']), InviteResolver: Filters.byProperties(['findInvite']),
InviteActions: Filters.byProperties(['acceptInvite']), InviteActions: Filters.byProperties(['acceptInvite']),
/* Discord Objects & Utils */ /* Discord Objects & Utils */
DiscordConstants: Filters.byProperties(["Permissions", "ActivityTypes", "StatusTypes"]), DiscordConstants: Filters.byProperties(['Permissions', 'ActivityTypes', 'StatusTypes']),
Permissions: Filters.byProperties(['getHighestRole']), Permissions: Filters.byProperties(['getHighestRole']),
ColorConverter: Filters.byProperties(['hex2int']), ColorConverter: Filters.byProperties(['hex2int']),
ColorShader: Filters.byProperties(['darken']), ColorShader: Filters.byProperties(['darken']),
ClassResolver: Filters.byProperties(["getClass"]), ClassResolver: Filters.byProperties(['getClass']),
ButtonData: Filters.byProperties(["ButtonSizes"]), ButtonData: Filters.byProperties(['ButtonSizes']),
IconNames: Filters.byProperties(["IconNames"]), IconNames: Filters.byProperties(['IconNames']),
NavigationUtils: Filters.byProperties(['transitionTo', 'replaceWith', 'getHistory']), NavigationUtils: Filters.byProperties(['transitionTo', 'replaceWith', 'getHistory']),
/* Discord Messages */ /* Discord Messages */
@ -94,36 +94,36 @@ const KnownModules = {
CurrentExperiment: Filters.byProperties(['getExperimentId']), CurrentExperiment: Filters.byProperties(['getExperimentId']),
/* Images, Avatars and Utils */ /* Images, Avatars and Utils */
ImageResolver: Filters.byProperties(["getUserAvatarURL"]), ImageResolver: Filters.byProperties(['getUserAvatarURL']),
ImageUtils: Filters.byProperties(['getSizedImageSrc']), ImageUtils: Filters.byProperties(['getSizedImageSrc']),
AvatarDefaults: Filters.byProperties(["getUserAvatarURL", "DEFAULT_AVATARS"]), AvatarDefaults: Filters.byProperties(['getUserAvatarURL', 'DEFAULT_AVATARS']),
/* Drag & Drop */ /* Drag & Drop */
DNDActions: Filters.byProperties(["beginDrag"]), DNDActions: Filters.byProperties(['beginDrag']),
DNDSources: Filters.byProperties(["addTarget"]), DNDSources: Filters.byProperties(['addTarget']),
DNDObjects: Filters.byProperties(["DragSource"]), DNDObjects: Filters.byProperties(['DragSource']),
/* Electron & Other Internals with Utils */ /* Electron & Other Internals with Utils */
ElectronModule: Filters.byProperties(["_getMainWindow"]), ElectronModule: Filters.byProperties(['_getMainWindow']),
Dispatcher: Filters.byProperties(['dirtyDispatch']), Dispatcher: Filters.byProperties(['dirtyDispatch']),
PathUtils: Filters.byProperties(["hasBasename"]), PathUtils: Filters.byProperties(['hasBasename']),
NotificationModule: Filters.byProperties(["showNotification"]), NotificationModule: Filters.byProperties(['showNotification']),
RouterModule: Filters.byProperties(["Router"]), RouterModule: Filters.byProperties(['Router']),
APIModule: Filters.byProperties(["getAPIBaseURL"]), APIModule: Filters.byProperties(['getAPIBaseURL']),
AnalyticEvents: Filters.byProperties(["AnalyticEventConfigs"]), AnalyticEvents: Filters.byProperties(['AnalyticEventConfigs']),
KeyGenerator: Filters.byCode(/"binary"/), KeyGenerator: Filters.byCode(/"binary"/),
Buffers: Filters.byProperties(['Buffer', 'kMaxLength']), Buffers: Filters.byProperties(['Buffer', 'kMaxLength']),
DeviceStore: Filters.byProperties(['getDevices']), DeviceStore: Filters.byProperties(['getDevices']),
SoftwareInfo: Filters.byProperties(["os"]), SoftwareInfo: Filters.byProperties(['os']),
CurrentContext: Filters.byProperties(["setTagsContext"]), CurrentContext: Filters.byProperties(['setTagsContext']),
/* Media Stuff (Audio/Video) */ /* Media Stuff (Audio/Video) */
MediaDeviceInfo: Filters.byProperties(["Codecs", "SUPPORTED_BROWSERS"]), MediaDeviceInfo: Filters.byProperties(['Codecs', 'SUPPORTED_BROWSERS']),
MediaInfo: Filters.byProperties(["getOutputVolume"]), MediaInfo: Filters.byProperties(['getOutputVolume']),
MediaEngineInfo: Filters.byProperties(['MediaEngineFeatures']), MediaEngineInfo: Filters.byProperties(['MediaEngineFeatures']),
VoiceInfo: Filters.byProperties(["EchoCancellation"]), VoiceInfo: Filters.byProperties(['EchoCancellation']),
VideoStream: Filters.byProperties(["getVideoStream"]), VideoStream: Filters.byProperties(['getVideoStream']),
SoundModule: Filters.byProperties(["playSound"]), SoundModule: Filters.byProperties(['playSound']),
/* Window, DOM, HTML */ /* Window, DOM, HTML */
WindowInfo: Filters.byProperties(['isFocused', 'windowSize']), WindowInfo: Filters.byProperties(['isFocused', 'windowSize']),
@ -133,13 +133,13 @@ const KnownModules = {
/* Locale/Location and Time */ /* Locale/Location and Time */
LocaleManager: Filters.byProperties(['setLocale']), LocaleManager: Filters.byProperties(['setLocale']),
Moment: Filters.byProperties(['parseZone']), Moment: Filters.byProperties(['parseZone']),
LocationManager: Filters.byProperties(["createLocation"]), LocationManager: Filters.byProperties(['createLocation']),
Timestamps: Filters.byProperties(["fromTimestamp"]), Timestamps: Filters.byProperties(['fromTimestamp']),
/* Strings and Utils */ /* Strings and Utils */
Strings: Filters.byProperties(["TEXT", "TEXTAREA_PLACEHOLDER"]), Strings: Filters.byProperties(['TEXT', 'TEXTAREA_PLACEHOLDER']),
StringFormats: Filters.byProperties(['a', 'z']), StringFormats: Filters.byProperties(['a', 'z']),
StringUtils: Filters.byProperties(["toASCII"]), StringUtils: Filters.byProperties(['toASCII']),
/* URLs and Utils */ /* URLs and Utils */
URLParser: Filters.byProperties(['Url', 'parse']), URLParser: Filters.byProperties(['Url', 'parse']),
@ -193,7 +193,7 @@ class WebpackModules {
static getModule(filter, first = true, _modules) { static getModule(filter, first = true, _modules) {
const modules = _modules || this.getAllModules(); const modules = _modules || this.getAllModules();
const rm = []; const rm = [];
for (let index in modules) { for (const index in modules) {
if (!modules.hasOwnProperty(index)) continue; if (!modules.hasOwnProperty(index)) continue;
const module = modules[index]; const module = modules[index];
const { exports } = module; const { exports } = module;
@ -317,7 +317,7 @@ class WebpackModules {
this.moduleLoadedEventTimeout = undefined; this.moduleLoadedEventTimeout = undefined;
// Emit a module-loaded event for every module // Emit a module-loaded event for every module
for (let module of this.modulesLoadingCache) { for (const module of this.modulesLoadingCache) {
Events.emit('module-loaded', module); Events.emit('module-loaded', module);
} }

View File

@ -27,12 +27,12 @@ export class Channel {
static from(channel) { static from(channel) {
switch (channel.type) { switch (channel.type) {
default: return new Channel(channel); default: return new Channel(channel);
case 0: return new GuildTextChannel(channel); case 0: return new GuildTextChannel(channel);
case 1: return new DirectMessageChannel(channel); case 1: return new DirectMessageChannel(channel);
case 2: return new GuildVoiceChannel(channel); case 2: return new GuildVoiceChannel(channel);
case 3: return new GroupChannel(channel); case 3: return new GroupChannel(channel);
case 4: return new ChannelCategory(channel); case 4: return new ChannelCategory(channel);
} }
} }
@ -156,9 +156,9 @@ export class PermissionOverwrite {
static from(data, channel_id) { static from(data, channel_id) {
switch (data.type) { switch (data.type) {
default: return new PermissionOverwrite(data, channel_id); default: return new PermissionOverwrite(data, channel_id);
case 'role': return new RolePermissionOverwrite(data, channel_id); case 'role': return new RolePermissionOverwrite(data, channel_id);
case 'member': return new MemberPermissionOverwrite(data, channel_id); case 'member': return new MemberPermissionOverwrite(data, channel_id);
} }
} }

View File

@ -99,15 +99,15 @@ export class Message {
static from(data) { static from(data) {
switch (data.type) { switch (data.type) {
default: return new Message(data); default: return new Message(data);
case 0: return new DefaultMessage(data); case 0: return new DefaultMessage(data);
case 1: return new RecipientAddMessage(data); case 1: return new RecipientAddMessage(data);
case 2: return new RecipientRemoveMessage(data); case 2: return new RecipientRemoveMessage(data);
case 3: return new CallMessage(data); case 3: return new CallMessage(data);
case 4: return new GroupChannelNameChangeMessage(data); case 4: return new GroupChannelNameChangeMessage(data);
case 5: return new GroupChannelIconChangeMessage(data); case 5: return new GroupChannelIconChangeMessage(data);
case 6: return new MessagePinnedMessage(data); case 6: return new MessagePinnedMessage(data);
case 7: return new GuildMemberJoinMessage(data); case 7: return new GuildMemberJoinMessage(data);
} }
} }

View File

@ -289,7 +289,7 @@ export class GuildMember {
addRole(...roles) { addRole(...roles) {
const newRoles = this.roleIds.concat([]); const newRoles = this.roleIds.concat([]);
let changed = false; let changed = false;
for (let role of roles) { for (const role of roles) {
if (newRoles.includes(role.id || role)) continue; if (newRoles.includes(role.id || role)) continue;
newRoles.push(role.id || role); newRoles.push(role.id || role);
changed = true; changed = true;
@ -306,7 +306,7 @@ export class GuildMember {
removeRole(...roles) { removeRole(...roles) {
const newRoles = this.roleIds.concat([]); const newRoles = this.roleIds.concat([]);
let changed = false; let changed = false;
for (let role of roles) { for (const role of roles) {
if (!newRoles.includes(role.id || role)) continue; if (!newRoles.includes(role.id || role)) continue;
Utils.removeFromArray(newRoles, role.id || role); Utils.removeFromArray(newRoles, role.id || role);
changed = true; changed = true;

View File

@ -10,14 +10,10 @@
export default class List extends Array { export default class List extends Array {
constructor() {
super(...arguments);
}
get(...filters) { get(...filters) {
return this.find(item => { return this.find(item => {
for (let filter of filters) { for (const filter of filters) {
for (let key in filter) { for (const key in filter) {
if (filter.hasOwnProperty(key)) { if (filter.hasOwnProperty(key)) {
if (item[key] !== filter[key]) return false; if (item[key] !== filter[key]) return false;
} }

View File

@ -29,14 +29,14 @@ export default class SettingsCategory extends AsyncEventEmitter {
this.args.settings = this.settings.map(setting => new Setting(setting)); this.args.settings = this.settings.map(setting => new Setting(setting));
for (let newCategory of merge) { for (const newCategory of merge) {
this._merge(newCategory); this._merge(newCategory);
} }
this.__settingUpdated = this.__settingUpdated.bind(this); this.__settingUpdated = this.__settingUpdated.bind(this);
this.__settingsUpdated = this.__settingsUpdated.bind(this); this.__settingsUpdated = this.__settingsUpdated.bind(this);
for (let setting of this.settings) { for (const setting of this.settings) {
setting.on('setting-updated', this.__settingUpdated); setting.on('setting-updated', this.__settingUpdated);
setting.on('settings-updated', this.__settingsUpdated); setting.on('settings-updated', this.__settingsUpdated);
} }
@ -216,7 +216,7 @@ export default class SettingsCategory extends AsyncEventEmitter {
_merge(newCategory) { _merge(newCategory) {
let updatedSettings = []; let updatedSettings = [];
for (let newSetting of newCategory.settings) { for (const newSetting of newCategory.settings) {
const setting = this.settings.find(setting => setting.id === newSetting.id); const setting = this.settings.find(setting => setting.id === newSetting.id);
if (!setting) { if (!setting) {
Logger.warn('SettingsCategory', `Trying to merge setting ${this.id}/${newSetting.id}, which does not exist.`); Logger.warn('SettingsCategory', `Trying to merge setting ${this.id}/${newSetting.id}, which does not exist.`);
@ -243,7 +243,7 @@ export default class SettingsCategory extends AsyncEventEmitter {
async merge(newCategory, emit_multi = true) { async merge(newCategory, emit_multi = true) {
let updatedSettings = []; let updatedSettings = [];
for (let newSetting of newCategory.settings) { for (const newSetting of newCategory.settings) {
const setting = this.settings.find(setting => setting.id === newSetting.id); const setting = this.settings.find(setting => setting.id === newSetting.id);
if (!setting) { if (!setting) {
Logger.warn('SettingsCategory', `Trying to merge setting ${this.id}/${newSetting.id}, which does not exist.`); Logger.warn('SettingsCategory', `Trying to merge setting ${this.id}/${newSetting.id}, which does not exist.`);
@ -271,7 +271,7 @@ export default class SettingsCategory extends AsyncEventEmitter {
* Marks all settings in this set as saved (not changed). * Marks all settings in this set as saved (not changed).
*/ */
setSaved() { setSaved() {
for (let setting of this.settings) { for (const setting of this.settings) {
setting.setSaved(); setting.setSaved();
} }
} }

View File

@ -86,14 +86,14 @@ export default class SettingsScheme {
* @return {Boolean} * @return {Boolean}
*/ */
isActive(set) { isActive(set) {
for (let schemeCategory of this.categories) { for (const schemeCategory of this.categories) {
const category = set.categories.find(c => c.id === (schemeCategory.id || schemeCategory.category)); const category = set.categories.find(c => c.id === (schemeCategory.id || schemeCategory.category));
if (!category) { if (!category) {
Logger.warn('SettingsScheme', `Category ${schemeCategory.id || schemeCategory.category} does not exist`); Logger.warn('SettingsScheme', `Category ${schemeCategory.id || schemeCategory.category} does not exist`);
return false; return false;
} }
for (let schemeSetting of schemeCategory.settings) { for (const schemeSetting of schemeCategory.settings) {
const setting = category.settings.find(s => s.id === schemeSetting.id); const setting = category.settings.find(s => s.id === schemeSetting.id);
if (!setting) { if (!setting) {
Logger.warn('SettingsScheme', `Setting ${category.category}/${schemeSetting.id} does not exist`); Logger.warn('SettingsScheme', `Setting ${category.category}/${schemeSetting.id} does not exist`);

View File

@ -31,7 +31,7 @@ export default class SettingsSet extends AsyncEventEmitter {
this.args.categories = this.categories.map(category => new SettingsCategory(category)); this.args.categories = this.categories.map(category => new SettingsCategory(category));
this.args.schemes = this.schemes.map(scheme => new SettingsScheme(scheme)); this.args.schemes = this.schemes.map(scheme => new SettingsScheme(scheme));
for (let newSet of merge) { for (const newSet of merge) {
this._merge(newSet); this._merge(newSet);
} }
@ -40,7 +40,7 @@ export default class SettingsSet extends AsyncEventEmitter {
this.__addedSetting = this.__addedSetting.bind(this); this.__addedSetting = this.__addedSetting.bind(this);
this.__removedSetting = this.__removedSetting.bind(this); this.__removedSetting = this.__removedSetting.bind(this);
for (let category of this.categories) { for (const category of this.categories) {
category.on('setting-updated', this.__settingUpdated); category.on('setting-updated', this.__settingUpdated);
category.on('settings-updated', this.__settingsUpdated); category.on('settings-updated', this.__settingsUpdated);
category.on('added-setting', this.__addedSetting); category.on('added-setting', this.__addedSetting);
@ -287,7 +287,7 @@ export default class SettingsSet extends AsyncEventEmitter {
* @return {Setting} * @return {Setting}
*/ */
findSetting(f) { findSetting(f) {
for (let category of this.categories) { for (const category of this.categories) {
const setting = category.find(f); const setting = category.find(f);
if (setting) return setting; if (setting) return setting;
} }
@ -309,7 +309,7 @@ export default class SettingsSet extends AsyncEventEmitter {
* @return {Array} An array of matching Setting objects * @return {Array} An array of matching Setting objects
*/ */
findSettingInCategory(cf, f) { findSettingInCategory(cf, f) {
for (let category of this.categories.filter(cf)) { for (const category of this.categories.filter(cf)) {
const setting = category.find(f); const setting = category.find(f);
if (setting) return setting; if (setting) return setting;
} }
@ -323,7 +323,7 @@ export default class SettingsSet extends AsyncEventEmitter {
*/ */
findSettingsInCategory(cf, f) { findSettingsInCategory(cf, f) {
let settings = []; let settings = [];
for (let category of this.categories.filter(cf)) { for (const category of this.categories.filter(cf)) {
settings = settings.concat(category.findSettings(f)); settings = settings.concat(category.findSettings(f));
} }
return settings; return settings;
@ -371,7 +371,7 @@ export default class SettingsSet extends AsyncEventEmitter {
const categories = newSet && newSet.args ? newSet.args.settings : newSet ? newSet.settings : newSet; const categories = newSet && newSet.args ? newSet.args.settings : newSet ? newSet.settings : newSet;
if (!categories) return []; if (!categories) return [];
for (let newCategory of categories) { for (const newCategory of categories) {
const category = this.find(category => category.id === (newCategory.id || newCategory.category)); const category = this.find(category => category.id === (newCategory.id || newCategory.category));
if (!category) { if (!category) {
Logger.warn('SettingsSet', `Trying to merge category ${newCategory.id}, which does not exist.`); Logger.warn('SettingsSet', `Trying to merge category ${newCategory.id}, which does not exist.`);
@ -402,7 +402,7 @@ export default class SettingsSet extends AsyncEventEmitter {
newSet ? newSet.categories || newSet.settings : newSet; newSet ? newSet.categories || newSet.settings : newSet;
if (!categories) return []; if (!categories) return [];
for (let newCategory of categories) { for (const newCategory of categories) {
const category = this.find(category => category.id === (newCategory.id || newCategory.category)); const category = this.find(category => category.id === (newCategory.id || newCategory.category));
if (!category) { if (!category) {
Logger.warn('SettingsSet', `Trying to merge category ${newCategory.id}, which does not exist.`); Logger.warn('SettingsSet', `Trying to merge category ${newCategory.id}, which does not exist.`);
@ -432,7 +432,7 @@ export default class SettingsSet extends AsyncEventEmitter {
* Marks all settings in this set as saved (not changed). * Marks all settings in this set as saved (not changed).
*/ */
setSaved() { setSaved() {
for (let category of this.categories) { for (const category of this.categories) {
category.setSaved(); category.setSaved();
} }
} }

View File

@ -174,7 +174,7 @@ export default class ArraySetting extends Setting {
const newItems = []; const newItems = [];
let error; let error;
for (let newItem of updatedSetting.value) { for (const newItem of updatedSetting.value) {
try { try {
const item = this.items.find(i => i.id && i.id === newItem.id); const item = this.items.find(i => i.id && i.id === newItem.id);
@ -200,7 +200,7 @@ export default class ArraySetting extends Setting {
} catch (e) { error = e; } } catch (e) { error = e; }
} }
for (let item of this.items) { for (const item of this.items) {
if (newItems.includes(item)) continue; if (newItems.includes(item)) continue;
try { try {
@ -245,8 +245,8 @@ export default class ArraySetting extends Setting {
setContentPath(contentPath) { setContentPath(contentPath) {
this.args.path = contentPath; this.args.path = contentPath;
for (let category of this.categories) { for (const category of this.categories) {
for (let setting of category.settings) { for (const setting of category.settings) {
setting.setContentPath(contentPath); setting.setContentPath(contentPath);
} }
} }
@ -258,11 +258,11 @@ export default class ArraySetting extends Setting {
*/ */
async toSCSS() { async toSCSS() {
const maps = []; const maps = [];
for (let item of this.items) for (const item of this.items)
maps.push(await ThemeManager.getConfigAsSCSSMap(item)); maps.push(await ThemeManager.getConfigAsSCSSMap(item));
// Final comma ensures the variable is a list // Final comma ensures the variable is a list
return maps.length ? maps.join(', ') + ',' : '()'; return maps.length ? `${maps.join(', ')},` : '()';
} }
} }

View File

@ -30,7 +30,7 @@ export default class Setting extends AsyncEventEmitter {
if (!this.args.hasOwnProperty('saved_value')) if (!this.args.hasOwnProperty('saved_value'))
this.args.saved_value = this.args.value; this.args.saved_value = this.args.value;
for (let newSetting of merge) { for (const newSetting of merge) {
this._merge(newSetting); this._merge(newSetting);
} }

View File

@ -49,7 +49,7 @@ export default class FileSetting extends Setting {
if (!this.value || !this.value.length) return '()'; if (!this.value || !this.value.length) return '()';
const files = []; const files = [];
for (let filepath of this.value) { for (const filepath of this.value) {
const buffer = await FileUtils.readFileBuffer(path.resolve(this.path, filepath)); const buffer = await FileUtils.readFileBuffer(path.resolve(this.path, filepath));
const type = await FileUtils.getFileType(buffer); const type = await FileUtils.getFileType(buffer);
files.push(`(data: ${ThemeManager.toSCSSString(buffer.toString('base64'))}, type: ${ThemeManager.toSCSSString(type.mime)}, url: ${ThemeManager.toSCSSString(await FileUtils.toDataURI(buffer, type.mime))})`); files.push(`(data: ${ThemeManager.toSCSSString(buffer.toString('base64'))}, type: ${ThemeManager.toSCSSString(type.mime)}, url: ${ThemeManager.toSCSSString(await FileUtils.toDataURI(buffer, type.mime))})`);

View File

@ -89,7 +89,7 @@ export default class GuildSetting extends Setting {
const newGuilds = []; const newGuilds = [];
let error; let error;
for (let newGuild of updatedSetting.value) { for (const newGuild of updatedSetting.value) {
try { try {
const guild = updatedSetting.old_value.find(g => g === newGuild); const guild = updatedSetting.old_value.find(g => g === newGuild);
@ -105,7 +105,7 @@ export default class GuildSetting extends Setting {
} catch (e) { error = e; } } catch (e) { error = e; }
} }
for (let guild_id of updatedSetting.old_value) { for (const guild_id of updatedSetting.old_value) {
if (newGuilds.find(g => g === guild_id)) continue; if (newGuilds.find(g => g === guild_id)) continue;
try { try {
@ -129,7 +129,7 @@ export default class GuildSetting extends Setting {
if (!this.value || !this.value.length) return '()'; if (!this.value || !this.value.length) return '()';
const guilds = []; const guilds = [];
for (let guild_id of this.value) { for (const guild_id of this.value) {
if (guild_id) if (guild_id)
guilds.push(guild_id); guilds.push(guild_id);
} }

View File

@ -67,7 +67,7 @@ export default class KeybindSetting extends Setting {
} }
static __event_handler(event, data) { static __event_handler(event, data) {
for (let keybindSetting of instances) { for (const keybindSetting of instances) {
keybindSetting.emit(event, data); keybindSetting.emit(event, data);
} }
} }

View File

@ -58,7 +58,7 @@ export const BdMenuItems = new class {
if (this.items.includes(item)) return item; if (this.items.includes(item)) return item;
item.id = items++; item.id = items++;
item.contentid = item.contentid || (items++ + ''); item.contentid = item.contentid || (`${items++}`);
item.active = false; item.active = false;
item.hidden = item.hidden || false; item.hidden = item.hidden || false;
item._type = item._type || 'button'; item._type = item._type || 'button';

View File

@ -21,7 +21,7 @@ export default class ClassNormaliser extends Module {
} }
patchClassModules(modules) { patchClassModules(modules) {
for (let module of modules) { for (const module of modules) {
this.patchClassModule(normalizedPrefix, module); this.patchClassModule(normalizedPrefix, module);
} }
} }
@ -38,7 +38,7 @@ export default class ClassNormaliser extends Module {
if (typeof module !== 'object' || Array.isArray(module)) return false; if (typeof module !== 'object' || Array.isArray(module)) return false;
if (module.__esModule) return false; if (module.__esModule) return false;
if (!Object.keys(module).length) return false; if (!Object.keys(module).length) return false;
for (let baseClassName in module) { for (const baseClassName in module) {
const value = module[baseClassName]; const value = module[baseClassName];
if (typeof value !== 'string') return false; if (typeof value !== 'string') return false;
if (this.shouldIgnore(value)) continue; if (this.shouldIgnore(value)) continue;
@ -50,11 +50,11 @@ export default class ClassNormaliser extends Module {
} }
patchClassModule(componentName, classNames) { patchClassModule(componentName, classNames) {
for (let baseClassName in classNames) { for (const baseClassName in classNames) {
const value = classNames[baseClassName]; const value = classNames[baseClassName];
if (this.shouldIgnore(value)) continue; if (this.shouldIgnore(value)) continue;
const classList = value.split(' '); const classList = value.split(' ');
for (let normalClass of classList) { for (const normalClass of classList) {
const match = normalClass.match(randClass)[1]; const match = normalClass.match(randClass)[1];
if (!match) continue; // Shouldn't ever happen since they passed the moduleFilter, but you never know if (!match) continue; // Shouldn't ever happen since they passed the moduleFilter, but you never know
const camelCase = match.split('-').map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join(''); const camelCase = match.split('-').map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join('');
@ -74,7 +74,7 @@ export default class ClassNormaliser extends Module {
element.classList.add(`${normalizedPrefix}-${newClass}`); element.classList.add(`${normalizedPrefix}-${newClass}`);
} }
for (let child of element.children) { for (const child of element.children) {
this.normalizeElement(child); this.normalizeElement(child);
} }
} }

View File

@ -47,7 +47,7 @@ export class DOMObserver {
} }
observerCallback(mutations) { observerCallback(mutations) {
for (let sub of this.subscriptions) { for (const sub of this.subscriptions) {
try { try {
const filteredMutations = sub.filter ? mutations.filter(sub.filter) : mutations; const filteredMutations = sub.filter ? mutations.filter(sub.filter) : mutations;
@ -55,7 +55,7 @@ export class DOMObserver {
if (!filteredMutations.length) continue; if (!filteredMutations.length) continue;
sub.callback.call(sub.bind || sub, filteredMutations); sub.callback.call(sub.bind || sub, filteredMutations);
} else { } else {
for (let mutation of filteredMutations) sub.callback.call(sub.bind || sub, mutation); for (const mutation of filteredMutations) sub.callback.call(sub.bind || sub, mutation);
} }
} catch (err) { } catch (err) {
Logger.warn('DOMObserver', [`Error in observer callback`, err]); Logger.warn('DOMObserver', [`Error in observer callback`, err]);
@ -239,7 +239,7 @@ export default class DOM {
} }
static setAttributes(node, attributes) { static setAttributes(node, attributes) {
for (let attribute of attributes) { for (const attribute of attributes) {
node.setAttribute(attribute.name, attribute.value); node.setAttribute(attribute.name, attribute.value);
} }
} }

View File

@ -128,7 +128,7 @@ export default class Modals {
*/ */
static closeAll(force) { static closeAll(force) {
const promises = []; const promises = [];
for (let modal of this.stack) for (const modal of this.stack)
promises.push(modal.close(force)); promises.push(modal.close(force));
return Promise.all(promises); return Promise.all(promises);
} }
@ -235,14 +235,14 @@ export default class Modals {
if (errors.length) { if (errors.length) {
const modal = this.error({ const modal = this.error({
header: header:
(PluginManager.errors.length && ThemeManager.errors.length ? '' : `${(PluginManager.errors.length && ThemeManager.errors.length ? '' :
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName) + ' - ') + `${PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName } - `) +
(PluginManager.errors.length ? `${PluginManager.errors.length} ${PluginManager.contentType}${PluginManager.errors.length !== 1 ? 's' : ''}` : '') + (PluginManager.errors.length ? `${PluginManager.errors.length} ${PluginManager.contentType}${PluginManager.errors.length !== 1 ? 's' : ''}` : '') +
(PluginManager.errors.length && ThemeManager.errors.length ? ' and ' : '') + (PluginManager.errors.length && ThemeManager.errors.length ? ' and ' : '') +
(ThemeManager.errors.length ? `${ThemeManager.errors.length} ${ThemeManager.contentType}${ThemeManager.errors.length !== 1 ? 's' : ''}` : '') + (ThemeManager.errors.length ? `${ThemeManager.errors.length} ${ThemeManager.contentType}${ThemeManager.errors.length !== 1 ? 's' : ''}` : '')
' failed to load', } failed to load`,
module: (PluginManager.errors.length && ThemeManager.errors.length ? 'Content Manager' : module: (PluginManager.errors.length && ThemeManager.errors.length ? 'Content Manager' :
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName)), (PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName)),
type: 'err', type: 'err',
content: errors content: errors
}); });
@ -294,7 +294,7 @@ export default class Modals {
* @return {Modal} * @return {Modal}
*/ */
static contentSettings(content, headertext, options) { static contentSettings(content, headertext, options) {
return this.settings(content.settings, headertext ? headertext : content.name + ' Settings', options); return this.settings(content.settings, headertext ? headertext : `${content.name} Settings`, options);
} }
/** /**

View File

@ -88,7 +88,7 @@ export default class extends Module {
async patchNameTag() { async patchNameTag() {
if (this.PatchedNameTag) return this.PatchedNameTag; if (this.PatchedNameTag) return this.PatchedNameTag;
const selector = '.' + WebpackModules.getClassName('nameTag', 'username', 'discriminator', 'ownerIcon'); const selector = `.${WebpackModules.getClassName('nameTag', 'username', 'discriminator', 'ownerIcon')}`;
const NameTag = await ReactComponents.getComponent('NameTag', {selector}); const NameTag = await ReactComponents.getComponent('NameTag', {selector});
this.PatchedNameTag = class extends NameTag.component { this.PatchedNameTag = class extends NameTag.component {

View File

@ -110,7 +110,7 @@ class Reflection {
static getComponentStateNode(node, component) { static getComponentStateNode(node, component) {
if (component instanceof ReactComponents.ReactComponent) component = component.component; if (component instanceof ReactComponents.ReactComponent) component = component.component;
for (let stateNode of this.getStateNodes(node)) { for (const stateNode of this.getStateNodes(node)) {
if (stateNode instanceof component) return stateNode; if (stateNode instanceof component) return stateNode;
} }
} }

View File

@ -35,7 +35,7 @@ export default class AsyncEventEmitter extends EventEmitter {
}]; }];
} }
for (let listener of listeners) { for (const listener of listeners) {
await listener.apply(this, data); await listener.apply(this, data);
} }
} }

View File

@ -57,7 +57,7 @@ const ClientIPC = new class ClientIPC {
async send(channel, message, error) { async send(channel, message, error) {
channel = channel.startsWith('bd-') ? channel : `bd-${channel}`; channel = channel.startsWith('bd-') ? channel : `bd-${channel}`;
const eid = 'bd-' + Date.now().toString(); const eid = `bd-${Date.now().toString()}`;
ipcRenderer.send(channel, { eid, message, error }); ipcRenderer.send(channel, { eid, message, error });
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -72,21 +72,21 @@ export class Utils {
*/ */
static findInTree(tree, searchFilter, {walkable = null, ignore = []}) { static findInTree(tree, searchFilter, {walkable = null, ignore = []}) {
if (searchFilter(tree)) return tree; if (searchFilter(tree)) return tree;
if (typeof tree !== "object" || tree == null) return undefined; if (typeof tree !== 'object' || tree == null) return undefined;
let tempReturn = undefined; let tempReturn = undefined;
if (tree instanceof Array) { if (tree instanceof Array) {
for (let value of tree) { for (const value of tree) {
tempReturn = this.findInTree(value, searchFilter, {walkable, ignore}); tempReturn = this.findInTree(value, searchFilter, {walkable, ignore});
if (typeof tempReturn != "undefined") return tempReturn; if (typeof tempReturn != 'undefined') return tempReturn;
} }
} }
else { else {
const toWalk = walkable == null ? Object.keys(tree) : walkable; const toWalk = walkable == null ? Object.keys(tree) : walkable;
for (let key of toWalk) { for (const key of toWalk) {
if (!tree.hasOwnProperty(key) || ignore.includes(key)) continue; if (!tree.hasOwnProperty(key) || ignore.includes(key)) continue;
tempReturn = this.findInTree(tree[key], searchFilter, {walkable, ignore}); tempReturn = this.findInTree(tree[key], searchFilter, {walkable, ignore});
if (typeof tempReturn != "undefined") return tempReturn; if (typeof tempReturn != 'undefined') return tempReturn;
} }
} }
return tempReturn; return tempReturn;
@ -107,14 +107,14 @@ export class Utils {
// Loop through the object and check if everything's the same // Loop through the object and check if everything's the same
if (Object.keys(value1).length !== Object.keys(value2).length) return false; if (Object.keys(value1).length !== Object.keys(value2).length) return false;
for (let key in value1) { for (const key in value1) {
if (!this.compare(value1[key], value2[key])) return false; if (!this.compare(value1[key], value2[key])) return false;
} }
} else if (value1 !== value2) return false; } else if (value1 !== value2) return false;
// value1 and value2 contain the same data // value1 and value2 contain the same data
// Check any more values // Check any more values
for (let value3 of values) { for (const value3 of values) {
if (!this.compare(value1, value3)) if (!this.compare(value1, value3))
return false; return false;
} }
@ -136,7 +136,7 @@ export class Utils {
const clone = Object.assign({}, value); const clone = Object.assign({}, value);
for (let key in clone) { for (const key in clone) {
clone[key] = this.deepclone(clone[key], exclude); clone[key] = this.deepclone(clone[key], exclude);
} }
@ -157,7 +157,7 @@ export class Utils {
if (typeof object === 'object' && object !== null) { if (typeof object === 'object' && object !== null) {
const properties = Object.getOwnPropertyNames(object); const properties = Object.getOwnPropertyNames(object);
for (let property of properties) { for (const property of properties) {
this.deepfreeze(object[property], exclude); this.deepfreeze(object[property], exclude);
} }
@ -260,7 +260,7 @@ export class Utils {
}); });
const img = new Image(); const img = new Image();
img.src = reader.result; img.src = reader.result;
return await new Promise(resolve => { return new Promise(resolve => {
img.onload = () => { img.onload = () => {
resolve(img); resolve(img);
} }
@ -446,7 +446,7 @@ export class FileUtils {
* @return {Promise} * @return {Promise}
*/ */
static async writeJsonToFile(path, json, pretty) { static async writeJsonToFile(path, json, pretty) {
return this.writeFile(path, JSON.stringify(json, null, pretty ? 4 : 0) + '\n'); return this.writeFile(path, `${JSON.stringify(json, null, pretty ? 4 : 0)}\n`);
} }
/** /**

View File

@ -57,9 +57,9 @@ const globals = {
const CSP = { const CSP = {
'img-src': ['https://cdn.betterttv.net', 'https://cdn.frankerfacez.com'], 'img-src': ['https://cdn.betterttv.net', 'https://cdn.frankerfacez.com'],
'script-src': [ 'script-src': [
"'sha256-fSHKdpQGCHaIqWP3SpJOuUHrLp49jy4dWHzZ/RBJ/p4='", // React Devtools '\'sha256-fSHKdpQGCHaIqWP3SpJOuUHrLp49jy4dWHzZ/RBJ/p4=\'', // React Devtools
"'sha256-VFJcfKY5B3EBkFDgQnv3CozPwBlZcxwssfLVWlPFfZU='", // Vue Devtools '\'sha256-VFJcfKY5B3EBkFDgQnv3CozPwBlZcxwssfLVWlPFfZU=\'', // Vue Devtools
"'sha256-VzDmLZ4PxPkOS/KY7ITzLQsSWhfCnvUrNculcj8UNgE=' 'sha256-l6K+77Z1cmldR9gIvaVWlboF/zr5MXCQHcsEHfnr5TU='"] // Vue Detector '\'sha256-VzDmLZ4PxPkOS/KY7ITzLQsSWhfCnvUrNculcj8UNgE=\' \'sha256-l6K+77Z1cmldR9gIvaVWlboF/zr5MXCQHcsEHfnr5TU=\''] // Vue Detector
}; };
class PatchedBrowserWindow extends BrowserWindow { class PatchedBrowserWindow extends BrowserWindow {
@ -255,7 +255,7 @@ export class BetterDiscord {
*/ */
static hookSessionRequest() { static hookSessionRequest() {
session.defaultSession.webRequest.onHeadersReceived((details, callback) => { session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
for (let [header, values] of Object.entries(details.responseHeaders)) { for (const [header, values] of Object.entries(details.responseHeaders)) {
if (!header.match(/^Content-Security-Policy(-Report-Only)?$/i)) continue; if (!header.match(/^Content-Security-Policy(-Report-Only)?$/i)) continue;
details.responseHeaders[header] = values.map(value => { details.responseHeaders[header] = values.map(value => {

View File

@ -58,7 +58,7 @@ export default class BDIpc {
static send(window, channel, message, error) { static send(window, channel, message, error) {
channel = channel.startsWith('bd-') ? channel : `bd-${channel}`; channel = channel.startsWith('bd-') ? channel : `bd-${channel}`;
const eid = 'bd-' + Date.now().toString(); const eid = `bd-${ Date.now().toString()}`;
window.send(channel, { eid, message, error }); window.send(channel, { eid, message, error });
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -58,10 +58,10 @@ export default class Database {
async exec(cmd) { async exec(cmd) {
switch (cmd.action) { switch (cmd.action) {
case 'update': case 'update':
return this.update(cmd); return this.update(cmd);
case 'find': case 'find':
return this.find(cmd); return this.find(cmd);
} }
throw 'Invalid Command'; throw 'Invalid Command';
} }

View File

@ -20,7 +20,7 @@ import electron, { ipcRenderer } from 'electron';
const currentWindow = electron.remote.getCurrentWindow(); const currentWindow = electron.remote.getCurrentWindow();
if (currentWindow.__bd_preload) { if (currentWindow.__bd_preload) {
for (let preloadScript of currentWindow.__bd_preload) { for (const preloadScript of currentWindow.__bd_preload) {
try { try {
require(preloadScript); require(preloadScript);
} catch (err) { } catch (err) {

4
package-lock.json generated
View File

@ -5137,8 +5137,8 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"abbrev": "1", "abbrev": "1.1.0",
"osenv": "^0.1.4" "osenv": "0.1.4"
} }
}, },
"npmlog": { "npmlog": {

View File

@ -78,6 +78,7 @@
"build_installer": "npm run build --prefix installer", "build_installer": "npm run build --prefix installer",
"watch_installer": "npm run watch --prefix installer", "watch_installer": "npm run watch --prefix installer",
"lint": "eslint -f unix client/src core/src csseditor/src common", "lint": "eslint -f unix client/src core/src csseditor/src common",
"lint_fix": "eslint -f unix client/src core/src csseditor/src common --fix",
"test": "npm run build && npm run lint", "test": "npm run build && npm run lint",
"build_node-sass": "node scripts/build-node-sass.js", "build_node-sass": "node scripts/build-node-sass.js",
"build_release": "npm run release --prefix client && npm run build --prefix core && npm run release --prefix csseditor", "build_release": "npm run release --prefix client && npm run build --prefix core && npm run release --prefix csseditor",