Merge pull request #53 from samogot/lint

Add ESLint and some more stuff
This commit is contained in:
Alexei Stukov 2018-01-28 19:09:53 +02:00 committed by GitHub
commit c5083733be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 11285 additions and 46 deletions

21
.eslintrc.yml Normal file
View File

@ -0,0 +1,21 @@
---
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

@ -5,13 +5,13 @@
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const styles = require('./styles/index.scss');
const { Global, Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy, Events } = require('./modules');
const { Global, Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy, Events, Vendor } = require('./modules');
//const { UI } = require('./modules/ui/index.jsx');
class BetterDiscord {
@ -50,11 +50,5 @@ if (window.BetterDiscord) {
Logger.log('main', 'Attempting to inject again?');
} else {
let bdInstance = new BetterDiscord();
window.BetterDiscord = {
'vendor': {
jQuery: require('jquery'),
$: require('jquery'),
moment: WebpackModules.getModuleByName('Moment')
}
};
window.BetterDiscord = {'vendor': Vendor};
}

View File

@ -5,10 +5,11 @@
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
const { Module } = require('./modulebase');
const { Vendor } = require('./vendor');
const fs = window.require('fs');
const path = window.require('path');
@ -29,7 +30,7 @@ class Logger {
}
level = this.parseLevel(level);
console[level]('[%cBetter%cDiscord:%s] %s', 'color: #3E82E5', '', `${module}${level === 'debug' ? '|DBG' : ''}`, message);
logs.push(`[${BetterDiscord.vendor.moment().format('DD/MM/YY hh:mm:ss')}|${module}|${level}] ${message}`);
logs.push(`[${Vendor.moment().format('DD/MM/YY hh:mm:ss')}|${module}|${level}] ${message}`);
window.bdlogs = logs;
}
@ -78,7 +79,7 @@ class Utils {
});
}
}
}
class FileUtils {
@ -102,7 +103,7 @@ class FileUtils {
}
static async directoryExists(path) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
fs.stat(path, (err, stats) => {
if (err) return reject({
'message': `Directory does not exist: ${path}`,
@ -126,7 +127,7 @@ class FileUtils {
throw (err);
}
return new Promise(resolve => {
return new Promise((resolve, reject) => {
fs.readFile(path, 'utf-8', (err, data) => {
if (err) reject({
'message': `Could not read file: ${path}`,
@ -208,17 +209,17 @@ class Filters {
};
}
static byDisplayName(name) {
static byDisplayName(name) {
return module => {
return module && module.displayName === name;
};
}
static combine(...filters) {
static combine(...filters) {
return module => {
return filters.every(filter => filter(module));
};
}
};
}
module.exports = { Logger, Utils, FileUtils, Filters }

View File

@ -0,0 +1,30 @@
/**
* BetterDiscord Client Utils Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const {WebpackModules} = require('./webpackmodules');
const jQuery = require('jquery');
class Vendor {
static get jQuery() {
return jQuery;
}
static get $() {
return jQuery;
}
static get moment() {
return WebpackModules.getModuleByName('Moment');
}
}
module.exports = {Vendor};

View File

@ -7,4 +7,5 @@ export { WebpackModules } from './core/webpackmodules';
export { Events } from './core/events';
export { SocketProxy } from './core/discordsocket';
export { CssEditor } from './core/csseditor';
export { Settings } from './core/settings';
export { Settings } from './core/settings';
export { Vendor } from './core/vendor';

View File

@ -5,7 +5,7 @@
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
const $ = require('jquery');
@ -32,8 +32,8 @@ class UI {
this.vueInstance = new Vue({
el: '#bd-settings',
template: '<BdSettingsWrapper/>',
components: { BdSettingsWrapper }
components: { BdSettingsWrapper },
template: '<BdSettingsWrapper/>'
});
}

View File

@ -64,7 +64,7 @@ class CSSEditor extends Module {
//TODO Currently uses a development path
get editorPath() {
return path.resolve(__dirname, '..', '..', '..', 'csseditor', 'dist');
return path.resolve(__dirname, '..', '..', '..', 'tests', 'csseditor');
// return path.resolve(__dirname, '..', '..', '..', 'tests', 'csseditor');
}
}

View File

@ -5,10 +5,10 @@
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* LICENSE file in the root directory of this source tree.
*/
const
const
path = require('path'),
fs = require('fs');
@ -54,7 +54,7 @@ class FileUtils {
}
static async directoryExists(path) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
fs.stat(path, (err, stats) => {
if(err) return reject({
'message': `Directory does not exist: ${path}`,
@ -78,7 +78,7 @@ class FileUtils {
throw(err);
}
return new Promise(resolve => {
return new Promise((resolve, reject) => {
fs.readFile(path, 'utf-8', (err, data) => {
if(err) reject({
'message': `Could not read file: ${path}`,
@ -145,7 +145,7 @@ class WindowUtils extends Module {
channel = channel.startsWith('bd-') ? channel : `bd-${channel}`;
this.webContents.send(channel, message);
}
}
module.exports = {

View File

@ -10,8 +10,8 @@ window.cmCommands = VueCodemirror.CodeMirror.commands;
new Vue({
el: '#root',
template: '<Editor/>',
components: { Editor }
components: { Editor },
template: '<Editor/>'
});
const style = document.createElement('style');

11190
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -16,35 +16,37 @@
},
"private": false,
"devDependencies": {
"webpack": "^3.10.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-env": "^1.6.1",
"babel-loader": "^7.1.2",
"jquery": "^3.2.1",
"vue": "^2.5.13",
"vue-loader": "^13.7.0",
"vue-template-compiler": "^2.5.13",
"codemirror": "^5.23.0",
"css-loader": "^0.28.9",
"sass-loader": "^6.0.6",
"node-sass": "^4.7.2",
"electron": "^1.7.10",
"eslint": "^4.16.0",
"eslint-plugin-vue": "^4.2.0",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.0",
"pump": "^2.0.0",
"gulp-plumber": "^1.2.0",
"gulp-watch": "^5.0.0",
"codemirror": "^5.23.0",
"jquery": "^3.2.1",
"node-sass": "^4.7.2",
"pump": "^2.0.0",
"sass-loader": "^6.0.6",
"v-tooltip": "^2.0.0-rc.30",
"vue": "^2.5.13",
"vue-codemirror": "^4.0.3",
"vue-loader": "^13.7.0",
"vue-material-design-icons": "^1.0.0",
"v-tooltip": "^2.0.0-rc.30"
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0"
},
"scripts": {
"build": "cd ./client && npm run build && cd ../core && npm run build && cd ../csseditor && npm run build",
"watch_client": "cd ./client && npm run watch",
"watch_core": "cd ./core && npm run watch",
"test": "npm run build"
"build": "npm run build --prefix client && npm run build --prefix core && npm run build --prefix csseditor",
"watch_client": "npm run watch --prefix client",
"watch_core": "npm run watch --prefix core",
"lint": "eslint -f unix client/src core/src csseditor/src",
"test": "npm run build && npm run lint"
}
}