Skip to content

Commit bb4c293

Browse files
aduh95ruyadorno
authored andcommitted
test: add trailing commas in async-hooks tests (#45549)
PR-URL: #45549 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 731e874 commit bb4c293

Some content is hidden

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

49 files changed

+78
-79
lines changed

test/.eslintrc.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ globals:
7272

7373
overrides:
7474
- files:
75-
- async-hooks/*.js
7675
- es-module/*.js
7776
- es-module/*.mjs
7877
- internet/*.js

test/async-hooks/hook-checks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports.checkInvocations = function checkInvocations(activity, hooks, stage) {
2121

2222
assert.ok(activity != null,
2323
`${stageInfo} Trying to check invocation for an activity, ` +
24-
'but it was empty/undefined.'
24+
'but it was empty/undefined.',
2525
);
2626

2727
// Check that actual invocations for all hooks match the expected invocations

test/async-hooks/init-hooks.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ActivityCollector {
2727
ondestroy,
2828
onpromiseResolve,
2929
logid = null,
30-
logtype = null
30+
logtype = null,
3131
} = {}) {
3232
this._start = start;
3333
this._allowNoInit = allowNoInit;
@@ -49,7 +49,7 @@ class ActivityCollector {
4949
before: this._before.bind(this),
5050
after: this._after.bind(this),
5151
destroy: this._destroy.bind(this),
52-
promiseResolve: this._promiseResolve.bind(this)
52+
promiseResolve: this._promiseResolve.bind(this),
5353
});
5454
}
5555

@@ -181,7 +181,7 @@ class ActivityCollector {
181181
// In some cases (e.g. Timeout) the handle is a function, thus the usual
182182
// `typeof handle === 'object' && handle !== null` check can't be used.
183183
handleIsObject: handle instanceof Object,
184-
handle
184+
handle,
185185
};
186186
this._stamp(activity, 'init');
187187
this._activities.set(uid, activity);
@@ -233,7 +233,7 @@ exports = module.exports = function initHooks({
233233
onpromiseResolve,
234234
allowNoInit,
235235
logid,
236-
logtype
236+
logtype,
237237
} = {}) {
238238
return new ActivityCollector(process.hrtime(), {
239239
oninit,
@@ -243,6 +243,6 @@ exports = module.exports = function initHooks({
243243
onpromiseResolve,
244244
allowNoInit,
245245
logid,
246-
logtype
246+
logtype,
247247
});
248248
};

test/async-hooks/test-async-await.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const hooks = initHooks({
2222
onbefore,
2323
onafter,
2424
ondestroy: null, // Intentionally not tested, since it will be removed soon
25-
onpromiseResolve
25+
onpromiseResolve,
2626
});
2727
hooks.enable();
2828

test/async-hooks/test-async-exec-resource-http-32060.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const hooked = {};
1212
createHook({
1313
init(asyncId, type, triggerAsyncId, resource) {
1414
hooked[asyncId] = resource;
15-
}
15+
},
1616
}).enable();
1717

1818
const server = http.createServer((req, res) => {

test/async-hooks/test-async-exec-resource-http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const hooked = {};
1313
createHook({
1414
init(asyncId, type, triggerAsyncId, resource) {
1515
hooked[asyncId] = resource;
16-
}
16+
},
1717
}).enable();
1818

1919
const server = http.createServer((req, res) => {

test/async-hooks/test-async-exec-resource-match.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { readFile } = require('fs');
66
const {
77
createHook,
88
executionAsyncResource,
9-
AsyncResource
9+
AsyncResource,
1010
} = require('async_hooks');
1111

1212
// Ignore any asyncIds created before our hook is active.
@@ -32,7 +32,7 @@ createHook({
3232
if (asyncId >= firstSeenAsyncId) {
3333
afterHook(asyncId);
3434
}
35-
}
35+
},
3636
}).enable();
3737

3838
const beforeHook = common.mustCallAtLeast(

test/async-hooks/test-async-local-storage-http-agent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const http = require('http');
77
const asyncLocalStorage = new AsyncLocalStorage();
88

99
const agent = new http.Agent({
10-
maxSockets: 1
10+
maxSockets: 1,
1111
});
1212

1313
const N = 3;

test/async-hooks/test-async-local-storage-stop-propagation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function onPropagate(type, store) {
1818
}
1919

2020
const als = new AsyncLocalStorage({
21-
onPropagate: common.mustCall(onPropagate, 2)
21+
onPropagate: common.mustCall(onPropagate, 2),
2222
});
2323

2424
const myStore = {};
@@ -40,11 +40,11 @@ als.run(myStore, common.mustCall(() => {
4040
assert.throws(() => new AsyncLocalStorage(15), {
4141
message: 'The "options" argument must be of type object. Received type number (15)',
4242
code: 'ERR_INVALID_ARG_TYPE',
43-
name: 'TypeError'
43+
name: 'TypeError',
4444
});
4545

4646
assert.throws(() => new AsyncLocalStorage({ onPropagate: 'bar' }), {
4747
message: 'The "options.onPropagate" property must be of type function. Received type string (\'bar\')',
4848
code: 'ERR_INVALID_ARG_TYPE',
49-
name: 'TypeError'
49+
name: 'TypeError',
5050
});

test/async-hooks/test-async-local-storage-thenable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const then = common.mustCall((cb) => {
1717

1818
function thenable() {
1919
return {
20-
then
20+
then,
2121
};
2222
}
2323

test/async-hooks/test-async-local-storage-tlssocket.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { AsyncLocalStorage } = require('async_hooks');
1414
const options = {
1515
cert: fixtures.readKey('rsa_cert.crt'),
1616
key: fixtures.readKey('rsa_private.pem'),
17-
rejectUnauthorized: false
17+
rejectUnauthorized: false,
1818
};
1919

2020
tls

test/async-hooks/test-callback-error.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ const arg = process.argv[2];
99
switch (arg) {
1010
case 'test_init_callback':
1111
initHooks({
12-
oninit: common.mustCall(() => { throw new Error(arg); })
12+
oninit: common.mustCall(() => { throw new Error(arg); }),
1313
}).enable();
1414
new async_hooks.AsyncResource(`${arg}_type`);
1515
return;
1616

1717
case 'test_callback': {
1818
initHooks({
19-
onbefore: common.mustCall(() => { throw new Error(arg); })
19+
onbefore: common.mustCall(() => { throw new Error(arg); }),
2020
}).enable();
2121
const resource = new async_hooks.AsyncResource(`${arg}_type`);
2222
resource.runInAsyncScope(() => {});
@@ -25,7 +25,7 @@ switch (arg) {
2525

2626
case 'test_callback_abort':
2727
initHooks({
28-
oninit: common.mustCall(() => { throw new Error(arg); })
28+
oninit: common.mustCall(() => { throw new Error(arg); }),
2929
}).enable();
3030
new async_hooks.AsyncResource(`${arg}_type`);
3131
return;

test/async-hooks/test-destroy-not-blocked.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ createHook({
2323
if (activeId === id) {
2424
activeId = -1;
2525
}
26-
}
26+
},
2727
}).enable();
2828

2929
function testNextTick() {
@@ -33,7 +33,7 @@ function testNextTick() {
3333
res.emitDestroy();
3434
// nextTick has higher prio than emit destroy
3535
process.nextTick(common.mustCall(() =>
36-
assert.strictEqual(activeId, res.asyncId()))
36+
assert.strictEqual(activeId, res.asyncId())),
3737
);
3838
}
3939

@@ -44,7 +44,7 @@ function testQueueMicrotask() {
4444
res.emitDestroy();
4545
// queueMicrotask has higher prio than emit destroy
4646
queueMicrotask(common.mustCall(() =>
47-
assert.strictEqual(activeId, res.asyncId()))
47+
assert.strictEqual(activeId, res.asyncId())),
4848
);
4949
}
5050

@@ -54,7 +54,7 @@ function testImmediate() {
5454
assert.strictEqual(activeId, res.asyncId());
5555
res.emitDestroy();
5656
setImmediate(common.mustCall(() =>
57-
assert.strictEqual(activeId, -1))
57+
assert.strictEqual(activeId, -1)),
5858
);
5959
}
6060

@@ -65,7 +65,7 @@ function testPromise() {
6565
res.emitDestroy();
6666
// Promise has higher prio than emit destroy
6767
Promise.resolve().then(common.mustCall(() =>
68-
assert.strictEqual(activeId, res.asyncId()))
68+
assert.strictEqual(activeId, res.asyncId())),
6969
);
7070
}
7171

test/async-hooks/test-disable-in-init.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ async_hooks.createHook({
1313
nestedCall = true;
1414
fs.access(__filename, common.mustCall());
1515
}
16-
}, 2)
16+
}, 2),
1717
}).enable();
1818

1919
const nestedHook = async_hooks.createHook({
20-
init: common.mustCall(2)
20+
init: common.mustCall(2),
2121
}).enable();
2222

2323
fs.access(__filename, common.mustCall());

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (process.argv[2] === 'child') {
2020
[null, undefined, 1, Date, {}, []].forEach((i) => {
2121
assert.throws(() => new Foo(i), {
2222
code: 'ERR_INVALID_ARG_TYPE',
23-
name: 'TypeError'
23+
name: 'TypeError',
2424
});
2525
});
2626

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ assert.throws(() => {
2626

2727
assert.strictEqual(
2828
new AsyncResource('default_trigger_id').triggerAsyncId(),
29-
async_hooks.executionAsyncId()
29+
async_hooks.executionAsyncId(),
3030
);
3131

3232
// Create first custom event 'alcazares' with triggerAsyncId derived

test/async-hooks/test-emit-after-on-destroyed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
1010

1111
const {
1212
newAsyncId, getDefaultTriggerAsyncId,
13-
emitInit, emitBefore, emitAfter, emitDestroy
13+
emitInit, emitBefore, emitAfter, emitDestroy,
1414
} = internal_async_hooks;
1515

1616
const initHooks = require('./init-hooks');

test/async-hooks/test-emit-before-after.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const checkOnce = (fn) => {
3030
initHooks({
3131
onbefore: checkOnce(chkBefore),
3232
onafter: checkOnce(chkAfter),
33-
allowNoInit: true
33+
allowNoInit: true,
3434
}).enable();
3535

3636
async_hooks.emitInit(expectedId, expectedType, expectedTriggerId);

test/async-hooks/test-emit-before-on-destroyed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
1010

1111
const {
1212
newAsyncId, getDefaultTriggerAsyncId,
13-
emitInit, emitBefore, emitAfter, emitDestroy
13+
emitInit, emitBefore, emitAfter, emitDestroy,
1414
} = internal_async_hooks;
1515

1616
const initHooks = require('./init-hooks');

test/async-hooks/test-emit-init.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const hooks1 = initHooks({
1717
assert.strictEqual(type, expectedType);
1818
assert.strictEqual(triggerAsyncId, expectedTriggerId);
1919
assert.strictEqual(resource.key, expectedResource.key);
20-
})
20+
}),
2121
});
2222

2323
hooks1.enable();
@@ -33,7 +33,7 @@ initHooks({
3333
assert.strictEqual(type, expectedType);
3434
assert.notStrictEqual(triggerAsyncId, expectedTriggerId);
3535
assert.strictEqual(resource.key, expectedResource.key);
36-
})
36+
}),
3737
}).enable();
3838

3939
async_hooks.emitInit(expectedId, expectedType, null, expectedResource);

test/async-hooks/test-enable-in-init.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const async_hooks = require('async_hooks');
55
const fs = require('fs');
66

77
const nestedHook = async_hooks.createHook({
8-
init: common.mustNotCall()
8+
init: common.mustNotCall(),
99
});
1010
let nestedCall = false;
1111

@@ -16,7 +16,7 @@ async_hooks.createHook({
1616
nestedCall = true;
1717
fs.access(__filename, common.mustCall());
1818
}
19-
}, 2)
19+
}, 2),
2020
}).enable();
2121

2222
fs.access(__filename, common.mustCall());

test/async-hooks/test-filehandle-no-reuse.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const hooks = initHooks();
1717
hooks.enable();
1818

1919
const {
20-
HTTP2_HEADER_CONTENT_TYPE
20+
HTTP2_HEADER_CONTENT_TYPE,
2121
} = http2.constants;
2222

2323
// Use large fixture to get several file operations.
@@ -27,7 +27,7 @@ const fd = fs.openSync(fname, 'r');
2727
const server = http2.createServer();
2828
server.on('stream', (stream) => {
2929
stream.respondWithFD(fd, {
30-
[HTTP2_HEADER_CONTENT_TYPE]: 'text/plain'
30+
[HTTP2_HEADER_CONTENT_TYPE]: 'text/plain',
3131
});
3232
});
3333
server.on('close', common.mustCall(() => fs.closeSync(fd)));

test/async-hooks/test-graph.fsreq-readFile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ function onexit() {
2121
[ { type: 'FSREQCALLBACK', id: 'fsreq:1', triggerAsyncId: null },
2222
{ type: 'FSREQCALLBACK', id: 'fsreq:2', triggerAsyncId: 'fsreq:1' },
2323
{ type: 'FSREQCALLBACK', id: 'fsreq:3', triggerAsyncId: 'fsreq:2' },
24-
{ type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ]
24+
{ type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ],
2525
);
2626
}

test/async-hooks/test-graph.http.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ server.listen(0, common.mustCall(() => {
2020
http.get({
2121
host: '::1',
2222
family: 6,
23-
port: server.address().port
23+
port: server.address().port,
2424
}, common.mustCall());
2525
}));
2626

@@ -48,6 +48,6 @@ process.on('exit', () => {
4848
triggerAsyncId: null },
4949
{ type: 'SHUTDOWNWRAP',
5050
id: 'shutdown:1',
51-
triggerAsyncId: 'tcp:2' } ]
51+
triggerAsyncId: 'tcp:2' } ],
5252
);
5353
});

test/async-hooks/test-graph.intervals.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ function onexit() {
3030
verifyGraph(
3131
hooks,
3232
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
33-
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }]
33+
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }],
3434
);
3535
}

test/async-hooks/test-graph.pipe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ function onexit() {
2727
[ { type: 'PROCESSWRAP', id: 'process:1', triggerAsyncId: null },
2828
{ type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null },
2929
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: null },
30-
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ]
30+
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ],
3131
);
3232
}

test/async-hooks/test-graph.pipeconnect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ function onexit() {
3434
{ type: 'PIPECONNECTWRAP', id: 'pipeconnect:1',
3535
triggerAsyncId: 'pipe:1' },
3636
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipeserver:1' },
37-
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ]
37+
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ],
3838
);
3939
}

test/async-hooks/test-graph.shutdown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ function onexit() {
4141
{ type: 'TCPCONNECTWRAP',
4242
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
4343
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
44-
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ]
44+
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ],
4545
);
4646
}

0 commit comments

Comments
 (0)