Apply no-var eslint rule

This commit is contained in:
Yuya Ochiai 2018-09-03 21:41:04 +09:00
parent d69bf3aa5e
commit d73f98825e
16 changed files with 92 additions and 89 deletions

View file

@ -17,6 +17,7 @@
"no-console": 0, "no-console": 0,
"no-process-env": 0, "no-process-env": 0,
"no-underscore-dangle": 1, "no-underscore-dangle": 1,
"no-var": 2,
"react/jsx-indent": [2, 2], "react/jsx-indent": [2, 2],
"react/jsx-indent-props": [2, 2], "react/jsx-indent-props": [2, 2],
"react/no-set-state": 1, "react/no-set-state": 1,

View file

@ -22,7 +22,7 @@ export default class LoginModal extends React.Component {
} }
render() { render() {
var theServer = ''; let theServer = '';
if (!this.props.show) { if (!this.props.show) {
theServer = ''; theServer = '';
} else if (this.props.authInfo.isProxy) { } else if (this.props.authInfo.isProxy) {

View file

@ -38,7 +38,7 @@ const MainPage = createReactClass({
getInitialState() { getInitialState() {
let key = this.props.initialIndex; let key = this.props.initialIndex;
if (this.props.deeplinkingUrl !== null) { if (this.props.deeplinkingUrl !== null) {
for (var i = 0; i < this.props.teams.length; i++) { for (let i = 0; i < this.props.teams.length; i++) {
if (this.props.deeplinkingUrl.includes(this.props.teams[i].url)) { if (this.props.deeplinkingUrl.includes(this.props.teams[i].url)) {
key = i; key = i;
break; break;
@ -57,7 +57,7 @@ const MainPage = createReactClass({
}; };
}, },
componentDidMount() { componentDidMount() {
var self = this; const self = this;
ipcRenderer.on('login-request', (event, request, authInfo) => { ipcRenderer.on('login-request', (event, request, authInfo) => {
self.setState({ self.setState({
loginRequired: true, loginRequired: true,
@ -96,7 +96,7 @@ const MainPage = createReactClass({
self.refs[`mattermostView${self.state.key}`].focusOnWebView(); self.refs[`mattermostView${self.state.key}`].focusOnWebView();
} }
var currentWindow = remote.getCurrentWindow(); const currentWindow = remote.getCurrentWindow();
currentWindow.on('focus', focusListener); currentWindow.on('focus', focusListener);
window.addEventListener('beforeunload', () => { window.addEventListener('beforeunload', () => {
currentWindow.removeListener('focus', focusListener); currentWindow.removeListener('focus', focusListener);
@ -132,7 +132,7 @@ const MainPage = createReactClass({
ipcRenderer.on('protocol-deeplink', (event, deepLinkUrl) => { ipcRenderer.on('protocol-deeplink', (event, deepLinkUrl) => {
const lastUrlDomain = Utils.getDomain(deepLinkUrl); const lastUrlDomain = Utils.getDomain(deepLinkUrl);
for (var i = 0; i < this.props.teams.length; i++) { for (let i = 0; i < this.props.teams.length; i++) {
if (lastUrlDomain === Utils.getDomain(self.refs[`mattermostView${i}`].getSrc())) { if (lastUrlDomain === Utils.getDomain(self.refs[`mattermostView${i}`].getSrc())) {
if (this.state.key !== i) { if (this.state.key !== i) {
this.handleSelect(i); this.handleSelect(i);
@ -158,7 +158,7 @@ const MainPage = createReactClass({
key: newKey, key: newKey,
finderVisible: false, finderVisible: false,
}); });
var webview = document.getElementById('mattermostView' + newKey); const webview = document.getElementById('mattermostView' + newKey);
ipcRenderer.send('update-title', { ipcRenderer.send('update-title', {
title: webview.getTitle(), title: webview.getTitle(),
}); });
@ -166,10 +166,10 @@ const MainPage = createReactClass({
}, },
handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned) { handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned) {
var unreadCounts = this.state.unreadCounts; const unreadCounts = this.state.unreadCounts;
var mentionCounts = this.state.mentionCounts; const mentionCounts = this.state.mentionCounts;
var unreadAtActive = this.state.unreadAtActive; const unreadAtActive = this.state.unreadAtActive;
var mentionAtActiveCounts = this.state.mentionAtActiveCounts; const mentionAtActiveCounts = this.state.mentionAtActiveCounts;
unreadCounts[index] = unreadCount; unreadCounts[index] = unreadCount;
mentionCounts[index] = mentionCount; mentionCounts[index] = mentionCount;
@ -189,8 +189,8 @@ const MainPage = createReactClass({
this.handleUnreadCountTotalChange(); this.handleUnreadCountTotalChange();
}, },
markReadAtActive(index) { markReadAtActive(index) {
var unreadAtActive = this.state.unreadAtActive; const unreadAtActive = this.state.unreadAtActive;
var mentionAtActiveCounts = this.state.mentionAtActiveCounts; const mentionAtActiveCounts = this.state.mentionAtActiveCounts;
unreadAtActive[index] = false; unreadAtActive[index] = false;
mentionAtActiveCounts[index] = 0; mentionAtActiveCounts[index] = 0;
this.setState({ this.setState({
@ -201,7 +201,7 @@ const MainPage = createReactClass({
}, },
handleUnreadCountTotalChange() { handleUnreadCountTotalChange() {
if (this.props.onUnreadCountChange) { if (this.props.onUnreadCountChange) {
var allUnreadCount = this.state.unreadCounts.reduce((prev, curr) => { let allUnreadCount = this.state.unreadCounts.reduce((prev, curr) => {
return prev + curr; return prev + curr;
}, 0); }, 0);
this.state.unreadAtActive.forEach((state) => { this.state.unreadAtActive.forEach((state) => {
@ -209,7 +209,7 @@ const MainPage = createReactClass({
allUnreadCount += 1; allUnreadCount += 1;
} }
}); });
var allMentionCount = this.state.mentionCounts.reduce((prev, curr) => { let allMentionCount = this.state.mentionCounts.reduce((prev, curr) => {
return prev + curr; return prev + curr;
}, 0); }, 0);
this.state.mentionAtActiveCounts.forEach((count) => { this.state.mentionAtActiveCounts.forEach((count) => {
@ -277,8 +277,8 @@ const MainPage = createReactClass({
}, },
render() { render() {
var self = this; const self = this;
var tabsRow; let tabsRow;
if (this.props.teams.length > 1) { if (this.props.teams.length > 1) {
tabsRow = ( tabsRow = (
<Row> <Row>
@ -300,15 +300,15 @@ const MainPage = createReactClass({
); );
} }
var views = this.props.teams.map((team, index) => { const views = this.props.teams.map((team, index) => {
function handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned) { function handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned) {
self.handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned); self.handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned);
} }
function handleNotificationClick() { function handleNotificationClick() {
self.handleSelect(index); self.handleSelect(index);
} }
var id = 'mattermostView' + index; const id = 'mattermostView' + index;
var isActive = self.state.key === index; const isActive = self.state.key === index;
let teamUrl = team.url; let teamUrl = team.url;
const deeplinkingUrl = this.props.deeplinkingUrl; const deeplinkingUrl = this.props.deeplinkingUrl;
@ -332,21 +332,21 @@ const MainPage = createReactClass({
active={isActive} active={isActive}
/>); />);
}); });
var viewsRow = ( const viewsRow = (
<Row> <Row>
{views} {views}
</Row>); </Row>);
var request = null; let request = null;
var authServerURL = null; let authServerURL = null;
var authInfo = null; let authInfo = null;
if (this.state.loginQueue.length !== 0) { if (this.state.loginQueue.length !== 0) {
request = this.state.loginQueue[0].request; request = this.state.loginQueue[0].request;
const tmpURL = url.parse(this.state.loginQueue[0].request.url); const tmpURL = url.parse(this.state.loginQueue[0].request.url);
authServerURL = `${tmpURL.protocol}//${tmpURL.host}`; authServerURL = `${tmpURL.protocol}//${tmpURL.host}`;
authInfo = this.state.loginQueue[0].authInfo; authInfo = this.state.loginQueue[0].authInfo;
} }
var modal = ( const modal = (
<NewTeamModal <NewTeamModal
show={this.state.showNewTeamModal} show={this.state.showNewTeamModal}
onClose={() => { onClose={() => {

View file

@ -72,8 +72,8 @@ const MattermostView = createReactClass({
}, },
componentDidMount() { componentDidMount() {
var self = this; const self = this;
var webview = findDOMNode(this.refs.webview); const webview = findDOMNode(this.refs.webview);
webview.addEventListener('did-fail-load', (e) => { webview.addEventListener('did-fail-load', (e) => {
console.log(self.props.name, 'webview did-fail-load', e); console.log(self.props.name, 'webview did-fail-load', e);
@ -105,8 +105,8 @@ const MattermostView = createReactClass({
// Open link in browserWindow. for exmaple, attached files. // Open link in browserWindow. for exmaple, attached files.
webview.addEventListener('new-window', (e) => { webview.addEventListener('new-window', (e) => {
var currentURL = url.parse(webview.getURL()); const currentURL = url.parse(webview.getURL());
var destURL = url.parse(e.url); const destURL = url.parse(e.url);
if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:' && destURL.protocol !== `${scheme}:`) { if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:' && destURL.protocol !== `${scheme}:`) {
ipcRenderer.send('confirm-protocol', destURL.protocol, e.url); ipcRenderer.send('confirm-protocol', destURL.protocol, e.url);
return; return;
@ -157,15 +157,17 @@ const MattermostView = createReactClass({
isLoaded: true, isLoaded: true,
}); });
break; break;
case 'onUnreadCountChange': case 'onUnreadCountChange': {
var unreadCount = event.args[0]; const unreadCount = event.args[0];
var mentionCount = event.args[1]; const mentionCount = event.args[1];
// isUnread and isMentioned is pulse flag. // isUnread and isMentioned is pulse flag.
var isUnread = event.args[2]; const isUnread = event.args[2];
var isMentioned = event.args[3]; const isMentioned = event.args[3];
self.handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned); self.handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned);
break; break;
}
case 'onNotificationClick': case 'onNotificationClick':
self.props.onNotificationClick(); self.props.onNotificationClick();
break; break;
@ -216,7 +218,7 @@ const MattermostView = createReactClass({
reloadTimeoutID: null, reloadTimeoutID: null,
isLoaded: false, isLoaded: false,
}); });
var webview = findDOMNode(this.refs.webview); const webview = findDOMNode(this.refs.webview);
webview.reload(); webview.reload();
}, },
@ -224,7 +226,7 @@ const MattermostView = createReactClass({
this.setState({ this.setState({
errorInfo: null, errorInfo: null,
}); });
var webContents = findDOMNode(this.refs.webview).getWebContents(); const webContents = findDOMNode(this.refs.webview).getWebContents();
webContents.session.clearCache(() => { webContents.session.clearCache(() => {
webContents.reload(); webContents.reload();
}); });

View file

@ -38,7 +38,7 @@ const SettingsPage = createReactClass({
}, },
getInitialState() { getInitialState() {
var initialState; let initialState;
try { try {
initialState = settings.readFileSync(this.props.configFile); initialState = settings.readFileSync(this.props.configFile);
} catch (e) { } catch (e) {
@ -59,7 +59,7 @@ const SettingsPage = createReactClass({
}, },
componentDidMount() { componentDidMount() {
if (process.platform === 'win32' || process.platform === 'linux') { if (process.platform === 'win32' || process.platform === 'linux') {
var self = this; const self = this;
appLauncher.isEnabled().then((enabled) => { appLauncher.isEnabled().then((enabled) => {
self.setState({ self.setState({
autostart: enabled, autostart: enabled,
@ -125,7 +125,7 @@ const SettingsPage = createReactClass({
}, },
saveConfig(callback) { saveConfig(callback) {
var config = { const config = {
teams: this.state.teams, teams: this.state.teams,
showTrayIcon: this.state.showTrayIcon, showTrayIcon: this.state.showTrayIcon,
trayIconTheme: this.state.trayIconTheme, trayIconTheme: this.state.trayIconTheme,
@ -178,7 +178,7 @@ const SettingsPage = createReactClass({
backToIndex(); backToIndex();
}, },
handleChangeShowTrayIcon() { handleChangeShowTrayIcon() {
var shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked; const shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked;
this.setState({ this.setState({
showTrayIcon: shouldShowTrayIcon, showTrayIcon: shouldShowTrayIcon,
}); });
@ -271,7 +271,7 @@ const SettingsPage = createReactClass({
}, },
updateTeam(index, newData) { updateTeam(index, newData) {
var teams = this.state.teams; const teams = this.state.teams;
teams[index] = newData; teams[index] = newData;
this.setState({ this.setState({
teams, teams,
@ -280,7 +280,7 @@ const SettingsPage = createReactClass({
}, },
addServer(team) { addServer(team) {
var teams = this.state.teams; const teams = this.state.teams;
teams.push(team); teams.push(team);
this.setState({ this.setState({
teams, teams,
@ -324,7 +324,7 @@ const SettingsPage = createReactClass({
}, },
}; };
var teamsRow = ( const teamsRow = (
<Row> <Row>
<Col md={12}> <Col md={12}>
<TeamList <TeamList
@ -344,7 +344,7 @@ const SettingsPage = createReactClass({
</Row> </Row>
); );
var serversRow = ( const serversRow = (
<Row> <Row>
<Col <Col
md={10} md={10}
@ -375,7 +375,7 @@ const SettingsPage = createReactClass({
</Row> </Row>
); );
var srvMgmt; let srvMgmt;
if (this.props.enableServerManagement === true) { if (this.props.enableServerManagement === true) {
srvMgmt = ( srvMgmt = (
<div> <div>
@ -386,7 +386,7 @@ const SettingsPage = createReactClass({
); );
} }
var options = []; const options = [];
// MacOS has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX // MacOS has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX
if (process.platform === 'win32' || process.platform === 'linux') { if (process.platform === 'win32' || process.platform === 'linux') {
@ -576,7 +576,7 @@ const SettingsPage = createReactClass({
</Checkbox> </Checkbox>
); );
var optionsRow = (options.length > 0) ? ( const optionsRow = (options.length > 0) ? (
<Row> <Row>
<Col md={12}> <Col md={12}>
<h2 style={settingsPage.sectionHeading}>{'App Options'}</h2> <h2 style={settingsPage.sectionHeading}>{'App Options'}</h2>

View file

@ -35,12 +35,12 @@ const TeamList = createReactClass({
}, },
handleTeamRemove(index) { handleTeamRemove(index) {
console.log(index); console.log(index);
var teams = this.props.teams; const teams = this.props.teams;
teams.splice(index, 1); teams.splice(index, 1);
this.props.onTeamsChange(teams); this.props.onTeamsChange(teams);
}, },
handleTeamAdd(team) { handleTeamAdd(team) {
var teams = this.props.teams; const teams = this.props.teams;
// check if team already exists and then change existing team or add new one // check if team already exists and then change existing team or add new one
if ((typeof team.index !== 'undefined') && teams[team.index]) { if ((typeof team.index !== 'undefined') && teams[team.index]) {
@ -81,8 +81,8 @@ const TeamList = createReactClass({
}, },
render() { render() {
var self = this; const self = this;
var teamNodes = this.props.teams.map((team, i) => { const teamNodes = this.props.teams.map((team, i) => {
function handleTeamRemove() { function handleTeamRemove() {
document.activeElement.blur(); document.activeElement.blur();
self.openServerRemoveModal(i); self.openServerRemoveModal(i);
@ -110,7 +110,7 @@ const TeamList = createReactClass({
); );
}); });
var addServerForm = ( const addServerForm = (
<NewTeamModal <NewTeamModal
show={this.props.showAddTeamForm || this.state.showEditTeamForm} show={this.props.showAddTeamForm || this.state.showEditTeamForm}
editMode={this.state.showEditTeamForm} editMode={this.state.showEditTeamForm}
@ -126,7 +126,7 @@ const TeamList = createReactClass({
this.props.setAddTeamFormVisibility(false); this.props.setAddTeamFormVisibility(false);
}} }}
onSave={(newTeam) => { onSave={(newTeam) => {
var teamData = { const teamData = {
name: newTeam.name, name: newTeam.name,
url: newTeam.url, url: newTeam.url,
}; };

View file

@ -51,7 +51,7 @@ window.addEventListener('load', () => {
}); });
function hasClass(element, className) { function hasClass(element, className) {
var rclass = /[\t\r\n\f]/g; const rclass = /[\t\r\n\f]/g;
if ((' ' + element.className + ' ').replace(rclass, ' ').indexOf(className) > -1) { if ((' ' + element.className + ' ').replace(rclass, ' ').indexOf(className) > -1) {
return true; return true;
} }
@ -77,7 +77,7 @@ function getUnreadCount() {
// unreadCount in sidebar // unreadCount in sidebar
// 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; let unreadCount = document.getElementsByClassName('unread-title').length;
// unreadCount in team sidebar // unreadCount in team sidebar
const teamSideBar = document.getElementsByClassName('team-sidebar'); // team-sidebar doesn't have id const teamSideBar = document.getElementsByClassName('team-sidebar'); // team-sidebar doesn't have id
@ -86,30 +86,30 @@ function getUnreadCount() {
} }
// mentionCount in sidebar // mentionCount in sidebar
var elem = document.getElementsByClassName('badge'); const elem = document.getElementsByClassName('badge');
var mentionCount = 0; let mentionCount = 0;
for (var i = 0; i < elem.length; i++) { for (let i = 0; i < elem.length; i++) {
if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) { if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) {
mentionCount += Number(elem[i].innerHTML); mentionCount += Number(elem[i].innerHTML);
} }
} }
var postAttrName = 'data-reactid'; const postAttrName = 'data-reactid';
var lastPostElem = document.querySelector('div[' + postAttrName + '="' + this.lastCheckedPostId + '"]'); const lastPostElem = document.querySelector('div[' + postAttrName + '="' + this.lastCheckedPostId + '"]');
var isUnread = false; let isUnread = false;
var isMentioned = false; let isMentioned = false;
if (lastPostElem === null || !isElementVisible(lastPostElem)) { if (lastPostElem === null || !isElementVisible(lastPostElem)) {
// When load channel or change channel, this.lastCheckedPostId is invalid. // When load channel or change channel, this.lastCheckedPostId is invalid.
// So we get latest post and save lastCheckedPostId. // So we get latest post and save lastCheckedPostId.
// find active post-list. // find active post-list.
var postLists = document.querySelectorAll('div.post-list__content'); const postLists = document.querySelectorAll('div.post-list__content');
if (postLists.length === 0) { if (postLists.length === 0) {
setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL); setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL);
return; return;
} }
var post = null; let post = null;
for (var j = 0; j < postLists.length; j++) { for (let j = 0; j < postLists.length; j++) {
if (isElementVisible(postLists[j])) { if (isElementVisible(postLists[j])) {
post = postLists[j].children[0]; post = postLists[j].children[0];
} }
@ -130,19 +130,19 @@ function getUnreadCount() {
post = post.nextSibling; post = post.nextSibling;
} }
} else if (lastPostElem !== null) { } else if (lastPostElem !== null) {
var newPostElem = lastPostElem.nextSibling; let newPostElem = lastPostElem.nextSibling;
while (newPostElem) { while (newPostElem) {
this.lastCheckedPostId = newPostElem.getAttribute(postAttrName); this.lastCheckedPostId = newPostElem.getAttribute(postAttrName);
isUnread = true; isUnread = true;
var activeChannel = document.querySelector('.active .sidebar-channel'); const activeChannel = document.querySelector('.active .sidebar-channel');
var closeButton = activeChannel.getElementsByClassName('btn-close'); const closeButton = activeChannel.getElementsByClassName('btn-close');
if (closeButton.length === 1 && closeButton[0].getAttribute('aria-describedby') === 'remove-dm-tooltip') { if (closeButton.length === 1 && closeButton[0].getAttribute('aria-describedby') === 'remove-dm-tooltip') {
// If active channel is DM, all posts is treated as menion. // If active channel is DM, all posts is treated as menion.
isMentioned = true; isMentioned = true;
break; break;
} else { } else {
// If active channel is public/private channel, only mentioned post is treated as mention. // If active channel is public/private channel, only mentioned post is treated as mention.
var highlight = newPostElem.getElementsByClassName('mention-highlight'); const highlight = newPostElem.getElementsByClassName('mention-highlight');
if (highlight.length !== 0 && isElementVisible(highlight[0])) { if (highlight.length !== 0 && isElementVisible(highlight[0])) {
isMentioned = true; isMentioned = true;
break; break;

View file

@ -20,7 +20,7 @@ function upgradeV0toV1(configV0) {
} }
export default function upgradeToLatest(config) { export default function upgradeToLatest(config) {
var configVersion = config.version ? config.version : 0; const configVersion = config.version ? config.version : 0;
switch (configVersion) { switch (configVersion) {
case 0: case 0:
return upgradeToLatest(upgradeV0toV1(config)); return upgradeToLatest(upgradeV0toV1(config));

View file

@ -4,7 +4,7 @@
'use strict'; 'use strict';
import os from 'os'; import os from 'os';
var releaseSplit = os.release().split('.'); const releaseSplit = os.release().split('.');
export default { export default {
major: parseInt(releaseSplit[0], 10), major: parseInt(releaseSplit[0], 10),

View file

@ -45,7 +45,7 @@ export default {
if (config.version !== defaultPreferences.version) { if (config.version !== defaultPreferences.version) {
throw new Error('version ' + config.version + ' is not equal to ' + defaultPreferences.version); throw new Error('version ' + config.version + ' is not equal to ' + defaultPreferences.version);
} }
var data = JSON.stringify(config, null, ' '); const data = JSON.stringify(config, null, ' ');
fs.writeFile(configFile, data, 'utf8', callback); fs.writeFile(configFile, data, 'utf8', callback);
}, },
@ -59,7 +59,7 @@ export default {
fs.mkdirSync(dir); fs.mkdirSync(dir);
} }
var data = JSON.stringify(config, null, ' '); const data = JSON.stringify(config, null, ' ');
fs.writeFileSync(configFile, data, 'utf8'); fs.writeFileSync(configFile, data, 'utf8');
}, },

View file

@ -58,7 +58,7 @@ const assetsDir = path.resolve(app.getAppPath(), 'assets');
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected. // be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null; let mainWindow = null;
let spellChecker = null; let spellChecker = null;
let deeplinkingUrl = null; let deeplinkingUrl = null;
let scheme = null; let scheme = null;
@ -74,7 +74,7 @@ if (argv['data-dir']) {
global.isDev = isDev && !argv.disableDevMode; global.isDev = isDev && !argv.disableDevMode;
var config = {}; let config = {};
try { try {
const configFile = app.getPath('userData') + '/config.json'; const configFile = app.getPath('userData') + '/config.json';
config = settings.readFileSync(configFile); config = settings.readFileSync(configFile);
@ -117,7 +117,7 @@ function switchMenuIconImages(icons, isDarkMode) {
} }
} }
var trayIcon = null; let trayIcon = null;
const trayImages = (() => { const trayImages = (() => {
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':
@ -293,7 +293,7 @@ app.on('certificate-error', (event, webContents, url, error, certificate, callba
event.preventDefault(); event.preventDefault();
callback(true); callback(true);
} else { } else {
var detail = `URL: ${url}\nError: ${error}`; let detail = `URL: ${url}\nError: ${error}`;
if (certificateStore.isExisting(url)) { if (certificateStore.isExisting(url)) {
detail = 'Certificate is different from previous one.\n\n' + detail; detail = 'Certificate is different from previous one.\n\n' + detail;
} }
@ -543,8 +543,8 @@ app.on('ready', () => {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
session.defaultSession.on('will-download', (event, item) => { session.defaultSession.on('will-download', (event, item) => {
var filename = item.getFilename(); const filename = item.getFilename();
var savePath = dialog.showSaveDialog({ const savePath = dialog.showSaveDialog({
title: filename, title: filename,
defaultPath: os.homedir() + '/Downloads/' + filename, defaultPath: os.homedir() + '/Downloads/' + filename,
}); });
@ -559,7 +559,7 @@ app.on('ready', () => {
// Set application menu // Set application menu
ipcMain.on('update-menu', (event, configData) => { ipcMain.on('update-menu', (event, configData) => {
var aMenu = appMenu.createMenu(mainWindow, configData, global.isDev); const aMenu = appMenu.createMenu(mainWindow, configData, global.isDev);
Menu.setApplicationMenu(aMenu); Menu.setApplicationMenu(aMenu);
// set up context menu for tray icon // set up context menu for tray icon

View file

@ -9,7 +9,7 @@ import fs from 'fs';
import {app, dialog, ipcMain, shell} from 'electron'; import {app, dialog, ipcMain, shell} from 'electron';
const allowedProtocolFile = path.resolve(app.getPath('userData'), 'allowedProtocols.json'); const allowedProtocolFile = path.resolve(app.getPath('userData'), 'allowedProtocols.json');
var allowedProtocols = []; let allowedProtocols = [];
function init(mainWindow) { function init(mainWindow) {
fs.readFile(allowedProtocolFile, 'utf-8', (err, data) => { fs.readFile(allowedProtocolFile, 'utf-8', (err, data) => {

View file

@ -56,7 +56,7 @@ CertificateStore.prototype.isExisting = function isExisting(targetURL) {
}; };
CertificateStore.prototype.isTrusted = function isTrusted(targetURL, certificate) { CertificateStore.prototype.isTrusted = function isTrusted(targetURL, certificate) {
var host = getHost(targetURL); const host = getHost(targetURL);
if (!this.isExisting(targetURL)) { if (!this.isExisting(targetURL)) {
return false; return false;
} }

View file

@ -7,7 +7,7 @@ import path from 'path';
import {app, BrowserWindow} from 'electron'; import {app, BrowserWindow} from 'electron';
function saveWindowState(file, window) { function saveWindowState(file, window) {
var windowState = window.getBounds(); const windowState = window.getBounds();
windowState.maximized = window.isMaximized(); windowState.maximized = window.isMaximized();
windowState.fullscreen = window.isFullScreen(); windowState.fullscreen = window.isFullScreen();
try { try {
@ -26,7 +26,7 @@ function createMainWindow(config, options) {
// Create the browser window. // Create the browser window.
const boundsInfoPath = path.join(app.getPath('userData'), 'bounds-info.json'); const boundsInfoPath = path.join(app.getPath('userData'), 'bounds-info.json');
var windowOptions; let windowOptions;
try { try {
windowOptions = JSON.parse(fs.readFileSync(boundsInfoPath, 'utf-8')); windowOptions = JSON.parse(fs.readFileSync(boundsInfoPath, 'utf-8'));
} catch (e) { } catch (e) {

View file

@ -15,11 +15,11 @@ function createTemplate(mainWindow, config, isDev) {
type: 'separator', type: 'separator',
}; };
var appName = app.getName(); const appName = app.getName();
var firstMenuName = (process.platform === 'darwin') ? appName : 'File'; const firstMenuName = (process.platform === 'darwin') ? appName : 'File';
var template = []; const template = [];
var platformAppMenu = process.platform === 'darwin' ? [{ let platformAppMenu = process.platform === 'darwin' ? [{
label: 'About ' + appName, label: 'About ' + appName,
role: 'about', role: 'about',
click() { click() {
@ -217,7 +217,7 @@ function createTemplate(mainWindow, config, isDev) {
}], }],
}; };
template.push(windowMenu); template.push(windowMenu);
var submenu = []; const submenu = [];
if (buildConfig.helpLink) { if (buildConfig.helpLink) {
submenu.push({ submenu.push({
label: 'Learn More...', label: 'Learn More...',

View file

@ -10,7 +10,7 @@ import settings from '../../common/settings';
function createTemplate(mainWindow, config, isDev) { function createTemplate(mainWindow, config, isDev) {
const settingsURL = isDev ? 'http://localhost:8080/browser/settings.html' : `file://${app.getAppPath()}/browser/settings.html`; const settingsURL = isDev ? 'http://localhost:8080/browser/settings.html' : `file://${app.getAppPath()}/browser/settings.html`;
const teams = settings.mergeDefaultTeams(config.teams); const teams = settings.mergeDefaultTeams(config.teams);
var template = [ const template = [
...teams.slice(0, 9).map((team, i) => { ...teams.slice(0, 9).map((team, i) => {
return { return {
label: team.name, label: team.name,