From f2bd86775bd4e4b925df47571400aa1fc86f1f8c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 28 Jan 2016 10:21:57 -0500 Subject: [PATCH] test: update arrow function style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit applies new arrow function linting rules across the codebase. As it turns out, the only offenders were in the test directory. PR-URL: https://github.com/nodejs/node/pull/4813 Reviewed-By: Rod Vagg Reviewed-By: Stephen Belanger Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Michaël Zasso Reviewed-By: Matteo Collina Reviewed-By: Evan Lucas Reviewed-By: Jeremiah Senkpiel Reviewed-By: Roman Reiss --- test/common.js | 2 +- test/parallel/test-assert.js | 4 ++-- test/parallel/test-async-wrap-check-providers.js | 2 +- test/parallel/test-child-process-spawn-shell.js | 6 +++--- test/parallel/test-cluster-disconnect-handles.js | 8 ++++---- test/parallel/test-debug-no-context.js | 2 +- test/parallel/test-debug-port-cluster.js | 2 +- test/parallel/test-net-socket-local-address.js | 2 +- test/parallel/test-process-emit.js | 6 +++--- test/parallel/test-repl-require.js | 4 ++-- test/parallel/test-tls-client-mindhsize.js | 4 ++-- test/parallel/test-tls-no-sslv3.js | 4 ++-- test/parallel/test-v8-stats.js | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/common.js b/test/common.js index b91044ec4b6ff9..43f4362b45cbfe 100644 --- a/test/common.js +++ b/test/common.js @@ -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'); }); }; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index d2ce326614f7e4..d779051d7f1d35 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -484,7 +484,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'); diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 45dd8d4f24048b..38302be2cd0b5d 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -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() { } diff --git a/test/parallel/test-child-process-spawn-shell.js b/test/parallel/test-child-process-spawn-shell.js index 555e02ff711f1d..591fb409cb4cea 100644 --- a/test/parallel/test-child-process-spawn-shell.js +++ b/test/parallel/test-child-process-spawn-shell.js @@ -26,7 +26,7 @@ let echoOutput = ''; assert.strictEqual(echo.spawnargs[echo.spawnargs.length - 1].replace(/"/g, ''), 'echo foo'); -echo.stdout.on('data', data => { +echo.stdout.on('data', (data) => { echoOutput += data; }); echo.on('close', common.mustCall((code, signal) => { @@ -41,7 +41,7 @@ const command = cp.spawn(cmd, { }); let commandOutput = ''; -command.stdout.on('data', data => { +command.stdout.on('data', (data) => { commandOutput += data; }); command.on('close', common.mustCall((code, signal) => { @@ -56,7 +56,7 @@ const env = cp.spawn(`"${process.execPath}" -pe process.env.BAZ`, { }); let envOutput = ''; -env.stdout.on('data', data => { +env.stdout.on('data', (data) => { envOutput += data; }); env.on('close', common.mustCall((code, signal) => { diff --git a/test/parallel/test-cluster-disconnect-handles.js b/test/parallel/test-cluster-disconnect-handles.js index f35f101dbd1879..0ae0a0406f4db8 100644 --- a/test/parallel/test-cluster-disconnect-handles.js +++ b/test/parallel/test-cluster-disconnect-handles.js @@ -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; @@ -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 @@ -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; diff --git a/test/parallel/test-debug-no-context.js b/test/parallel/test-debug-no-context.js index a143e67ac66cd5..11a9aa17150bbb 100644 --- a/test/parallel/test-debug-no-context.js +++ b/test/parallel/test-debug-no-context.js @@ -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 }')); diff --git a/test/parallel/test-debug-port-cluster.js b/test/parallel/test-debug-port-cluster.js index 912f06d6dc6dd5..05e1627265b524 100644 --- a/test/parallel/test-debug-port-cluster.js +++ b/test/parallel/test-debug-port-cluster.js @@ -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(); diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index e0ef1ee5ed2c70..379bed363e75e8 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -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(); }); diff --git a/test/parallel/test-process-emit.js b/test/parallel/test-process-emit.js index 0e6d28b22a66e4..ce7d441655d947 100644 --- a/test/parallel/test-process-emit.js +++ b/test/parallel/test-process-emit.js @@ -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'); })); diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index e8e5e34190c464..c964951c2cacd8 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -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(); @@ -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'); }); diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index a67a3cd67d983b..0921a373c2a8dc 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -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/); }); diff --git a/test/parallel/test-tls-no-sslv3.js b/test/parallel/test-tls-no-sslv3.js index 442fc3b91c25af..44a8b4e2c0f920 100644 --- a/test/parallel/test-tls-no-sslv3.js +++ b/test/parallel/test-tls-no-sslv3.js @@ -40,7 +40,7 @@ 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); @@ -48,7 +48,7 @@ server.listen(common.PORT, '127.0.0.1', function() { })); }); -server.on('clientError', err => errors.push(err)); +server.on('clientError', (err) => errors.push(err)); process.on('exit', function() { if (/unknown option -ssl3/.test(stderr)) { diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js index 54140e4110fefe..f6d7933f0636c4 100644 --- a/test/parallel/test-v8-stats.js +++ b/test/parallel/test-v8-stats.js @@ -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');