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

tools: lint for function argument alignment #6390

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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ rules:
prefer-const: 2

# Custom rules in tools/eslint-rules
align-function-arguments: 2
align-multiline-assignment: 2
assert-fail-single-argument: 2
new-with-error: [2, "Error", "RangeError", "TypeError", "SyntaxError", "ReferenceError"]
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-multicast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function launchChildProcess(index) {
worker.pid, count);

assert.strictEqual(count, messages.length,
'A worker received an invalid multicast message');
'A worker received an invalid multicast message');
});

clearTimeout(timer);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ try {
} catch (e) {
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
assert.equal(e.generatedMessage, false,
'Message incorrectly marked as generated');
'Message incorrectly marked as generated');
}

// Verify that throws() and doesNotThrow() throw on non-function block
Expand Down
36 changes: 24 additions & 12 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,18 +645,30 @@ assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKio', 'base64').toString(),
'********************');

// handle padding graciously, multiple-of-4 or not
assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==',
'base64').length, 32);
assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=',
'base64').length, 32);
assert.equal(Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw',
'base64').length, 32);
assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==',
'base64').length, 31);
assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=',
'base64').length, 31);
assert.equal(Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg',
'base64').length, 31);
assert.equal(
Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length,
32
);
assert.equal(
Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', 'base64').length,
32
);
assert.equal(
Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64').length,
32
);
assert.equal(
Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length,
31
);
assert.equal(
Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length,
31
);
assert.equal(
Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length,
31
);

// This string encodes single '.' character in UTF-16
var dot = Buffer.from('//4uAA==', 'base64');
Expand Down
36 changes: 24 additions & 12 deletions test/parallel/test-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,18 +643,30 @@ assert.equal(new Buffer('KioqKioqKioqKioqKioqKioqKio', 'base64').toString(),
'********************');

// handle padding graciously, multiple-of-4 or not
assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==',
'base64').length, 32);
assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=',
'base64').length, 32);
assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw',
'base64').length, 32);
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==',
'base64').length, 31);
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=',
'base64').length, 31);
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg',
'base64').length, 31);
assert.equal(
new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length,
32
);
assert.equal(
new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', 'base64').length,
32
);
assert.equal(
new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64').length,
32
);
assert.equal(
new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length,
31
);
assert.equal(
new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length,
31
);
assert.equal(
new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length,
31
);

// This string encodes single '.' character in UTF-16
var dot = new Buffer('//4uAA==', 'base64');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-cluster-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var assert = require('assert');
var cluster = require('cluster');

assert.equal('NODE_UNIQUE_ID' in process.env, false,
'NODE_UNIQUE_ID should be removed on startup');
'NODE_UNIQUE_ID should be removed on startup');

function forEach(obj, fn) {
Object.keys(obj).forEach(function(name, index) {
Expand Down Expand Up @@ -93,7 +93,7 @@ else if (cluster.isMaster) {
worker = cluster.fork();
assert.equal(worker.id, 1);
assert.ok(worker instanceof cluster.Worker,
'the worker is not a instance of the Worker constructor');
'the worker is not a instance of the Worker constructor');

//Check event
forEach(checks.worker.events, function(bool, name, index) {
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-crypto-binary-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,11 @@ var a4 = crypto.createHash('sha1').update('Test123').digest('buffer');

if (!common.hasFipsCrypto) {
var a0 = crypto.createHash('md5').update('Test123').digest('binary');
assert.equal(a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' +
'\u00bd\u008c', 'Test MD5 as binary');
assert.equal(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
'Test MD5 as binary'
);
}

assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-crypto-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ a8 = a8.read();

if (!common.hasFipsCrypto) {
var a0 = crypto.createHash('md5').update('Test123').digest('binary');
assert.equal(a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' +
'\u00bd\u008c', 'Test MD5 as binary');
assert.equal(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
'Test MD5 as binary'
);
}
assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-domain-exit-dispose-again.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ setTimeout(function firstTimer() {
d.dispose();
console.error(err);
console.error('in domain error handler',
process.domain, process.domain === d);
process.domain, process.domain === d);
});

d.run(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const d = domain.create();

process.on('uncaughtException', common.mustCall(function onUncaught() {
assert.equal(process.domain, null,
'domains stack should be empty in uncaughtException handler');
'domains stack should be empty in uncaughtException handler');
}));

process.on('beforeExit', common.mustCall(function onBeforeExit() {
assert.equal(process.domain, null,
'domains stack should be empty in beforeExit handler');
'domains stack should be empty in beforeExit handler');
}));

d.run(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function runTestWithoutAbortOnUncaughtException() {
'include domain\'s error\'s message');

assert.notEqual(err.code, 0,
'child process should have exited with a non-zero exit code, ' +
'but did not');
'child process should have exited with a non-zero ' +
'exit code, but did not');
});
}

Expand All @@ -72,8 +72,8 @@ function runTestWithAbortOnUncaughtException() {
withAbortOnUncaughtException: true
}), function onTestDone(err, stdout, stderr) {
assert.notEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE,
'child process should not have run its uncaughtException event ' +
'handler');
'child process should not have run its uncaughtException ' +
'event handler');
assert(common.nodeProcessAborted(err.code, err.signal),
'process should have aborted, but did not');
});
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-domain-timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ timeout = setTimeout(function() {}, 10 * 1000);

