Skip to content

Commit 90c12a9

Browse files
TrottMylesBorins
authored andcommitted
lib,test,tools: alignment on variable assignments
Correct alignment on variable assignments that span multiple lines in preparation for lint rule to enforce such alignment. PR-URL: #6242 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8077b89 commit 90c12a9

25 files changed

+210
-189
lines changed

lib/child_process.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,10 @@ function checkExecSyncError(ret) {
463463
ret.error = null;
464464

465465
if (!err) {
466-
var msg = 'Command failed: ' +
467-
(ret.cmd ? ret.cmd : ret.args.join(' ')) +
468-
(ret.stderr ? '\n' + ret.stderr.toString() : '');
466+
var msg = 'Command failed: ';
467+
msg += ret.cmd || ret.args.join(' ');
468+
if (ret.stderr)
469+
msg += '\n' + ret.stderr.toString();
469470
err = new Error(msg);
470471
}
471472

lib/repl.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ exports._builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
7070
'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'];
7171

7272

73-
const BLOCK_SCOPED_ERROR = 'Block-scoped declarations (let, ' +
74-
'const, function, class) not yet supported outside strict mode';
73+
const BLOCK_SCOPED_ERROR = 'Block-scoped declarations (let, const, function, ' +
74+
'class) not yet supported outside strict mode';
7575

7676

