Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
[ESLint] autofix 'modules' (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
luclu authored and frozeman committed Dec 20, 2016
1 parent c26a303 commit 59b918f
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 80 deletions.
36 changes: 19 additions & 17 deletions modules/dbSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ exports.backendSyncInit = function () {

ipc.on('dbSync-add', (event, args) => {
let collName = args.collName,
coll = db.getCollection('UI_'+ collName);
coll = db.getCollection(`UI_${collName}`);

log.trace('dbSync-add', collName, args._id);

const _id = args._id;

if (!coll.by("_id", _id)) {
if (!coll.by('_id', _id)) {
args.fields._id = _id;
coll.insert(args.fields);
}
});

ipc.on('dbSync-changed', (event, args) => {
let collName = args.collName,
coll = db.getCollection('UI_'+ collName);
coll = db.getCollection(`UI_${collName}`);

log.trace('dbSync-changed', collName, args._id);

const _id = args._id;
const item = coll.by("_id", _id);
const item = coll.by('_id', _id);

if (item) {
for (const k in args.fields) {
Expand All @@ -50,12 +50,12 @@ exports.backendSyncInit = function () {

ipc.on('dbSync-removed', (event, args) => {
let collName = args.collName,
coll = db.getCollection('UI_'+ collName);
coll = db.getCollection(`UI_${collName}`);

log.trace('dbSync-removed', collName, args._id);

const _id = args._id;
const item = coll.by("_id", _id);
const item = coll.by('_id', _id);

if (item) {
coll.remove(item);
Expand All @@ -67,7 +67,7 @@ exports.backendSyncInit = function () {
// Get all data (synchronous)
ipc.on('dbSync-reloadSync', (event, args) => {
let collName = args.collName,
coll = db.getCollection('UI_'+ collName),
coll = db.getCollection(`UI_${collName}`),
docs = coll.find();

log.debug('dbSync-reloadSync, no. of docs:', collName, docs.length);
Expand All @@ -88,15 +88,15 @@ exports.backendSyncInit = function () {
});
};

var syncDataFromBackend = function(coll){
let ipc = ipcRenderer;
const syncDataFromBackend = function (coll) {
const ipc = ipcRenderer;

let collName = coll._name;
const collName = coll._name;

console.debug('Load collection data from backend: ', collName);

return new Promise((resolve, reject) => {
let dataJson = ipc.sendSync('dbSync-reloadSync', {
const dataJson = ipc.sendSync('dbSync-reloadSync', {
collName,
});

Expand All @@ -105,8 +105,9 @@ var syncDataFromBackend = function(coll){

coll.remove({});

if(!dataJson.length)
if (!dataJson.length) {
resolve();
}

// we do inserts slowly, to avoid race conditions when it comes
// to updating the UI
Expand All @@ -120,10 +121,11 @@ var syncDataFromBackend = function(coll){
record.redirect = null;
}

if(record._id)
if (record._id) {
coll.upsert(record._id, record);
else
} else {
coll.insert(record);
}
} catch (err) {
console.error(err.toString());
}
Expand All @@ -138,16 +140,16 @@ var syncDataFromBackend = function(coll){
} catch (err) {
reject(err);
}
})
});
};
exports.syncDataFromBackend = syncDataFromBackend;

exports.frontendSyncInit = function (coll) {
let ipc = ipcRenderer,
syncDoneResolver;

let collName = coll._name;
const collName = coll._name;

coll.onceSynced = new Promise((resolve, reject) => {
syncDoneResolver = resolve;
});
Expand Down
9 changes: 5 additions & 4 deletions modules/ethereumNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,14 @@ class EthereumNode extends EventEmitter {
this._network = network;
this._type = nodeType;

let client = ClientBinaryManager.getClient(nodeType);
const client = ClientBinaryManager.getClient(nodeType);
let binPath;

if(client)
if (client) {
binPath = client.binPath;
else
} else {
throw new Error(`Node "${nodeType}" binPath is not available.`);
}

log.info(`Start node using ${binPath}`);

Expand Down Expand Up @@ -358,7 +359,7 @@ class EthereumNode extends EventEmitter {
// START MAINNET
else {
args = (nodeType === 'geth')
? ['--fast', '--cache', '1024']
? ['--fast', '--cache', '1024']
: ['--unsafe-transactions'];
}

Expand Down
5 changes: 3 additions & 2 deletions modules/ipc/dechunker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ module.exports = class Dechunker {

return _.each(dechunkedData, (data) => {
// prepend the last chunk
if (this.lastChunk)
{ data = this.lastChunk + data; }
if (this.lastChunk) {
data = this.lastChunk + data;
}

let result = data;

Expand Down
14 changes: 8 additions & 6 deletions modules/ipc/ipcProviderBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ class IpcProviderBackend {

socket.destroy().finally(() => {

if(!owner.isDestroyed())
owner.send(`ipcProvider-${ev}`, JSON.stringify(data));
if (!owner.isDestroyed()) { owner.send(`ipcProvider-${ev}`, JSON.stringify(data)); }
});

delete this._connections[ownerId];
Expand All @@ -110,8 +109,9 @@ class IpcProviderBackend {
});

socket.on('connect', (data) => {
if(!owner.isDestroyed())
if (!owner.isDestroyed()) {
owner.send('ipcProvider-connect', JSON.stringify(data));
}
});

// pass notifications back up the chain
Expand All @@ -124,8 +124,9 @@ class IpcProviderBackend {
data = this._makeResponsePayload(data, data);
}

if(!owner.isDestroyed())
if (!owner.isDestroyed()) {
owner.send('ipcProvider-data', JSON.stringify(data));
}
});
}
})
Expand Down Expand Up @@ -172,8 +173,9 @@ class IpcProviderBackend {
}
})
.then(() => {
if(!owner.isDestroyed())
if (!owner.isDestroyed()) {
owner.send('ipcProvider-setWritable', true);
}

return this._connections[ownerId];
});
Expand Down Expand Up @@ -356,7 +358,7 @@ class IpcProviderBackend {

if (isSync) {
event.returnValue = returnValue;
} else if(!event.sender.isDestroyed()) {
} else if (!event.sender.isDestroyed()) {
event.sender.send('ipcProvider-data', returnValue);
}
});
Expand Down
3 changes: 1 addition & 2 deletions modules/ipc/methods/eth_sendTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ module.exports = class extends BaseProcessor {

ipc.once('backendAction_unlockedAccountAndSentTransaction', (ev, err, result) => {
if (Windows.getById(ev.sender.id) === modalWindow
&& !modalWindow.isClosed)
{
&& !modalWindow.isClosed) {
if (err || !result) {
this._log.debug('Confirmation error', err);

Expand Down
12 changes: 7 additions & 5 deletions modules/ipcCommunicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ipc.on('backendAction_windowCallback', (e, value1, value2, value3) => {
const windowId = e.sender.id;
const senderWindow = Windows.getById(windowId);

if(senderWindow.callback) {
if (senderWindow.callback) {
senderWindow.callback(value1, value2, value3);
}
});
Expand Down Expand Up @@ -100,10 +100,11 @@ ipc.on('backendAction_setLanguage', (e, lang) => {

ipc.on('backendAction_stopWebviewNavigation', (e, id) => {
console.log('webcontent ID', id);
var webContent = webContents.fromId(id);
const webContent = webContents.fromId(id);

if(webContent && !webContent.isDestroyed())
if (webContent && !webContent.isDestroyed()) {
webContent.stop();
}

e.returnValue = true;
});
Expand All @@ -126,8 +127,9 @@ ipc.on('backendAction_importPresaleFile', (e, path, pw) => {
});
nodeProcess.stdout.on('data', (data) => {
var data = data.toString();
if (data)
{ log.info('Imported presale: ', data); }
if (data) {
log.info('Imported presale: ', data);
}

if (/Decryption failed|not equal to expected addr|could not decrypt/.test(data)) {
e.sender.send('uiAction_importedPresaleFile', 'Decryption Failed');
Expand Down
3 changes: 1 addition & 2 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const ClientBinaryManager = require('./clientBinaryManager');
const switchForSystem = function (options) {
if (process.platform in options) {
return options[process.platform];
}
else if ('default' in options) {
} else if ('default' in options) {
return options.default;
}
};
Expand Down
2 changes: 1 addition & 1 deletion modules/preloader/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ipcRenderer.sendToHost('setWebviewId');
ipcRenderer.send('ipcProvider-destroy');

// Security
process.on('loaded',function () {
process.on('loaded', function () {
Object.freeze(window.JSON);
// Object.freeze(window.Function);
// Object.freeze(window.Function.prototype);
Expand Down
9 changes: 5 additions & 4 deletions modules/preloader/include/getFavicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const { ipcRenderer } = require('electron');
function DOMContentLoaded(event) {
const icon = document.querySelector('link[rel="apple-touch-icon"]') || document.querySelector('link[type="image/x-icon"]') || document.querySelector('link[rel="shortcut"]') || document.querySelector('link[rel="shortcut icon"]') || document.querySelector('link[rel="icon"]');

if (icon)
{ ipcRenderer.sendToHost('favicon', icon.href); }
else
{ ipcRenderer.sendToHost('favicon', null); }
if (icon) {
ipcRenderer.sendToHost('favicon', icon.href);
} else {
ipcRenderer.sendToHost('favicon', null);
}

document.removeEventListener('DOMContentLoaded', DOMContentLoaded, false);
}
Expand Down
11 changes: 6 additions & 5 deletions modules/preloader/include/getMetaTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ Gest the meta[name="ethereum-dapp-url-bar-style"] meta tag
@module getMetaTags
*/

const { ipcRenderer } = require('electron');
const { ipcRenderer } = require('electron');

module.export = (function () {
document.addEventListener('DOMContentLoaded', DOMContentLoaded, false);

function DOMContentLoaded(event) {
const appBar = document.querySelector('meta[name="ethereum-dapp-url-bar-style"]');

if (appBar)
{ ipcRenderer.sendToHost('appBar', appBar.content); }
else
{ ipcRenderer.sendToHost('appBar', null); }
if (appBar) {
ipcRenderer.sendToHost('appBar', appBar.content);
} else {
ipcRenderer.sendToHost('appBar', null);
}

document.removeEventListener('DOMContentLoaded', DOMContentLoaded, false);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/preloader/include/mistAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = () => {
@param {Function} callback Change the callback to be called when the menu is pressed.
*/
add(id, options, callback) {
var args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
callback = _.isFunction(args[args.length - 1]) ? args.pop() : null;
options = _.isObject(args[args.length - 1]) ? args.pop() : null;
id = _.isString(args[args.length - 1]) || _.isFinite(args[args.length - 1]) ? args.pop() : null;
Expand Down
9 changes: 5 additions & 4 deletions modules/preloader/include/openExternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ document.addEventListener('click', (e) => {
let node = false;


if (e.target.nodeName === 'A')
{ node = e.target; }
else if (e.target.parentNode && e.target.parentNode.nodeName === 'A')
{ node = e.target.parentNode; }
if (e.target.nodeName === 'A') {
node = e.target;
} else if (e.target.parentNode && e.target.parentNode.nodeName === 'A') {
node = e.target.parentNode;
}

// open in browser
if (node && node.attributes.target && node.attributes.target.value === '_blank') {
Expand Down
9 changes: 5 additions & 4 deletions modules/preloader/include/openPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const { remote } = require('electron');
document.addEventListener('click', (e) => {
let node = false;

if (e.target.nodeName === 'A')
{ node = e.target; }
else if (e.target.parentNode && e.target.parentNode.nodeName === 'A')
{ node = e.target.parentNode; }
if (e.target.nodeName === 'A') {
node = e.target;
} else if (e.target.parentNode && e.target.parentNode.nodeName === 'A') {
node = e.target.parentNode;
}

// open popup
if (node && node.attributes.target && node.attributes.target.value === '_popup') {
Expand Down
Loading

0 comments on commit 59b918f

Please sign in to comment.