Merge pull request #265 from Razzeee/jshint
Jshint basic config and some cleanup jshint is not added yet due to the discussion in the PR.
This commit is contained in:
13
gulpfile.js
13
gulpfile.js
@@ -3,26 +3,23 @@
|
|||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var prettify = require('gulp-jsbeautifier');
|
var prettify = require('gulp-jsbeautifier');
|
||||||
var diff = require('gulp-diff');
|
var diff = require('gulp-diff');
|
||||||
var babel = require('gulp-babel');
|
|
||||||
var webpack = require('webpack-stream');
|
var webpack = require('webpack-stream');
|
||||||
var named = require('vinyl-named');
|
var named = require('vinyl-named');
|
||||||
var changed = require('gulp-changed');
|
|
||||||
var esformatter = require('gulp-esformatter');
|
var esformatter = require('gulp-esformatter');
|
||||||
var esformatter_origin = require('esformatter');
|
var esformatter_origin = require('esformatter');
|
||||||
var through = require('through2');
|
var through = require('through2');
|
||||||
var del = require('del');
|
|
||||||
var electron = require('electron-connect').server.create({
|
var electron = require('electron-connect').server.create({
|
||||||
path: './dist'
|
path: './dist'
|
||||||
});
|
});
|
||||||
var packager = require('electron-packager');
|
var packager = require('electron-packager');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const distPackageAuthor = 'Mattermost, Inc.'
|
const distPackageAuthor = 'Mattermost, Inc.';
|
||||||
|
|
||||||
var sources = ['**/*.js', '**/*.json', '**/*.css', '**/*.html', '!**/node_modules/**', '!dist/**', '!release/**', '!**/test_config.json'];
|
var sources = ['**/*.js', '**/*.json', '**/*.css', '**/*.html', '!**/node_modules/**', '!dist/**', '!release/**', '!**/test_config.json'];
|
||||||
|
|
||||||
gulp.task('prettify', ['prettify:sources', 'prettify:jsx']);
|
gulp.task('prettify', ['prettify:sources', 'prettify:jsx']);
|
||||||
gulp.task('prettify:verify', ['prettify:sources:verify', 'prettify:jsx:verify'])
|
gulp.task('prettify:verify', ['prettify:sources:verify', 'prettify:jsx:verify']);
|
||||||
|
|
||||||
var prettify_options = {
|
var prettify_options = {
|
||||||
html: {
|
html: {
|
||||||
@@ -164,7 +161,7 @@ gulp.task('webpack:webview', function() {
|
|||||||
},
|
},
|
||||||
target: 'electron'
|
target: 'electron'
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('dist/browser/webview'))
|
.pipe(gulp.dest('dist/browser/webview'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('copy', ['copy:resources', 'copy:html/css', 'copy:modules']);
|
gulp.task('copy', ['copy:resources', 'copy:html/css', 'copy:modules']);
|
||||||
@@ -181,7 +178,7 @@ gulp.task('copy:html/css', function() {
|
|||||||
|
|
||||||
gulp.task('copy:modules', function() {
|
gulp.task('copy:modules', function() {
|
||||||
return gulp.src(['src/node_modules/bootstrap/dist/**'])
|
return gulp.src(['src/node_modules/bootstrap/dist/**'])
|
||||||
.pipe(gulp.dest('dist/browser/modules/bootstrap'))
|
.pipe(gulp.dest('dist/browser/modules/bootstrap'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('watch', ['build'], function() {
|
gulp.task('watch', ['build'], function() {
|
||||||
@@ -248,7 +245,7 @@ function makePackage(platform, arch, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
gulp.task('package', ['build'], function(cb) {
|
gulp.task('package', ['build'], function(cb) {
|
||||||
makePackage(process.platform, 'all', cb);
|
makePackage(process.platform, 'all', cb);
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
"babel-preset-react": "^6.5.0",
|
"babel-preset-react": "^6.5.0",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"chai-as-promised": "^5.3.0",
|
"chai-as-promised": "^5.3.0",
|
||||||
"del": "^2.2.2",
|
|
||||||
"devtron": "^1.3.0",
|
"devtron": "^1.3.0",
|
||||||
"electron-builder": "5.2.1",
|
"electron-builder": "5.2.1",
|
||||||
"electron-connect": "~0.3.9",
|
"electron-connect": "~0.3.9",
|
||||||
@@ -45,8 +44,6 @@
|
|||||||
"esformatter": "^0.9.6",
|
"esformatter": "^0.9.6",
|
||||||
"esformatter-jsx": "^7.0.1",
|
"esformatter-jsx": "^7.0.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-babel": "^6.1.2",
|
|
||||||
"gulp-changed": "^1.3.2",
|
|
||||||
"gulp-diff": "^1.0.0",
|
"gulp-diff": "^1.0.0",
|
||||||
"gulp-esformatter": "^6.0.0",
|
"gulp-esformatter": "^6.0.0",
|
||||||
"gulp-jsbeautifier": "^2.0.3",
|
"gulp-jsbeautifier": "^2.0.3",
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller
|
'use strict';
|
||||||
const path = require('path')
|
|
||||||
const rimraf = require('rimraf')
|
const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller;
|
||||||
|
const path = require('path');
|
||||||
|
const rimraf = require('rimraf');
|
||||||
|
|
||||||
const archList = ['ia32', 'x64'];
|
const archList = ['ia32', 'x64'];
|
||||||
archList.forEach((arch) => {
|
archList.forEach((arch) => {
|
||||||
@@ -10,14 +12,14 @@ archList.forEach((arch) => {
|
|||||||
.then(getInstallerConfig)
|
.then(getInstallerConfig)
|
||||||
.then(createWindowsInstaller)
|
.then(createWindowsInstaller)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error.message || error)
|
console.error(error.message || error);
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
function getInstallerConfig(arch) {
|
function getInstallerConfig(arch) {
|
||||||
const rootPath = path.join(__dirname, '..')
|
const rootPath = path.join(__dirname, '..');
|
||||||
const outPath = path.join(rootPath, 'release')
|
const outPath = path.join(rootPath, 'release');
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
appDirectory: path.join(outPath, `Mattermost-win32-${arch}`),
|
appDirectory: path.join(outPath, `Mattermost-win32-${arch}`),
|
||||||
@@ -31,13 +33,13 @@ function getInstallerConfig(arch) {
|
|||||||
setupIcon: path.join(rootPath, 'resources', 'icon.ico'),
|
setupIcon: path.join(rootPath, 'resources', 'icon.ico'),
|
||||||
skipUpdateIcon: true,
|
skipUpdateIcon: true,
|
||||||
exe: 'Mattermost.exe'
|
exe: 'Mattermost.exe'
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteOutputFolder(arch) {
|
function deleteOutputFolder(arch) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
rimraf(path.join(__dirname, '..', 'out', `windows-installer-${arch}`), (error) => {
|
rimraf(path.join(__dirname, '..', 'out', `windows-installer-${arch}`), (error) => {
|
||||||
error ? reject(error) : resolve(arch)
|
error ? reject(error) : resolve(arch);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ var createDataURL = function(text) {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
|
||||||
// text
|
// text
|
||||||
ctx.fillStyle = "#ffffff"
|
ctx.fillStyle = "#ffffff";
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
ctx.font = (11 * scale) + "px sans-serif";
|
ctx.font = (11 * scale) + "px sans-serif";
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
const OriginalNotification = Notification;
|
const OriginalNotification = Notification;
|
||||||
|
|
||||||
const appIconURL = `file:///${require('electron').remote.app.getAppPath()}/resources/appicon.png`;
|
const appIconURL = `file:///${require('electron').remote.app.getAppPath()}/resources/appicon.png`;
|
||||||
@@ -64,9 +66,9 @@ function override(eventHandlers) {
|
|||||||
else {
|
else {
|
||||||
originalCallback();
|
originalCallback();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
defineEventHandler('onclick', eventHandlers.onclick);
|
defineEventHandler('onclick', eventHandlers.onclick);
|
||||||
defineEventHandler('onerror', eventHandlers.onerror);
|
defineEventHandler('onerror', eventHandlers.onerror);
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ var createDefault = function() {
|
|||||||
role: 'selectall'
|
role: 'selectall'
|
||||||
}));
|
}));
|
||||||
return menu;
|
return menu;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createDefault: createDefault
|
createDefault: createDefault
|
||||||
|
@@ -6,7 +6,7 @@ const notification = require('../js/notification');
|
|||||||
|
|
||||||
window.eval = global.eval = function() {
|
window.eval = global.eval = function() {
|
||||||
throw new Error("Sorry, Mattermost does not support window.eval() for security reasons.");
|
throw new Error("Sorry, Mattermost does not support window.eval() for security reasons.");
|
||||||
}
|
};
|
||||||
|
|
||||||
var hasClass = function(element, className) {
|
var hasClass = function(element, className) {
|
||||||
var rclass = /[\t\r\n\f]/g;
|
var rclass = /[\t\r\n\f]/g;
|
||||||
@@ -16,7 +16,7 @@ var hasClass = function(element, className) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
var unreadCountTimer = setInterval(function() {
|
setInterval(function() {
|
||||||
if (!this.unreadCount) {
|
if (!this.unreadCount) {
|
||||||
this.unreadCount = 0;
|
this.unreadCount = 0;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ var unreadCountTimer = setInterval(function() {
|
|||||||
// Note: the active channel doesn't have '.unread-title'.
|
// Note: the active channel doesn't have '.unread-title'.
|
||||||
var unreadCount = document.getElementsByClassName('unread-title').length;
|
var unreadCount = document.getElementsByClassName('unread-title').length;
|
||||||
// mentionCount in sidebar
|
// mentionCount in sidebar
|
||||||
var elem = document.getElementsByClassName('badge')
|
var elem = document.getElementsByClassName('badge');
|
||||||
var mentionCount = 0;
|
var mentionCount = 0;
|
||||||
for (var i = 0; i < elem.length; i++) {
|
for (var i = 0; i < elem.length; i++) {
|
||||||
if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) {
|
if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) {
|
||||||
@@ -50,9 +50,9 @@ var unreadCountTimer = setInterval(function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var post = null;
|
var post = null;
|
||||||
for (var i = 0; i < postLists.length; i++) {
|
for (var j = 0; j < postLists.length; j++) {
|
||||||
if (isElementVisible(postLists[i])) {
|
if (isElementVisible(postLists[j])) {
|
||||||
post = postLists[i].children[0];
|
post = postLists[j].children[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (post === null) {
|
if (post === null) {
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
var release_split = os.release().split('.');
|
var release_split = os.release().split('.');
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ var merge = function(base, target) {
|
|||||||
|
|
||||||
var loadDefault = function(version) {
|
var loadDefault = function(version) {
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
version = settingsVersion
|
version = settingsVersion;
|
||||||
}
|
}
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -34,7 +34,7 @@ var loadDefault = function(version) {
|
|||||||
showUnreadBadge: true
|
showUnreadBadge: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var upgradeV0toV1 = function(config_v0) {
|
var upgradeV0toV1 = function(config_v0) {
|
||||||
var config = loadDefault(1);
|
var config = loadDefault(1);
|
||||||
|
10
src/main.js
10
src/main.js
@@ -54,7 +54,7 @@ if (argv['config-file']) {
|
|||||||
global['config-file'] = argv['config-file'];
|
global['config-file'] = argv['config-file'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
global['config-file'] = app.getPath('userData') + '/config.json'
|
global['config-file'] = app.getPath('userData') + '/config.json';
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = {};
|
var config = {};
|
||||||
@@ -136,7 +136,7 @@ if (app.makeSingleInstance((commandLine, workingDirectory) => {
|
|||||||
else mainWindow.show();
|
else mainWindow.show();
|
||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
app.quit()
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldShowTrayIcon() {
|
function shouldShowTrayIcon() {
|
||||||
@@ -220,7 +220,7 @@ ipcMain.on('login-credentials', function(event, request, user, password) {
|
|||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback(user, password);
|
callback(user, password);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
app.on('login', function(event, webContents, request, authInfo, callback) {
|
app.on('login', function(event, webContents, request, authInfo, callback) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -283,7 +283,7 @@ app.on('ready', function() {
|
|||||||
});
|
});
|
||||||
trayIcon.on('balloon-click', function() {
|
trayIcon.on('balloon-click', function() {
|
||||||
if (process.platform === 'win32' || process.platform === 'darwin') {
|
if (process.platform === 'win32' || process.platform === 'darwin') {
|
||||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||||
else mainWindow.show();
|
else mainWindow.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +360,7 @@ app.on('ready', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.on('unresponsive', () => {
|
mainWindow.on('unresponsive', () => {
|
||||||
console.log('The application has become unresponsive.')
|
console.log('The application has become unresponsive.');
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.setFullScreenable(true); // fullscreenable option has no effect.
|
mainWindow.setFullScreenable(true); // fullscreenable option has no effect.
|
||||||
|
@@ -25,7 +25,7 @@ function getHost(targetURL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var CertificateStore = function(storeFile) {
|
var CertificateStore = function(storeFile) {
|
||||||
this.storeFile = storeFile
|
this.storeFile = storeFile;
|
||||||
try {
|
try {
|
||||||
this.data = JSON.parse(fs.readFileSync(storeFile, 'utf-8'));
|
this.data = JSON.parse(fs.readFileSync(storeFile, 'utf-8'));
|
||||||
}
|
}
|
||||||
|
@@ -177,7 +177,7 @@ var createTemplate = function(mainWindow, config) {
|
|||||||
},
|
},
|
||||||
enabled: (config.teams.length > 1)
|
enabled: (config.teams.length > 1)
|
||||||
}]
|
}]
|
||||||
}
|
};
|
||||||
template.push(window_menu);
|
template.push(window_menu);
|
||||||
|
|
||||||
template.push({
|
template.push({
|
||||||
@@ -185,7 +185,7 @@ var createTemplate = function(mainWindow, config) {
|
|||||||
submenu: [{
|
submenu: [{
|
||||||
label: `${app_name} Docs`,
|
label: `${app_name} Docs`,
|
||||||
click: function() {
|
click: function() {
|
||||||
electron.shell.openExternal('http://docs.mattermost.com')
|
electron.shell.openExternal('http://docs.mattermost.com');
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
|
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
app,
|
app,
|
||||||
Menu,
|
Menu
|
||||||
MenuItem
|
|
||||||
} = require('electron');
|
} = require('electron');
|
||||||
|
|
||||||
function createTemplate(mainWindow, config) {
|
function createTemplate(mainWindow, config) {
|
||||||
@@ -48,7 +47,7 @@ var createMenu = function(mainWindow, config) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function showOrRestore(window) {
|
function showOrRestore(window) {
|
||||||
window.isMinimized() ? window.restore() : window.show()
|
window.isMinimized() ? window.restore() : window.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Reference in New Issue
Block a user