Skip to content

Commit 78e05da

Browse files
tniessenevanlucas
authored andcommitted
test: use shorthand properties
PR-URL: #18105 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 63be0d6 commit 78e05da

40 files changed

+55
-86
lines changed

test/fixtures/tls-connect.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ exports.connect = function connect(options, callback) {
4444

4545
const server = {};
4646
const client = {};
47-
const pair = {
48-
server: server,
49-
client: client,
50-
};
47+
const pair = { server, client };
5148

5249
tls.createServer(options.server, function(conn) {
5350
server.conn = conn;

test/internet/test-tls-reuse-host-from-socket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const tls = require('tls');
3030
const net = require('net');
3131

3232
const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
33-
const secureSocket = tls.connect({ socket: socket }, common.mustCall(() => {
33+
const secureSocket = tls.connect({ socket }, common.mustCall(() => {
3434
secureSocket.destroy();
3535
console.log('ok');
3636
}));

test/parallel/test-child-process-env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ Object.setPrototypeOf(env, {
3535
let child;
3636
if (common.isWindows) {
3737
child = spawn('cmd.exe', ['/c', 'set'],
38-
Object.assign({}, process.env, { env: env }));
38+
Object.assign({}, process.env, { env }));
3939
} else {
4040
child = spawn('/usr/bin/env', [],
41-
Object.assign({}, process.env, { env: env }));
41+
Object.assign({}, process.env, { env }));
4242
}
4343

4444

test/parallel/test-cluster-dgram-1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function worker() {
102102

103103
// Every 10 messages, notify the master.
104104
if (received === PACKETS_PER_WORKER) {
105-
process.send({ received: received });
105+
process.send({ received });
106106
socket.close();
107107
}
108108
}, PACKETS_PER_WORKER));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if (cluster.isMaster) {
6060

6161
worker = cluster.fork()
6262
.on('online', function() {
63-
this.send({ port: port });
63+
this.send({ port });
6464
});
6565
});
6666
process.on('exit', function() {

test/parallel/test-fs-realpath-buffer-encoding.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ for (encoding in expected) {
2121
const expected_value = expected[encoding];
2222
let result;
2323

24-
result = fs.realpathSync(string_dir, { encoding: encoding });
24+
result = fs.realpathSync(string_dir, { encoding });
2525
assert.strictEqual(result, expected_value);
2626

2727
result = fs.realpathSync(string_dir, encoding);
2828
assert.strictEqual(result, expected_value);
2929

30-
result = fs.realpathSync(buffer_dir, { encoding: encoding });
30+
result = fs.realpathSync(buffer_dir, { encoding });
3131
assert.strictEqual(result, expected_value);
3232

3333
result = fs.realpathSync(buffer_dir, encoding);
@@ -53,7 +53,7 @@ for (encoding in expected) {
5353

5454
fs.realpath(
5555
string_dir,
56-
{ encoding: encoding },
56+
{ encoding },
5757
common.mustCall((err, res) => {
5858
assert.ifError(err);
5959
assert.strictEqual(res, expected_value);
@@ -65,7 +65,7 @@ for (encoding in expected) {
6565
}));
6666
fs.realpath(
6767
buffer_dir,
68-
{ encoding: encoding },
68+
{ encoding },
6969
common.mustCall((err, res) => {
7070
assert.ifError(err);
7171
assert.strictEqual(res, expected_value);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ common.refreshTmpDir();
5151
// Test writeFileSync
5252
const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
5353

54-
fs.writeFileSync(file1, '123', { mode: mode });
54+
fs.writeFileSync(file1, '123', { mode });
5555

5656
content = fs.readFileSync(file1, { encoding: 'utf8' });
5757
assert.strictEqual(content, '123');
@@ -61,7 +61,7 @@ assert.strictEqual(fs.statSync(file1).mode & 0o777, mode);
6161
// Test appendFileSync
6262
const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
6363

64-
fs.appendFileSync(file2, 'abc', { mode: mode });
64+
fs.appendFileSync(file2, 'abc', { mode });
6565

6666
content = fs.readFileSync(file2, { encoding: 'utf8' });
6767
assert.strictEqual(content, 'abc');

test/parallel/test-http-client-read-in-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Agent extends http.Agent {
3434
const agent = new Agent();
3535

3636
http.request({
37-
agent: agent
37+
agent
3838
}).once('error', function() {
3939
console.log('ignore');
4040
});

test/parallel/test-http-pipeline-flood.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function child() {
6666
const net = require('net');
6767

6868
const port = +process.argv[3];
69-
const conn = net.connect({ port: port });
69+
const conn = net.connect({ port });
7070

7171
let req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`;
7272

test/parallel/test-http2-create-client-connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const URL = url.URL;
2222
[`http://localhost:${port}`],
2323
[new URL(`http://localhost:${port}`)],
2424
[url.parse(`http://localhost:${port}`)],
25-
[{ port: port }, { protocol: 'http:' }],
26-
[{ port: port, hostname: '127.0.0.1' }, { protocol: 'http:' }]
25+
[{ port }, { protocol: 'http:' }],
26+
[{ port, hostname: '127.0.0.1' }, { protocol: 'http:' }]
2727
];
2828

2929
const serverClose = new Countdown(items.length + 1,

0 commit comments

Comments
 (0)