Skip to content

Commit b7b38bd

Browse files
TrottMylesBorins
authored andcommitted
test: adjust indentation for stricter linting
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: #14835 PR-URL: #14431 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent 963ea0e commit b7b38bd

File tree

76 files changed

+580
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+580
-560
lines changed

test/.eslintrc.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
## Test-specific linter rules
22

33
rules:
4+
# Stylistic Issues
5+
# http://eslint.org/docs/rules/#stylistic-issues
6+
indent: [error, 2, {ArrayExpression: first,
7+
CallExpression: {arguments: first},
8+
FunctionDeclaration: {parameters: first},
9+
FunctionExpression: {parameters: first},
10+
MemberExpression: off,
11+
ObjectExpression: first,
12+
SwitchCase: 1}]
13+
indent-legacy: off
414
# ECMAScript 6
515
# http://eslint.org/docs/rules/#ecmascript-6
616
no-var: 2

test/debugger/test-debugger-client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function doTest(cb, done) {
181181
c.end();
182182
c.on('end', function() {
183183
console.error(
184-
'>>> killing node process %d\n\n',
185-
nodeProcess.pid);
184+
'>>> killing node process %d\n\n',
185+
nodeProcess.pid);
186186
nodeProcess.kill();
187187
done();
188188
});

test/inspector/inspector-helper.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function send(socket, message, id, callback) {
4343
for (let i = 0; i < messageBuf.length; i++)
4444
messageBuf[i] = messageBuf[i] ^ (1 << (i % 4));
4545
socket.write(
46-
Buffer.concat([wsHeaderBuf.slice(0, maskOffset + 4), messageBuf]),
47-
callback);
46+
Buffer.concat([wsHeaderBuf.slice(0, maskOffset + 4), messageBuf]),
47+
callback);
4848
}
4949

