Skip to content

Commit 7c51240

Browse files
Trottaddaleax
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: #14522 Backport-Reviewed-By: Anna Henningsen <[email protected]> PR-URL: #14431 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent eb023ef commit 7c51240

File tree

94 files changed

+660
-632
lines changed

Some content is hidden

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

94 files changed

+660
-632
lines changed

lib/.eslintrc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rules:
66
MemberExpression: off,
77
ObjectExpression: first,
88
SwitchCase: 1}]
9-
indent-legacy: 0
9+
indent-legacy: off
1010

1111
# Custom rules in tools/eslint-rules
1212
require-buffer: error

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: error

test/addons-napi/test_fatal/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (process.argv[2] === 'child') {
1212
}
1313

1414
const p = child_process.spawnSync(
15-
process.execPath, [ '--napi-modules', __filename, 'child' ]);
15+
process.execPath, [ '--napi-modules', __filename, 'child' ]);
1616
assert.ifError(p.error);
1717
assert.ok(p.stderr.toString().includes(
18-
'FATAL ERROR: test_fatal::Test fatal message'));
18+
'FATAL ERROR: test_fatal::Test fatal message'));

test/addons-napi/test_general/testInstanceOf.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
6161
typeof Symbol.hasInstance === 'symbol') {
6262

6363
function compareToNative(theObject, theConstructor) {
64-
assert.strictEqual(addon.doInstanceOf(theObject, theConstructor),
65-
(theObject instanceof theConstructor));
64+
assert.strictEqual(
65+
addon.doInstanceOf(theObject, theConstructor),
66+
(theObject instanceof theConstructor)
67+
);
6668
}
6769

6870
function MyClass() {}

test/async-hooks/init-hooks.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,14 @@ class ActivityCollector {
212212
}
213213

214214
exports = module.exports = function initHooks({
215-
oninit,
216-
onbefore,
217-
onafter,
218-
ondestroy,
219-
allowNoInit,
220-
logid,
221-
logtype } = {}) {
215+
oninit,
216+
onbefore,
217+
onafter,
218+
ondestroy,
219+
allowNoInit,
220+
logid,
221+
logtype
222+
} = {}) {
222223
return new ActivityCollector(process.hrtime(), {
223224
oninit,
224225
onbefore,

test/async-hooks/test-embedder.api.async-resource.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ assert.throws(() => new AsyncResource('invalid_trigger_id', null),
1818
/^RangeError: triggerAsyncId must be an unsigned integer$/);
1919

2020
assert.strictEqual(
21-
new AsyncResource('default_trigger_id').triggerAsyncId(),
22-
async_hooks.executionAsyncId()
21+
new AsyncResource('default_trigger_id').triggerAsyncId(),
22+
async_hooks.executionAsyncId()
2323
);
2424

2525
// create first custom event 'alcazares' with triggerAsyncId derived

test/async-hooks/test-internal-nexttick-default-trigger.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ process.on('exit', function() {
4141

4242
const as = hooks.activitiesOfTypes('TickObject');
4343
checkInvocations(as[0], {
44-
init: 1, before: 1, after: 1, destroy: 1
44+
init: 1, before: 1, after: 1, destroy: 1
4545
}, 'when process exits');
4646
checkInvocations(as[1], {
47-
init: 1, before: 1, after: 1, destroy: 1
47+
init: 1, before: 1, after: 1, destroy: 1
4848
}, 'when process exits');
4949
checkInvocations(as[2], {
50-
init: 1, before: 1, after: 1, destroy: 1
50+
init: 1, before: 1, after: 1, destroy: 1
5151
}, 'when process exits');
5252
});

test/common/dns.js

+56-56
Original file line numberDiff line numberDiff line change
@@ -100,53 +100,53 @@ function parseDNSPacket(buffer) {
100100
.replace(/(.{4}(?!$))/g, '$1:');
101101
break;
102102
case types.TXT:
103-
{
104-
let position = offset;
105-
rr.entries = [];
106-
while (position < offset + dataLength) {
107-
const txtLength = buffer[offset];
108-
rr.entries.push(buffer.toString('utf8',
109-
position + 1,
110-
position + 1 + txtLength));
111-
position += 1 + txtLength;
112-
}
113-
assert.strictEqual(position, offset + dataLength);
114-
break;
103+
{
104+
let position = offset;
105+
rr.entries = [];
106+
while (position < offset + dataLength) {
107+
const txtLength = buffer[offset];
108+
rr.entries.push(buffer.toString('utf8',
109+
position + 1,
110+
position + 1 + txtLength));
111+
position += 1 + txtLength;
115112
}
113+
assert.strictEqual(position, offset + dataLength);
114+
break;
115+
}
116116
case types.MX:
117-
{
118-
rr.priority = buffer.readInt16BE(buffer, offset);
119-
offset += 2;
120-
const { nread, domain } = readDomainFromPacket(buffer, offset);
121-
rr.exchange = domain;
122-
assert.strictEqual(nread, dataLength);
123-
break;
124-
}
117+
{
118+
rr.priority = buffer.readInt16BE(buffer, offset);
119+
offset += 2;
120+
const { nread, domain } = readDomainFromPacket(buffer, offset);
121+
rr.exchange = domain;
122+
assert.strictEqual(nread, dataLength);
123+
break;
124+
}
125125
case types.NS:
126126
case types.CNAME:
127127
case types.PTR:
128-
{
129-
const { nread, domain } = readDomainFromPacket(buffer, offset);
130-
rr.value = domain;
131-
assert.strictEqual(nread, dataLength);
132-
break;
133-
}
128+
{
129+
const { nread, domain } = readDomainFromPacket(buffer, offset);
130+
rr.value = domain;
131+
assert.strictEqual(nread, dataLength);
132+
break;
133+
}
134134
case types.SOA:
135-
{
136-
const mname = readDomainFromPacket(buffer, offset);
137-
const rname = readDomainFromPacket(buffer, offset + mname.nread);
138-
rr.nsname = mname.domain;
139-
rr.hostmaster = rname.domain;
140-
const trailerOffset = offset + mname.nread + rname.nread;
141-
rr.serial = buffer.readUInt32BE(trailerOffset);
142-
rr.refresh = buffer.readUInt32BE(trailerOffset + 4);
143-
rr.retry = buffer.readUInt32BE(trailerOffset + 8);
144-
rr.expire = buffer.readUInt32BE(trailerOffset + 12);
145-
rr.minttl = buffer.readUInt32BE(trailerOffset + 16);
135+
{
136+
const mname = readDomainFromPacket(buffer, offset);
137+
const rname = readDomainFromPacket(buffer, offset + mname.nread);
138+
rr.nsname = mname.domain;
139+
rr.hostmaster = rname.domain;
140+
const trailerOffset = offset + mname.nread + rname.nread;
141+
rr.serial = buffer.readUInt32BE(trailerOffset);
142+
rr.refresh = buffer.readUInt32BE(trailerOffset + 4);
143+
rr.retry = buffer.readUInt32BE(trailerOffset + 8);
144+
rr.expire = buffer.readUInt32BE(trailerOffset + 12);
145+
rr.minttl = buffer.readUInt32BE(trailerOffset + 16);
146146

147-
assert.strictEqual(trailerOffset + 20, dataLength);
148-
break;
149-
}
147+
assert.strictEqual(trailerOffset + 20, dataLength);
148+
break;
149+
}
150150
default:
151151
throw new Error(`Unknown RR type ${rr.type}`);
152152
}
@@ -253,23 +253,23 @@ function writeDNSPacket(parsed) {
253253
case 'NS':
254254
case 'CNAME':
255255
case 'PTR':
256-
{
257-
const domain = writeDomainName(rr.exchange || rr.value);
258-
rdLengthBuf[0] += domain.length;
259-
buffers.push(domain);
260-
break;
261-
}
256+
{
257+
const domain = writeDomainName(rr.exchange || rr.value);
258+
rdLengthBuf[0] += domain.length;
259+
buffers.push(domain);
260+
break;
261+
}
262262
case 'SOA':
263-
{
264-
const mname = writeDomainName(rr.nsname);
265-
const rname = writeDomainName(rr.hostmaster);
266-
rdLengthBuf[0] = mname.length + rname.length + 20;
267-
buffers.push(mname, rname);
268-
buffers.push(new Uint32Array([
269-
rr.serial, rr.refresh, rr.retry, rr.expire, rr.minttl
270-
]));
271-
break;
272-
}
263+
{
264+
const mname = writeDomainName(rr.nsname);
265+
const rname = writeDomainName(rr.hostmaster);
266+
rdLengthBuf[0] = mname.length + rname.length + 20;
267+
buffers.push(mname, rname);
268+
buffers.push(new Uint32Array([
269+
rr.serial, rr.refresh, rr.retry, rr.expire, rr.minttl
270+
]));
271+
break;
272+
}
273273
default:
274274
throw new Error(`Unknown RR type ${rr.type}`);
275275
}

test/inspector/inspector-helper.js

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

5151
function sendEnd(socket) {
@@ -74,7 +74,7 @@ function parseWSFrame(buffer, handler) {
7474
if (buffer.length < bodyOffset + dataLen)
7575
return 0;
7676
const message = JSON.parse(
77-
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
77+
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
7878
if (DEBUG)
7979
console.log('[received]', JSON.stringify(message));
8080
handler(message);
@@ -238,7 +238,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
238238
this.sendAll_(commands, () => {
239239
timeoutId = setTimeout(() => {
240240
assert.fail(`Messages without response: ${
241-
Object.keys(this.messages_).join(', ')}`);
241+
Object.keys(this.messages_).join(', ')}`);
242242
}, TIMEOUT);
243243
});
244244
});
@@ -282,7 +282,7 @@ TestSession.prototype.expectMessages = function(expects) {
282282
if (!(expects instanceof Array)) expects = [ expects ];
283283

284284
const callback = this.createCallbackWithTimeout_(
285-
`Matching response was not received:\n${expects[0]}`);
285+
`Matching response was not received:\n${expects[0]}`);
286286
this.messagefilter_ = (message) => {
287287
if (expects[0](message))
288288
expects.shift();
@@ -296,8 +296,8 @@ TestSession.prototype.expectMessages = function(expects) {
296296

297297
TestSession.prototype.expectStderrOutput = function(regexp) {
298298
this.harness_.addStderrFilter(
299-
regexp,
300-
this.createCallbackWithTimeout_(`Timed out waiting for ${regexp}`));
299+
regexp,
300+
this.createCallbackWithTimeout_(`Timed out waiting for ${regexp}`));
301301
return this;
302302
};
303303

@@ -350,10 +350,10 @@ TestSession.prototype.assertClosed = function() {
350350

351351
TestSession.prototype.testHttpResponse = function(path, check) {
352352
return this.enqueue((callback) =>
353-
checkHttpResponse(null, this.harness_.port, path, (err, response) => {
354-
check.call(this, err, response);
355-
callback();
356-
}));
353+
checkHttpResponse(null, this.harness_.port, path, (err, response) => {
354+
check.call(this, err, response);
355+
callback();
356+
}));
357357
};
358358

359359

@@ -366,7 +366,7 @@ function Harness(port, childProcess) {
366366
this.running_ = true;
367367

368368
childProcess.stdout.on('data', makeBufferingDataCallback(
369-
(line) => console.log('[out]', line)));
369+
(line) => console.log('[out]', line)));
370370

371371

372372
childProcess.stderr.on('data', makeBufferingDataCallback((message) => {

test/inspector/test-inspector.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ function testBreakpointOnStart(session) {
122122
function testSetBreakpointAndResume(session) {
123123
console.log('[test]', 'Setting a breakpoint and verifying it is hit');
124124
const commands = [
125-
{ 'method': 'Debugger.setBreakpointByUrl',
126-
'params': { 'lineNumber': 5,
127-
'url': session.mainScriptPath,
128-
'columnNumber': 0,
129-
'condition': ''
130-
}
131-
},
132-
{ 'method': 'Debugger.resume'},
133-
[ { 'method': 'Debugger.getScriptSource',
134-
'params': { 'scriptId': session.mainScriptId } },
135-
expectMainScriptSource ],
125+
{ 'method': 'Debugger.setBreakpointByUrl',
126+
'params': { 'lineNumber': 5,
127+
'url': session.mainScriptPath,
128+
'columnNumber': 0,
129+
'condition': ''
130+
}
131+
},
132+
{ 'method': 'Debugger.resume'},
133+
[ { 'method': 'Debugger.getScriptSource',
134+
'params': { 'scriptId': session.mainScriptId } },
135+
expectMainScriptSource ],
136136
];
137137
session
138138
.sendInspectorCommands(commands)

test/inspector/test-not-blocked-on-idle.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const helper = require('./inspector-helper.js');
66
function shouldShutDown(session) {
77
session
88
.sendInspectorCommands([
9-
{ 'method': 'Debugger.enable' },
10-
{ 'method': 'Debugger.pause' },
9+
{ 'method': 'Debugger.enable' },
10+
{ 'method': 'Debugger.pause' },
1111
])
1212
.disconnect(true);
1313
}

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
@@ -19,7 +19,7 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
/* eslint-disable indent-legacy, no-tabs */
22+
/* eslint-disable indent, no-tabs */
2323
'use strict';
2424
require('../common');
2525

test/parallel/test-assert.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ assert.throws(() => {
464464
let threw = false;
465465
try {
466466
assert.throws(
467-
function() {
468-
throw ({}); // eslint-disable-line no-throw-literal
469-
},
470-
Array
467+
function() {
468+
throw ({}); // eslint-disable-line no-throw-literal
469+
},
470+
Array
471471
);
472472
} catch (e) {
473473
threw = true;

0 commit comments

Comments
 (0)