Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code style: always-parens for arrow functions #4814

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ rules:
# list: http://eslint.org/docs/rules/#ecmascript-6
## Suggest using 'const' wherever possible
prefer-const: 2
## always require paren in arrow functions, even in the single-argument case
arrow-parens: [2, "always"]

# Strict Mode
# list: https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ exports.fail = function(msg) {
// A stream to push an array into a REPL
function ArrayStream() {
this.run = function(data) {
data.forEach(line => {
data.forEach((line) => {
this.emit('data', line + '\n');
});
};
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ testBlockTypeError(assert.throws, undefined);
testBlockTypeError(assert.doesNotThrow, undefined);

// https://github.com/nodejs/node/issues/3275
assert.throws(() => { throw 'error'; }, err => err === 'error');
assert.throws(() => { throw new Error(); }, err => err instanceof Error);
assert.throws(() => { throw 'error'; }, (err) => err === 'error');
assert.throws(() => { throw new Error(); }, (err) => err instanceof Error);

console.log('All OK');
2 changes: 1 addition & 1 deletion test/parallel/test-async-wrap-check-providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ keyList.splice(0, 1);


function init(id) {
keyList = keyList.filter(e => e != pkeys[id]);
keyList = keyList.filter((e) => e != pkeys[id]);
}

function noop() { }
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-cluster-disconnect-handles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (cluster.isMaster) {
// scanner but is ignored by atoi(3). Heinous hack.
cluster.setupMaster({ execArgv: [`--debug=${common.PORT}.`] });
const worker = cluster.fork();
worker.on('message', common.mustCall(message => {
worker.on('message', common.mustCall((message) => {
assert.strictEqual(Array.isArray(message), true);
assert.strictEqual(message[0], 'listening');
let continueRecv = false;
Expand All @@ -40,9 +40,9 @@ if (cluster.isMaster) {
const debugClient = net.connect({ host, port: common.PORT });
const protocol = new Protocol();
debugClient.setEncoding('utf8');
debugClient.on('data', data => protocol.execute(data));
debugClient.on('data', (data) => protocol.execute(data));
debugClient.once('connect', common.mustCall(() => {
protocol.onResponse = common.mustCall(res => {
protocol.onResponse = common.mustCall((res) => {
protocol.onResponse = (res) => {
// It can happen that the first continue was sent before the break
// event was received. If that's the case, send also a continue from
Expand Down Expand Up @@ -85,7 +85,7 @@ if (cluster.isMaster) {
throw ex;
});
} else {
const server = net.createServer(socket => socket.pipe(socket));
const server = net.createServer((socket) => socket.pipe(socket));
const cb = () => {
process.send(['listening', server.address()]);
debugger;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-debug-no-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ proc.on('exit', common.mustCall((exitCode, signalCode) => {
}));
let stdout = '';
proc.stdout.setEncoding('utf8');
proc.stdout.on('data', data => stdout += data);
proc.stdout.on('data', (data) => stdout += data);
process.on('exit', () => {
assert(stdout.includes('Promise { 42 }'));
assert(stdout.includes('Promise { 1337 }'));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-debug-port-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const child = spawn(process.execPath, args);
child.stderr.setEncoding('utf8');

let stderr = '';
child.stderr.on('data', data => {
child.stderr.on('data', (data) => {
stderr += data;
if (child.killed !== true && stderr.includes('all workers are running'))
child.kill();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-socket-local-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var conns = 0;
var clientLocalPorts = [];
var serverRemotePorts = [];
const client = new net.Socket();
const server = net.createServer(socket => {
const server = net.createServer((socket) => {
serverRemotePorts.push(socket.remotePort);
socket.end();
});
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-process-emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const common = require('../common');
const assert = require('assert');
const sym = Symbol();

process.on('normal', common.mustCall(data => {
process.on('normal', common.mustCall((data) => {
assert.strictEqual(data, 'normalData');
}));

process.on(sym, common.mustCall(data => {
process.on(sym, common.mustCall((data) => {
assert.strictEqual(data, 'symbolData');
}));

process.on('SIGPIPE', common.mustCall(data => {
process.on('SIGPIPE', common.mustCall((data) => {
assert.strictEqual(data, 'signalData');
}));

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-repl-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const net = require('net');
process.chdir(common.fixturesDir);
const repl = require('repl');

const server = net.createServer(conn => {
const server = net.createServer((conn) => {
repl.start('', conn).on('exit', () => {
conn.destroy();
server.close();
Expand All @@ -22,7 +22,7 @@ var answer = '';
server.listen(options, function() {
const conn = net.connect(options);
conn.setEncoding('utf8');
conn.on('data', data => answer += data);
conn.on('data', (data) => answer += data);
conn.write('require("baz")\n.exit\n');
});

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-client-mindhsize.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ testDHE1024();
assert.throws(() => test(512, true, assert.fail),
/DH parameter is less than 1024 bits/);

[0, -1, -Infinity, NaN].forEach(minDHSize => {
[0, -1, -Infinity, NaN].forEach((minDHSize) => {
assert.throws(() => tls.connect({ minDHSize }),
/minDHSize is not a positive number/);
});

[true, false, null, undefined, {}, [], '', '1'].forEach(minDHSize => {
[true, false, null, undefined, {}, [], '', '1'].forEach((minDHSize) => {
assert.throws(() => tls.connect({ minDHSize }), /minDHSize is not a number/);
});

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-no-sslv3.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ server.listen(common.PORT, '127.0.0.1', function() {
client.stdout.pipe(process.stdout);
client.stderr.pipe(process.stderr);
client.stderr.setEncoding('utf8');
client.stderr.on('data', data => stderr += data);
client.stderr.on('data', (data) => stderr += data);

client.once('exit', common.mustCall(function(exitCode) {
assert.equal(exitCode, 1);
server.close();
}));
});

server.on('tlsClientError', err => errors.push(err));
server.on('tlsClientError', (err) => errors.push(err));

process.on('exit', function() {
if (/unknown option -ssl3/.test(stderr)) {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ for (const showHidden of [true, false]) {
Uint16Array,
Uint32Array,
Uint8Array,
Uint8ClampedArray ].forEach(constructor => {
Uint8ClampedArray ].forEach((constructor) => {
const length = 2;
const byteLength = length * constructor.BYTES_PER_ELEMENT;
const array = new constructor(new ArrayBuffer(byteLength), 0, length);
Expand All @@ -133,7 +133,7 @@ for (const showHidden of [true, false]) {
Uint16Array,
Uint32Array,
Uint8Array,
Uint8ClampedArray ].forEach(constructor => {
Uint8ClampedArray ].forEach((constructor) => {
const length = 2;
const byteLength = length * constructor.BYTES_PER_ELEMENT;
const array = vm.runInNewContext('new constructor(new ArrayBuffer(' +
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-v8-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const expectedHeapSpaces = [
'large_object_space'
];
const heapSpaceStatistics = v8.getHeapSpaceStatistics();
const actualHeapSpaceNames = heapSpaceStatistics.map(s => s.space_name);
const actualHeapSpaceNames = heapSpaceStatistics.map((s) => s.space_name);
assert.deepEqual(actualHeapSpaceNames.sort(), expectedHeapSpaces.sort());
heapSpaceStatistics.forEach(heapSpace => {
heapSpaceStatistics.forEach((heapSpace) => {
assert.strictEqual(typeof heapSpace.space_name, 'string');
assert.strictEqual(typeof heapSpace.space_size, 'number');
assert.strictEqual(typeof heapSpace.space_used_size, 'number');
Expand Down