5050
function parseWSFrame(buffer, handler) {
@@ -65,7 +65,7 @@ function parseWSFrame(buffer, handler) {
6565
if (buffer.length < bodyOffset + dataLen)
6666
return 0;
6767
const message = JSON.parse(
68-
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
68+
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
6969
if (DEBUG)
7070
console.log('[received]', JSON.stringify(message));
7171
handler(message);
@@ -214,7 +214,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
214214
this.sendAll_(commands, () => {
215215
timeoutId = setTimeout(() => {
216216
common.fail(`Messages without response: ${
217-
Object.keys(this.messages_).join(', ')}`);
217+
Object.keys(this.messages_).join(', ')}`);
218218
}, TIMEOUT);
219219
});
220220
});
@@ -237,7 +237,7 @@ TestSession.prototype.expectMessages = function(expects) {
237237
if (!(expects instanceof Array)) expects = [ expects ];
238238

239239
const callback = this.createCallbackWithTimeout_(
240-
`Matching response was not received:\n${expects[0]}`);
240+
`Matching response was not received:\n${expects[0]}`);
241241
this.messagefilter_ = (message) => {
242242
if (expects[0](message))
243243
expects.shift();
@@ -251,8 +251,8 @@ TestSession.prototype.expectMessages = function(expects) {
251251

252252
TestSession.prototype.expectStderrOutput = function(regexp) {
253253
this.harness_.addStderrFilter(
254-
regexp,
255-
this.createCallbackWithTimeout_(`Timed out waiting for ${regexp}`));
254+
regexp,
255+
this.createCallbackWithTimeout_(`Timed out waiting for ${regexp}`));
256256
return this;
257257
};
258258

@@ -293,10 +293,10 @@ TestSession.prototype.disconnect = function(childDone) {
293293

294294
TestSession.prototype.testHttpResponse = function(path, check) {
295295
return this.enqueue((callback) =>
296-
checkHttpResponse(this.harness_.port, path, (err, response) => {
297-
check.call(this, err, response);
298-
callback();
299-
}));
296+
checkHttpResponse(this.harness_.port, path, (err, response) => {
297+
check.call(this, err, response);
298+
callback();
299+
}));
300300
};
301301

302302

@@ -310,7 +310,7 @@ function Harness(port, childProcess) {
310310
this.running_ = true;
311311

312312
childProcess.stdout.on('data', makeBufferingDataCallback(
313-
(line) => console.log('[out]', line)));
313+
(line) => console.log('[out]', line)));
314314

315315

316316
childProcess.stderr.on('data', makeBufferingDataCallback((message) => {
@@ -427,7 +427,7 @@ Harness.prototype.expectShutDown = function(errorCode) {
427427

428428
exports.startNodeForInspectorTest = function(callback) {
429429
const child = spawn(process.execPath,
430-
[ '--inspect', '--debug-brk', mainScript ]);
430+
[ '--inspect', '--debug-brk', mainScript ]);
431431

432432
const timeoutId = timeout('Child process did not start properly', 4);
433433

test/inspector/test-inspector.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ function testBreakpointOnStart(session) {
112112
function testSetBreakpointAndResume(session) {
113113
console.log('[test]', 'Setting a breakpoint and verifying it is hit');
114114
const commands = [
115-
{ 'method': 'Debugger.setBreakpointByUrl',
116-
'params': { 'lineNumber': 5,
117-
'url': session.mainScriptPath,
118-
'columnNumber': 0,
119-
'condition': ''
120-
}
121-
},
122-
{ 'method': 'Debugger.resume'},
123-
[ { 'method': 'Debugger.getScriptSource',
124-
'params': { 'scriptId': session.mainScriptId } },
125-
expectMainScriptSource ],
115+
{ 'method': 'Debugger.setBreakpointByUrl',
116+
'params': { 'lineNumber': 5,
117+
'url': session.mainScriptPath,
118+
'columnNumber': 0,
119+
'condition': ''
120+
}
121+
},
122+
{ 'method': 'Debugger.resume'},
123+
[ { 'method': 'Debugger.getScriptSource',
124+
'params': { 'scriptId': session.mainScriptId } },
125+
expectMainScriptSource ],
126126
];
127127
session
128128
.sendInspectorCommands(commands)

test/known_issues/test-http-path-contains-unicode.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const http = require('http');
1111
const expected = '/café🐶';
1212

1313
assert.strictEqual(
14-
expected,
15-
'/caf\u{e9}\u{1f436}',
16-
'Sanity check that string literal produced the expected string'
14+
expected,
15+
'/caf\u{e9}\u{1f436}',
16+
'Sanity check that string literal produced the expected string'
1717
);
1818

1919
const server = http.createServer(common.mustCall(function(req, res) {

test/known_issues/test-vm-proxy-failure-CP.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const assert = require('assert');
99
const vm = require('vm');
1010

1111
const handler = {
12-
getOwnPropertyDescriptor: (target, prop) => {
13-
throw new Error('whoops');
14-
}
12+
getOwnPropertyDescriptor: (target, prop) => {
13+
throw new Error('whoops');
14+
}
1515
};
1616
const sandbox = new Proxy({foo: 'bar'}, handler);
1717
const context = vm.createContext(sandbox);

test/message/throw_in_line_with_tabs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable indent-legacy, no-tabs */
1+
/* eslint-disable indent, no-tabs */
22
'use strict';
33
require('../common');
44

test/parallel/test-assert.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ assert.throws(() => {
399399
threw = false;
400400
try {
401401
assert.throws(
402-
function() {
403-
throw ({});
404-
},
405-
Array
402+
function() {
403+
throw ({});
404+
},
405+
Array
406406
);
407407
} catch (e) {
408408
threw = true;

test/parallel/test-buffer-alloc.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ assert.strictEqual('<Buffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
743743

744744
// Call .fill() first, stops valgrind warning about uninitialized memory reads.
745745
Buffer.allocUnsafe(3.3).fill().toString();
746-
// throws bad argument error in commit 43cb4ec
746+
// throws bad argument error in commit 43cb4ec
747747
Buffer.alloc(3.3).fill().toString();
748748
assert.strictEqual(Buffer.allocUnsafe(-1).length, 0);
749749
assert.strictEqual(Buffer.allocUnsafe(NaN).length, 0);
@@ -782,8 +782,8 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
782782
'ucs-2',
783783
'utf16le',
784784
'utf-16le' ].forEach(function(enc) {
785-
assert.strictEqual(Buffer.isEncoding(enc), true);
786-
});
785+
assert.strictEqual(Buffer.isEncoding(enc), true);
786+
});
787787

788788
[ 'utf9',
789789
'utf-7',
@@ -797,8 +797,8 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
797797
1,
798798
0,
799799
-1 ].forEach(function(enc) {
800-
assert.strictEqual(Buffer.isEncoding(enc), false);
801-
});
800+
assert.strictEqual(Buffer.isEncoding(enc), false);
801+
});
802802

803803
// GH-5110
804804
{

test/parallel/test-buffer-concat.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function assertWrongList(value) {
4040
}
4141

4242
const random10 = common.hasCrypto
43-
? require('crypto').randomBytes(10)
44-
: Buffer.alloc(10, 1);
43+
? require('crypto').randomBytes(10)
44+
: Buffer.alloc(10, 1);
4545
const empty = Buffer.alloc(0);
4646

4747
assert.notDeepStrictEqual(random10, empty);
@@ -58,5 +58,5 @@ assert.deepStrictEqual(Buffer.concat([random10, empty, empty]), random10);
5858
assert.deepStrictEqual(Buffer.concat([empty], 100), Buffer.alloc(100));
5959
assert.deepStrictEqual(Buffer.concat([empty], 4096), Buffer.alloc(4096));
6060
assert.deepStrictEqual(
61-
Buffer.concat([random10], 40),
62-
Buffer.concat([random10, Buffer.alloc(30)]));
61+
Buffer.concat([random10], 40),
62+
Buffer.concat([random10, Buffer.alloc(30)]));

test/parallel/test-buffer-fill.js

+29-29
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ testBufs('61c8b462c8b563c8b6', 12, 1, 'hex');
135135
// Make sure this operation doesn't go on forever
136136
buf1.fill('yKJh', 'hex');
137137
assert.throws(() =>
138-
buf1.fill('\u0222', 'hex'), /^TypeError: Invalid hex string$/);
138+
buf1.fill('\u0222', 'hex'), /^TypeError: Invalid hex string$/);
139139

140140

141141
// BASE64
@@ -183,23 +183,23 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
183183
// Check exceptions
184184
assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/);
185185
assert.throws(() =>
186-
buf1.fill(0, 0, buf1.length + 1),
186+
buf1.fill(0, 0, buf1.length + 1),
187187
/^RangeError: Out of range index$/);
188188
assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/);
189189
assert.throws(() =>
190-
buf1.fill('', 0, buf1.length + 1),
190+
buf1.fill('', 0, buf1.length + 1),
191191
/^RangeError: Out of range index$/);
192192
assert.throws(() =>
193-
buf1.fill('a', 0, buf1.length, 'node rocks!'),
193+
buf1.fill('a', 0, buf1.length, 'node rocks!'),
194194
/^TypeError: Unknown encoding: node rocks!$/);
195195
assert.throws(() =>
196-
buf1.fill('a', 0, 0, NaN),
196+
buf1.fill('a', 0, 0, NaN),
197197
/^TypeError: encoding must be a string$/);
198198
assert.throws(() =>
199-
buf1.fill('a', 0, 0, null),
199+
buf1.fill('a', 0, 0, null),
200200
/^TypeError: encoding must be a string$/);
201201
assert.throws(() =>
202-
buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
202+
buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
203203

204204

205205
function genBuffer(size, args) {
@@ -270,10 +270,10 @@ function testBufs(string, offset, length, encoding) {
270270

271271
// Make sure these throw.
272272
assert.throws(() =>
273-
Buffer.allocUnsafe(8).fill('a', -1),
273+
Buffer.allocUnsafe(8).fill('a', -1),
274274
/^RangeError: Out of range index$/);
275275
assert.throws(() =>
276-
Buffer.allocUnsafe(8).fill('a', 0, 9),
276+
Buffer.allocUnsafe(8).fill('a', 0, 9),
277277
/^RangeError: Out of range index$/);
278278

279279
// Make sure this doesn't hang indefinitely.
@@ -396,36 +396,36 @@ assert.throws(() => {
396396
}, /^RangeError: out of range index$/);
397397

398398
assert.deepStrictEqual(
399-
Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'),
400-
Buffer.from('61006200610062006100620061006200', 'hex'));
399+
Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'),
400+
Buffer.from('61006200610062006100620061006200', 'hex'));
401401

402402
assert.deepStrictEqual(
403-
Buffer.allocUnsafeSlow(15).fill('ab', 'utf16le'),
404-
Buffer.from('610062006100620061006200610062', 'hex'));
403+
Buffer.allocUnsafeSlow(15).fill('ab', 'utf16le'),
404+
Buffer.from('610062006100620061006200610062', 'hex'));
405405

406406
assert.deepStrictEqual(
407-
Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'),
408-
Buffer.from('61006200610062006100620061006200', 'hex'));
407+
Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'),
408+
Buffer.from('61006200610062006100620061006200', 'hex'));
409409
assert.deepStrictEqual(
410-
Buffer.allocUnsafeSlow(16).fill('a', 'utf16le'),
411-
Buffer.from('61006100610061006100610061006100', 'hex'));
410+
Buffer.allocUnsafeSlow(16).fill('a', 'utf16le'),
411+
Buffer.from('61006100610061006100610061006100', 'hex'));
412412

413413
assert.strictEqual(
414-
Buffer.allocUnsafeSlow(16).fill('a', 'utf16le').toString('utf16le'),
415-
'a'.repeat(8));
414+
Buffer.allocUnsafeSlow(16).fill('a', 'utf16le').toString('utf16le'),
415+
'a'.repeat(8));
416416
assert.strictEqual(
417-
Buffer.allocUnsafeSlow(16).fill('a', 'latin1').toString('latin1'),
418-
'a'.repeat(16));
417+
Buffer.allocUnsafeSlow(16).fill('a', 'latin1').toString('latin1'),
418+
'a'.repeat(16));
419419
assert.strictEqual(
420-
Buffer.allocUnsafeSlow(16).fill('a', 'utf8').toString('utf8'),
421-
'a'.repeat(16));
420+
Buffer.allocUnsafeSlow(16).fill('a', 'utf8').toString('utf8'),
421+
'a'.repeat(16));
422422

423423
assert.strictEqual(
424-
Buffer.allocUnsafeSlow(16).fill('Љ', 'utf16le').toString('utf16le'),
425-
'Љ'.repeat(8));
424+
Buffer.allocUnsafeSlow(16).fill('Љ', 'utf16le').toString('utf16le'),
425+
'Љ'.repeat(8));
426426
assert.strictEqual(
427-
Buffer.allocUnsafeSlow(16).fill('Љ', 'latin1').toString('latin1'),
428-
'\t'.repeat(16));
427+
Buffer.allocUnsafeSlow(16).fill('Љ', 'latin1').toString('latin1'),
428+
'\t'.repeat(16));
429429
assert.strictEqual(
430-
Buffer.allocUnsafeSlow(16).fill('Љ', 'utf8').toString('utf8'),
431-
'Љ'.repeat(8));
430+
Buffer.allocUnsafeSlow(16).fill('Љ', 'utf8').toString('utf8'),
431+
'Љ'.repeat(8));

test/parallel/test-buffer-includes.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ assert(mixedByteStringUcs2.includes('\u03a3', 0, 'ucs2'));
154154
assert(!mixedByteStringUcs2.includes('\u0396', 0, 'ucs2'));
155155

156156
assert.ok(
157-
mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
157+
mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
158158
assert.ok(
159-
mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
159+
mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
160160
assert.ok(
161-
!mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
161+
!mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
162162

163163
twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
164164

@@ -208,7 +208,7 @@ assert(longBufferString.includes(pattern, 512), 'Long JABACABA..., Second J');
208208

209209
// Search for a non-ASCII string in a pure ASCII string.
210210
const asciiString = Buffer.from(
211-
'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf');
211+
'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf');
212212
assert(!asciiString.includes('\x2061'));
213213
assert(asciiString.includes('leb', 0));
214214

@@ -263,11 +263,11 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
263263
const patternBufferUcs2 =
264264
allCharsBufferUcs2.slice(index, index + length);
265265
assert.ok(
266-
allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
266+
allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
267267

268268
const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
269269
assert.ok(
270-
allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
270+
allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
271271
}
272272
}
273273

0 commit comments

Comments
 (0)