Skip to content

Commit

Permalink
deps,lint: update eslint-config-metarhia
Browse files Browse the repository at this point in the history
Update eslint-config-metarhia to v4.0.0 and fix all of the linting
errors.

PR-URL: #371
Reviewed-By: Dmytro Nechai <nechaido@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
  • Loading branch information
belochub authored and aqrln committed Aug 27, 2018
1 parent ecf375d commit 6e3391a
Show file tree
Hide file tree
Showing 67 changed files with 271 additions and 257 deletions.
4 changes: 2 additions & 2 deletions benchmark/distributed/master.js
Expand Up @@ -69,7 +69,7 @@ const application = {
registerServer: (connection, address, callback) => {
server = connection;
serverAddress = address;
workers.forEach((worker) => {
workers.forEach(worker => {
worker.emitRemoteEvent('worker', 'connect', [serverAddress]);
});
callback(null);
Expand Down Expand Up @@ -160,7 +160,7 @@ master.listen(listenAddress, () => {

process.on('SIGINT', () => {
console.log('\nMaster server is being closed');
master.close((error) => {
master.close(error => {
if (error) {
console.log(`Error occured when closing:\n${error}`);
if (transport === 'ipc') {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/distributed/parse-address.js
Expand Up @@ -2,7 +2,7 @@

const { split } = require('../../lib/cli/utils');

module.exports = (address) => {
module.exports = address => {
const [transport, location] = split(address, '://', 1, true);

if (!location) {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/distributed/server.js
Expand Up @@ -107,7 +107,7 @@ server.listen(listenAddress, () => {
return;
}

api.master.registerServer(connectAddress, (error) => {
api.master.registerServer(connectAddress, error => {
if (error) {
console.error(error);
connection.close();
Expand All @@ -133,7 +133,7 @@ server.listen(listenAddress, () => {
process.on('SIGINT', () => {
console.log('\nServer is being closed');
clearInterval(timer);
server.close((error) => {
server.close(error => {
if (error) {
console.log(`Error occured when closing:\n${error}`);
if (transport === 'ipc') {
Expand Down
8 changes: 4 additions & 4 deletions benchmark/distributed/worker.js
Expand Up @@ -106,7 +106,7 @@ const report = () => {

const request = () => {
const startTimeHR = process.hrtime();
connections.forEach((connection) => {
connections.forEach(connection => {
connection.remoteProxies['server'].method(argument, (error, data) => {
if (error) {
console.error(`Error during call:\n${error}`);
Expand All @@ -130,13 +130,13 @@ jstp[transport].connectAndInspect(

api = master;

api.master.on('connect', (address) => {
api.master.on('connect', address => {
for (let i = 0; i < connectionAmount; i++) {
createConnection(i, address);
}
});

api.master.registerWorker((error) => {
api.master.registerWorker(error => {
if (error) {
console.error(`Couldn't register worker:\n${error}`);
return;
Expand All @@ -153,7 +153,7 @@ process.on('SIGINT', () => {
console.log('\nWorker is being closed');
clearInterval(requestTimer);
clearInterval(reportTimer);
connections.forEach((connection) => {
connections.forEach(connection => {
connection.close();
});
process.exit(0);
Expand Down
6 changes: 3 additions & 3 deletions benchmark/run.js
Expand Up @@ -44,7 +44,7 @@ let workersFinished = 0;

let benchStartedHR;

server.on('exit', (exitCode) => {
server.on('exit', exitCode => {
serverExited = true;
if (exitCode !== 0) {
terminate();
Expand All @@ -59,7 +59,7 @@ server.on('message', ([type, payload]) => {
}
socket = payload;

const onWorkerExitFactory = index => (exitCode) => {
const onWorkerExitFactory = index => exitCode => {
workersExited[index] = true;
if (exitCode !== 0) {
terminate();
Expand Down Expand Up @@ -122,7 +122,7 @@ function terminate() {
'\nBenchmark is being terminated due to an error or signal termination\n'
);
workers.filter((_, index) => !workersExited[index])
.forEach((worker) => {
.forEach(worker => {
worker.kill('SIGKILL');
});

Expand Down
2 changes: 1 addition & 1 deletion benchmark/server.js
Expand Up @@ -36,7 +36,7 @@ process.on('message', ([type]) => {

process.on('SIGINT', terminate);

server.listen(socket, (error) => {
server.listen(socket, error => {
if (error) {
console.error(error);
}
Expand Down
6 changes: 3 additions & 3 deletions benchmark/statistics.js
@@ -1,6 +1,6 @@
'use strict';

const mean = (sample) => {
const mean = sample => {
const len = sample.length;
if (len === 0)
return;
Expand All @@ -25,7 +25,7 @@ const stdev = (sample, meanValue) => {
return Math.sqrt(variance);
};

const combineCount = (samples) => {
const combineCount = samples => {
let sum = 0;
for (let i = 0; i < samples.length; i++) {
sum += samples[i].count;
Expand All @@ -52,7 +52,7 @@ const combineStdev = (samples, mean, count) => {
return Math.sqrt(sum / count);
};

const combineSamples = (samples) => {
const combineSamples = samples => {
const len = samples.length;
if (len === 0)
return;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/worker.js
Expand Up @@ -20,7 +20,7 @@ process.on('message', ([type, ...payload]) => {

function connect(socket) {
let connected = 0;
const createConnection = (index) => {
const createConnection = index => {
jstp.net.connectAndInspect(
'app', null, ['iface'], socket, (error, conn) => {
connected++;
Expand Down
4 changes: 2 additions & 2 deletions bin/cli.js
Expand Up @@ -28,7 +28,7 @@ const args = yargs
})
.strict().argv;

const log = (msg) => {
const log = msg => {
const userInput = rl.line;
if (userInput) rl.clearLine();
rl.output.write(msg);
Expand All @@ -52,7 +52,7 @@ rl = readline.createInterface({
});

const prompt = rl.prompt.bind(rl);
rl.on('line', (line) => {
rl.on('line', line => {
cli.processLine(line, prompt);
});

Expand Down
4 changes: 2 additions & 2 deletions lib/applications.js
Expand Up @@ -95,10 +95,10 @@ class Application {
// Create an index of applications from an array
// applications - array of JSTP applications
//
const createAppsIndex = (applications) => {
const createAppsIndex = applications => {
const index = new Map();

applications.forEach((application) => {
applications.forEach(application => {
let versions = index.get(application.name);
if (!versions) {
versions = new Map();
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/cli.js
Expand Up @@ -28,7 +28,7 @@ module.exports = class Cli extends EventEmitter {
if (options.verbose) {
this.client.logger = new EventEmitter();

this.client.logger.on('outgoingMessage', (message) => {
this.client.logger.on('outgoingMessage', message => {
if (
(!message.pong && !message.ping) ||
options.verbose === VERBOSENESS_LEVEL.ALL
Expand All @@ -37,7 +37,7 @@ module.exports = class Cli extends EventEmitter {
}
});

this.client.logger.on('incomingMessage', (message) => {
this.client.logger.on('incomingMessage', message => {
if (
(!message.pong && !message.ping) ||
options.verbose === VERBOSENESS_LEVEL.ALL
Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports = class Cli extends EventEmitter {
utils.filterKeys(
Object.getOwnPropertyNames(CommandProcessor.prototype),
['constructor', 'complete', 'getNextCompleter']
).map((command) => {
).map(command => {
if (!this.lineProcessor[command]) {
this.lineProcessor[command] =
(...args) => this.commandProcessor[command](...args);
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/command-processor.js
Expand Up @@ -60,7 +60,7 @@ class ConnectCompleter {
function filterApiCompletions(rawApi) {
const api = {};
const forbidden = ['_', 'domain'];
Object.keys(rawApi).forEach((int) => {
Object.keys(rawApi).forEach(int => {
api[int] = Object.keys(rawApi[int])
.filter(c => forbidden.every(el => !c.startsWith(el)));
});
Expand Down Expand Up @@ -149,7 +149,7 @@ module.exports = class CommandProcessor extends EventEmitter {
this.cli.log(`Received remote event '${eventName}'` +
` in interface '${interfaceName}': ${mdsf.stringify(args)}`);
});
connection.on('error', (err) => {
connection.on('error', err => {
this.cli._logErr(err);
});
callback();
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/line-processor.js
Expand Up @@ -62,7 +62,7 @@ module.exports = class LineProcessor {
callback(err);
return;
}
this.commandProcessor.event(args[0], args[1], eventArgs, (err) => {
this.commandProcessor.event(args[0], args[1], eventArgs, err => {
if (err) {
callback(err);
return;
Expand Down Expand Up @@ -107,7 +107,7 @@ module.exports = class LineProcessor {
const interfaces = args[2] ? utils.split(args[2], ' ') : [];
this.commandProcessor.connect(
scheme, host, port, app, interfaces,
(err) => {
err => {
if (err) {
callback(err);
return;
Expand All @@ -118,7 +118,7 @@ module.exports = class LineProcessor {
}

disconnect(_, callback) {
this.commandProcessor.disconnect((err) => {
this.commandProcessor.disconnect(err => {
if (err) {
callback(err);
return;
Expand Down
6 changes: 3 additions & 3 deletions lib/common-crypto-fallback.js
Expand Up @@ -5,22 +5,22 @@
// Browser adapter for required functions from Node.js crypto module.
const crypto = {};

crypto.randomBytes = (count) => {
crypto.randomBytes = count => {
const buf = Buffer.alloc(count);
crypto.randomFillSync(buf);
return buf;
};

if (window.crypto && window.crypto.getRandomValues) {
crypto.randomFillSync = (buf) => {
crypto.randomFillSync = buf => {
window.crypto.getRandomValues(buf);
};
} else {
console.warn(
'Web Crypto API is not supported in your browser!',
'Using Math.random() instead.'
);
crypto.randomFillSync = (buf) => {
crypto.randomFillSync = buf => {
for (let i = 0; i < buf.length; i++) {
buf[i] = Math.floor(0x100 * Math.random());
}
Expand Down
8 changes: 4 additions & 4 deletions lib/common.js
Expand Up @@ -26,15 +26,15 @@ const forwardEvent = (from, to, eventName, newEventName = eventName) => {
// eventNames - array of names of events
//
const forwardMultipleEvents = (from, to, eventNames) => {
eventNames.forEach((event) => {
eventNames.forEach(event => {
forwardEvent(from, to, event);
});
};

// Try to require `moduleName` and return the exported object if the module is
// found or null otherwise.
//
const safeRequire = (moduleName) => {
const safeRequire = moduleName => {
try {
return [null, require(moduleName)];
} catch (err) {
Expand All @@ -46,7 +46,7 @@ const safeRequire = (moduleName) => {
// for ES6 classes.
//
const mixin = (target, source) => {
Object.getOwnPropertyNames(source).forEach((property) => {
Object.getOwnPropertyNames(source).forEach(property => {
if (!target[property]) {
target[property] = source[property];
}
Expand All @@ -56,7 +56,7 @@ const mixin = (target, source) => {
// If last element of the array args is a function then
// pops the array and returns that function else returns null.
//
const extractCallback = (args) => {
const extractCallback = args => {
if (typeof args[args.length - 1] === 'function') return args.pop();
return null;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/connection.js
Expand Up @@ -60,7 +60,7 @@ class Connection extends EventEmitter {

// Defined in constructor to be used as default callback in callMethod
// without binding it.
this._emitError = (error) => {
this._emitError = error => {
if (error) this.emit('error', error);
};

Expand All @@ -83,7 +83,7 @@ class Connection extends EventEmitter {
this.handshakeDone = false;
this._closed = false;

Object.keys(this._transportListeners).forEach((event) => {
Object.keys(this._transportListeners).forEach(event => {
transport.on(event, this._transportListeners[event]);
});
}
Expand Down Expand Up @@ -113,7 +113,7 @@ class Connection extends EventEmitter {
}

_removeTransport() {
Object.keys(this._transportListeners).forEach((event) => {
Object.keys(this._transportListeners).forEach(event => {
this.transport.removeListener(
event, this._transportListeners[event]
);
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Expand Up @@ -63,7 +63,7 @@ RemoteError.fromJstpArray = array => new RemoteError(array[0], array[1]);
// error - an error to prepare (instance of Error, RemoteError, a string or
// a regular JavaScript array of error code and error description)
//
RemoteError.getJstpArrayFor = (error) => {
RemoteError.getJstpArrayFor = error => {
if (error instanceof RemoteError) {
return error.toJstpArray();
} else if (Array.isArray(error)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Expand Up @@ -30,7 +30,7 @@ class Server extends net.Server {
options.clientExpirationTime,
listener
);
this.on('connection', (socket) => {
this.on('connection', socket => {
this._onRawConnection(socket);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/remote-proxy.js
Expand Up @@ -17,7 +17,7 @@ class RemoteProxy extends EventEmitter {
this._interfaceName = interfaceName;

methods.filter(method => this[method] === undefined)
.forEach((method) => {
.forEach(method => {
this[method] = (...args) => {
let resend = args[args.length - 1];
let callback = args[args.length - 2];
Expand Down
4 changes: 2 additions & 2 deletions lib/server.js
Expand Up @@ -139,7 +139,7 @@ class Server {
}

broadcast(interfaceName, eventName, ...eventArgs) {
this.clients.forEach((client) => {
this.clients.forEach(client => {
client.emitRemoteEvent(interfaceName, eventName, eventArgs);
});
}
Expand Down Expand Up @@ -249,7 +249,7 @@ class Server {
_onRawConnection(socket) {
const connection = new Connection(this.createTransport(socket), this);

connection.on('error', (error) => {
connection.on('error', error => {
this.emit('connectionError', error, connection);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/session.js
Expand Up @@ -106,7 +106,7 @@ class Session extends Map {
}

_resendBufferedMessages() {
this.buffer.forEach((message) => {
this.buffer.forEach(message => {
this.connection._send(message);
});
}
Expand Down

0 comments on commit 6e3391a

Please sign in to comment.