process.on('exit', function() {
assert.equal(timeout_err.message, 'Timeout UNREFd',
'Domain should catch timer error');
'Domain should catch timer error');
assert.equal(immediate_err.message, 'Immediate Error',
'Domain should catch immediate error');
'Domain should catch immediate error');
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ d.on('error', common.mustCall(function() {
// call to process._fatalException, and so on recursively and
// indefinitely.
console.error('domains stack length should be 1, but instead is:',
domain._stack.length);
domain._stack.length);
process.exit(1);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-file-write-stream2.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ process.on('exit', function() {
console.log(' expected: %j', cb_expected);
console.log(' occurred: %j', cb_occurred);
assert.strictEqual(cb_occurred, cb_expected,
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
} else {
console.log('ok');
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-file-write-stream3.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ process.on('exit', function() {
console.log(' expected: %j', cb_expected);
console.log(' occurred: %j', cb_occurred);
assert.strictEqual(cb_occurred, cb_expected,
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
'events missing or out of order: "' +
cb_occurred + '" !== "' + cb_expected + '"');
}
});

Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-fs-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ function test_escape_cwd(cb) {
console.log('test_escape_cwd');
asynctest(fs.realpath, ['..'], cb, function(er, uponeActual) {
assertEqualPath(upone, uponeActual,
'realpath("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);
'realpath("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);
});
}
var uponeActual = fs.realpathSync('..');
assertEqualPath(upone, uponeActual,
'realpathSync("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);
'realpathSync("..") expected: ' + path.resolve(upone) +
' actual:' + uponeActual);


// going up with .. multiple times
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-error-on-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ server.listen(common.PORT, function() {

function done() {
assert.equal(Object.keys(agent.freeSockets).length, 0,
'expect the freeSockets pool to be empty');
'expect the freeSockets pool to be empty');

agent.destroy();
server.close();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function remoteClose() {
setTimeout(function() {
assert.equal(agent.sockets[name], undefined);
assert.equal(agent.freeSockets[name], undefined,
'freeSockets is not empty');
'freeSockets is not empty');
remoteError();
}, common.platformTimeout(200));
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-maxsockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function done() {
}
var freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
assert.equal(freepool.length, 2,
'expect keep 2 free sockets, but got ' + freepool.length);
'expect keep 2 free sockets, but got ' + freepool.length);
agent.destroy();
server.close();
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http-destroyed-socket-write2.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ server.listen(common.PORT, function() {
break;
default:
assert.strictEqual(er.code,
'ECONNRESET',
'Writing to a torn down client should RESET or ABORT');
'ECONNRESET',
'Write to a torn down client should RESET or ABORT');
break;
}

Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-http-parser-bad-ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ demoBug('POST /1', '/22 HTTP/1.1\r\n' +
'Content-Length: 4\r\n\r\n' +
'pong');

/* eslint-disable align-function-arguments */
demoBug('POST /1/22 HTTP/1.1\r\n' +
'Content-Type: tex', 't/plain\r\n' +
'Content-Length: 4\r\n\r\n' +
'pong');
/* eslint-enable align-function-arguments */

process.on('exit', function() {
assert.equal(2, headersComplete);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-url.parse-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function check(request) {
assert.strictEqual(request.url, '/asdf?qwer=zxcv');
//the host header should use the url.parse.hostname
assert.strictEqual(request.headers.host,
testURL.hostname + ':' + testURL.port);
testURL.hostname + ':' + testURL.port);
}

var server = http.createServer(function(request, response) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-module-relative-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const lookupResults = _module._resolveLookupPaths('./lodash');
const paths = lookupResults[1];

assert.strictEqual(paths[0], '.',
'Current directory is prioritized before node_modules for local modules');
'Current directory gets highest priority for local modules');
2 changes: 1 addition & 1 deletion test/parallel/test-require-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ var assert = require('assert');

var nativeProcess = require('process');
assert.strictEqual(nativeProcess, process,
'require("process") should return a reference to global process');
'require("process") should return global process reference');
2 changes: 1 addition & 1 deletion test/parallel/test-timers-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var f = function(i) {
var now = Timer.now();
console.log(i, now);
assert(now >= last_ts + 1,
'current ts ' + now + ' < prev ts ' + last_ts + ' + 1');
'current ts ' + now + ' < prev ts ' + last_ts + ' + 1');
last_ts = now;

// schedule next iteration
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-timers-reset-process-domain-on-throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function secondTimer() {
// secondTimer was scheduled before any domain had been created, so its
// callback should not have any active domain set when it runs.
if (process.domain !== null) {
console.log('process.domain should be null in this timer callback, but ' +
'instead is:', process.domain);
console.log('process.domain should be null in this timer callback, but is:',
process.domain);
// Do not use assert here, as it throws errors and if a domain with an error
// handler is active, then asserting wouldn't make the test fail.
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-peer-certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ server.listen(common.PORT, function() {
assert.equal(peerCert.fingerprint,
'8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA');
assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'],
[ 'http://ocsp.nodejs.org/' ]);
[ 'http://ocsp.nodejs.org/' ]);

var issuer = peerCert.issuerCertificate;
assert.ok(issuer.issuerCertificate === issuer);
Expand Down
Loading