7777
class LineParser {

lib/util.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,12 @@ function formatPrimitive(ctx, value) {
460460
var type = typeof value;
461461

462462
if (type === 'string') {
463-
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
464-
.replace(/'/g, "\\'")
465-
.replace(/\\"/g, '"') + '\'';
463+
var simple = '\'' +
464+
JSON.stringify(value)
465+
.replace(/^"|"$/g, '')
466+
.replace(/'/g, "\\'")
467+
.replace(/\\"/g, '"') +
468+
'\'';
466469
return ctx.stylize(simple, 'string');
467470
}
468471
if (type === 'number') {

lib/zlib.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const binding = process.binding('zlib');
66
const util = require('util');
77
const assert = require('assert').ok;
88
const kMaxLength = require('buffer').kMaxLength;
9-
const kRangeErrorMessage = 'Cannot create final Buffer. ' +
10-
'It would be larger than 0x' + kMaxLength.toString(16) + ' bytes.';
9+
const kRangeErrorMessage = 'Cannot create final Buffer. It would be larger ' +
10+
'than 0x' + kMaxLength.toString(16) + ' bytes';
1111

1212
// zlib doesn't provide these, so kludge them in following the same
1313
// const naming scheme zlib uses.

test/parallel/test-buffer-alloc.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,17 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64'));
536536
{
537537
// big example
538538
const quote = 'Man is distinguished, not only by his reason, but by this ' +
539-
'singular passion from other animals, which is a lust ' +
540-
'of the mind, that by a perseverance of delight in the ' +
541-
'continued and indefatigable generation of knowledge, exceeds ' +
542-
'the short vehemence of any carnal pleasure.';
539+
'singular passion from other animals, which is a lust ' +
540+
'of the mind, that by a perseverance of delight in the ' +
541+
'continued and indefatigable generation of knowledge, ' +
542+
'exceeds the short vehemence of any carnal pleasure.';
543543
const expected = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb' +
544-
'24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBh' +
545-
'bmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk' +
546-
'gYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIG' +
547-
'FuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBle' +
548-
'GNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVh' +
549-
'c3VyZS4=';
544+
'24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci' +
545+
'BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ' +
546+
'gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu' +
547+
'dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ' +
548+
'GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm' +
549+
'5hbCBwbGVhc3VyZS4=';
550550
assert.equal(expected, (Buffer.from(quote)).toString('base64'));
551551

552552
let b = Buffer.allocUnsafe(1024);
@@ -556,11 +556,11 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64'));
556556

557557
// check that the base64 decoder ignores whitespace
558558
const expectedWhite = expected.slice(0, 60) + ' \n' +
559-
expected.slice(60, 120) + ' \n' +
560-
expected.slice(120, 180) + ' \n' +
561-
expected.slice(180, 240) + ' \n' +
562-
expected.slice(240, 300) + '\n' +
563-
expected.slice(300, 360) + '\n';
559+
expected.slice(60, 120) + ' \n' +
560+
expected.slice(120, 180) + ' \n' +
561+
expected.slice(180, 240) + ' \n' +
562+
expected.slice(240, 300) + '\n' +
563+
expected.slice(300, 360) + '\n';
564564
b = Buffer.allocUnsafe(1024);
565565
bytesWritten = b.write(expectedWhite, 0, 'base64');
566566
assert.equal(quote.length, bytesWritten);
@@ -574,11 +574,11 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64'));
574574

575575
// check that the base64 decoder ignores illegal chars
576576
const expectedIllegal = expected.slice(0, 60) + ' \x80' +
577-
expected.slice(60, 120) + ' \xff' +
578-
expected.slice(120, 180) + ' \x00' +
579-
expected.slice(180, 240) + ' \x98' +
580-
expected.slice(240, 300) + '\x03' +
581-
expected.slice(300, 360);
577+
expected.slice(60, 120) + ' \xff' +
578+
expected.slice(120, 180) + ' \x00' +
579+
expected.slice(180, 240) + ' \x98' +
580+
expected.slice(240, 300) + '\x03' +
581+
expected.slice(300, 360);
582582
b = Buffer.from(expectedIllegal, 'base64');
583583
assert.equal(quote.length, b.length);
584584
assert.equal(quote, b.toString('ascii', 0, quote.length));

test/parallel/test-buffer.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,17 @@ assert.equal('TWFu', (new Buffer('Man')).toString('base64'));
533533
{
534534
// big example
535535
const quote = 'Man is distinguished, not only by his reason, but by this ' +
536-
'singular passion from other animals, which is a lust ' +
537-
'of the mind, that by a perseverance of delight in the ' +
538-
'continued and indefatigable generation of knowledge, exceeds ' +
539-
'the short vehemence of any carnal pleasure.';
536+
'singular passion from other animals, which is a lust ' +
537+
'of the mind, that by a perseverance of delight in the ' +
538+
'continued and indefatigable generation of knowledge, ' +
539+
'exceeds the short vehemence of any carnal pleasure.';
540540
const expected = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb' +
541-
'24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBh' +
542-
'bmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk' +
543-
'gYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIG' +
544-
'FuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBle' +
545-
'GNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVh' +
546-
'c3VyZS4=';
541+
'24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci' +
542+
'BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ' +
543+
'gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu' +
544+
'dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ' +
545+
'GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm' +
546+
'5hbCBwbGVhc3VyZS4=';
547547
assert.equal(expected, (new Buffer(quote)).toString('base64'));
548548

549549
let b = new Buffer(1024);
@@ -553,11 +553,11 @@ assert.equal('TWFu', (new Buffer('Man')).toString('base64'));
553553

554554
// check that the base64 decoder ignores whitespace
555555
const expectedWhite = expected.slice(0, 60) + ' \n' +
556-
expected.slice(60, 120) + ' \n' +
557-
expected.slice(120, 180) + ' \n' +
558-
expected.slice(180, 240) + ' \n' +
559-
expected.slice(240, 300) + '\n' +
560-
expected.slice(300, 360) + '\n';
556+
expected.slice(60, 120) + ' \n' +
557+
expected.slice(120, 180) + ' \n' +
558+
expected.slice(180, 240) + ' \n' +
559+
expected.slice(240, 300) + '\n' +
560+
expected.slice(300, 360) + '\n';
561561
b = new Buffer(1024);
562562
bytesWritten = b.write(expectedWhite, 0, 'base64');
563563
assert.equal(quote.length, bytesWritten);
@@ -571,11 +571,11 @@ assert.equal('TWFu', (new Buffer('Man')).toString('base64'));
571571

572572
// check that the base64 decoder ignores illegal chars
573573
const expectedIllegal = expected.slice(0, 60) + ' \x80' +
574-
expected.slice(60, 120) + ' \xff' +
575-
expected.slice(120, 180) + ' \x00' +
576-
expected.slice(180, 240) + ' \x98' +
577-
expected.slice(240, 300) + '\x03' +
578-
expected.slice(300, 360);
574+
expected.slice(60, 120) + ' \xff' +
575+
expected.slice(120, 180) + ' \x00' +
576+
expected.slice(180, 240) + ' \x98' +
577+
expected.slice(240, 300) + '\x03' +
578+
expected.slice(300, 360);
579579
b = new Buffer(expectedIllegal, 'base64');
580580
assert.equal(quote.length, b.length);
581581
assert.equal(quote, b.toString('ascii', 0, quote.length));

test/parallel/test-cluster-worker-exit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function checkResults(expected_results, results) {
107107
const expected = expected_results[k];
108108

109109
var msg = (expected[1] || '') +
110-
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']');
110+
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']');
111111

112112
if (expected && expected.length) {
113113
assert.equal(actual, expected[0], msg);

test/parallel/test-cluster-worker-kill.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function checkResults(expected_results, results) {
9090
const expected = expected_results[k];
9191

9292
var msg = (expected[1] || '') +
93-
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']');
93+
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']');
9494
if (expected && expected.length) {
9595
assert.equal(actual, expected[0], msg);
9696
} else {

test/parallel/test-domain-no-error-handler-abort-on-uncaught.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ if (process.argv[2] === 'child') {
160160

161161
child.on('exit', function onExit(exitCode, signal) {
162162
const errMsg = 'Test at index ' + testIndex + ' should have aborted ' +
163-
'but instead exited with exit code ' + exitCode + ' and signal ' +
164-
signal;
163+
'but instead exited with exit code ' + exitCode +
164+
' and signal ' + signal;
165165
assert(common.nodeProcessAborted(exitCode, signal), errMsg);
166166
});
167167
});

test/parallel/test-error-reporting.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var exits = 0;
88

99
function errExec(script, callback) {
1010
var cmd = '"' + process.argv[0] + '" "' +
11-
path.join(common.fixturesDir, script) + '"';
11+
path.join(common.fixturesDir, script) + '"';
1212
return exec(cmd, function(err, stdout, stderr) {
1313
// There was some error
1414
assert.ok(err);

test/parallel/test-fs-append-file-sync.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ var currentFileData = 'ABCD';
88

99
var num = 220;
1010
var data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' +
11-
'广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
12-
'南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
13-
'前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
14-
'南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
15-
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
16-
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
11+
'广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' +
12+
'南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' +
13+
'前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
14+
'南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
15+
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
16+
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
1717

1818
common.refreshTmpDir();
1919

test/parallel/test-http-1.0.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ function test(handler, request_generator, response_validator) {
8888
}
8989

9090
function response_validator(server_response, client_got_eof, timed_out) {
91-
var expected_response = ('HTTP/1.1 200 OK\r\n' +
92-
'Content-Type: text/plain\r\n' +
93-
'Connection: close\r\n' +
94-
'\r\n' +
95-
'Hello, world!');
91+
var expected_response = 'HTTP/1.1 200 OK\r\n' +
92+
'Content-Type: text/plain\r\n' +
93+
'Connection: close\r\n' +
94+
'\r\n' +
95+
'Hello, world!';
9696

9797
assert.equal(expected_response, server_response);
9898
assert.equal(true, client_got_eof);
@@ -125,17 +125,17 @@ function test(handler, request_generator, response_validator) {
125125
}
126126

127127
function response_validator(server_response, client_got_eof, timed_out) {
128-
var expected_response = ('HTTP/1.1 200 OK\r\n' +
129-
'Content-Type: text/plain\r\n' +
130-
'Connection: close\r\n' +
131-
'Transfer-Encoding: chunked\r\n' +
132-
'\r\n' +
133-
'7\r\n' +
134-
'Hello, \r\n' +
135-
'6\r\n' +
136-
'world!\r\n' +
137-
'0\r\n' +
138-
'\r\n');
128+
var expected_response = 'HTTP/1.1 200 OK\r\n' +
129+
'Content-Type: text/plain\r\n' +
130+
'Connection: close\r\n' +
131+
'Transfer-Encoding: chunked\r\n' +
132+
'\r\n' +
133+
'7\r\n' +
134+
'Hello, \r\n' +
135+
'6\r\n' +
136+
'world!\r\n' +
137+
'0\r\n' +
138+
'\r\n';
139139

140140
assert.equal(expected_response, server_response);
141141
assert.equal(true, client_got_eof);

test/parallel/test-path-parse-format.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,11 @@ const trailingTests = [
119119
const failures = [];
120120
trailingTests.forEach(function(test) {
121121
const parse = test[0];
122+
const os = parse === path.win32.parse ? 'win32' : 'posix';
122123
test[1].forEach(function(test) {
123124
const actual = parse(test[0]);
124125
const expected = test[1];
125-
const fn = 'path.' +
126-
(parse === path.win32.parse ? 'win32' : 'posix') +
127-
'.parse(';
126+
const fn = `path.${os}.parse(`;
128127
const message = fn +
129128
JSON.stringify(test[0]) +
130129
')' +

test/parallel/test-path.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,16 @@ assert.equal(path.win32.dirname({}), '.');
155155
].forEach(function(test) {
156156
[path.posix.extname, path.win32.extname].forEach(function(extname) {
157157
let input = test[0];
158-
if (extname === path.win32.extname)
158+
let os;
159+
if (extname === path.win32.extname) {
159160
input = input.replace(/\//g, '\\');
161+
os = 'win32';
162+
} else {
163+
os = 'posix';
164+
}
160165
const actual = extname(input);
161166
const expected = test[1];
162-
const fn = 'path.' +
163-
(extname === path.win32.extname ? 'win32' : 'posix') +
164-
'.extname(';
167+
const fn = `path.${os}.extname(`;
165168
const message = fn + JSON.stringify(input) + ')' +
166169
'\n expect=' + JSON.stringify(expected) +
167170
'\n actual=' + JSON.stringify(actual);
@@ -319,11 +322,15 @@ joinTests.forEach(function(test) {
319322
// For non-Windows specific tests with the Windows join(), we need to try
320323
// replacing the slashes since the non-Windows specific tests' `expected`
321324
// use forward slashes
322-
const actualAlt = (join === path.win32.join) ?
323-
actual.replace(/\\/g, '/') : undefined;
324-
const fn = 'path.' +
325-
(join === path.win32.join ? 'win32' : 'posix') +
326-
'.join(';
325+
let actualAlt;
326+
let os;
327+
if (join === path.win32.join) {
328+
actualAlt = actual.replace(/\\/g, '/');
329+
os = 'win32';
330+
} else {
331+
os = 'posix';
332+
}
333+
const fn = `path.${os}.join(`;
327334
const message = fn + test[0].map(JSON.stringify).join(',') + ')' +
328335
'\n expect=' + JSON.stringify(expected) +
329336
'\n actual=' + JSON.stringify(actual);
@@ -424,14 +431,14 @@ resolveTests.forEach(function(test) {
424431
test[1].forEach(function(test) {
425432
const actual = resolve.apply(null, test[0]);
426433
let actualAlt;
434+
const os = resolve === path.win32.resolve ? 'win32' : 'posix';
427435
if (resolve === path.win32.resolve && !common.isWindows)
428436
actualAlt = actual.replace(/\\/g, '/');
429437
else if (resolve !== path.win32.resolve && common.isWindows)
430438
actualAlt = actual.replace(/\//g, '\\');
439+
431440
const expected = test[1];
432-
const fn = 'path.' +
433-
(resolve === path.win32.resolve ? 'win32' : 'posix') +
434-
'.resolve(';
441+
const fn = `path.${os}.resolve(`;
435442
const message = fn + test[0].map(JSON.stringify).join(',') + ')' +
436443
'\n expect=' + JSON.stringify(expected) +
437444
'\n actual=' + JSON.stringify(actual);
@@ -518,9 +525,8 @@ relativeTests.forEach(function(test) {
518525
test[1].forEach(function(test) {
519526
const actual = relative(test[0], test[1]);
520527
const expected = test[2];
521-
const fn = 'path.' +
522-
(relative === path.win32.relative ? 'win32' : 'posix') +
523-
'.relative(';
528+
const os = relative === path.win32.relative ? 'win32' : 'posix';
529+
const fn = `path.${os}.relative(`;
524530
const message = fn +
525531
test.slice(0, 2).map(JSON.stringify).join(',') +
526532
')' +

test/parallel/test-readline-undefined-columns.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ oStream.on('data', function(data) {
2828

2929
oStream.on('end', function() {
3030
const expect = 'process.stdout\r\n' +
31-
'process.stdin\r\n' +
32-
'process.stderr';
31+
'process.stdin\r\n' +
32+
'process.stderr';
3333
assert(new RegExp(expect).test(output));
3434
});
3535

0 commit comments

Comments
 (0)