diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 934c60d5dec558..69c5af9d305a3c 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -44,6 +44,7 @@ rules: # http://eslint.org/docs/rules/#best-practices accessor-pairs: error dot-location: [error, property] + dot-notation: error eqeqeq: [error, smart] no-fallthrough: error no-global-assign: error diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js index d6afd4e9c0bcbb..fb27f0e5b83d62 100644 --- a/benchmark/misc/object-property-bench.js +++ b/benchmark/misc/object-property-bench.js @@ -1,5 +1,7 @@ 'use strict'; +/* eslint-disable dot-notation */ + const common = require('../common.js'); const bench = common.createBenchmark(main, { diff --git a/doc/api/http2.md b/doc/api/http2.md index cfa018bce231ce..0331d45bb54d74 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1236,7 +1236,7 @@ const server = http2.createServer(); server.on('stream', (stream) => { stream.respond({ ':status': 200 }, { getTrailers(trailers) { - trailers['ABC'] = 'some value to send'; + trailers.ABC = 'some value to send'; } }); stream.end('some data'); @@ -1326,7 +1326,7 @@ server.on('stream', (stream) => { }; stream.respondWithFD(fd, headers, { getTrailers(trailers) { - trailers['ABC'] = 'some value to send'; + trailers.ABC = 'some value to send'; } }); @@ -1435,7 +1435,7 @@ const http2 = require('http2'); const server = http2.createServer(); server.on('stream', (stream) => { function getTrailers(trailers) { - trailers['ABC'] = 'some value to send'; + trailers.ABC = 'some value to send'; } stream.respondWithFile('/some/file', { 'content-type': 'text/plain' }, diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 0b00638e2a638c..e87596d4d5c21b 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -1,6 +1,4 @@ rules: - dot-notation: error - # Custom rules in tools/eslint-rules require-buffer: error buffer-constructor: error diff --git a/test/addons-napi/test_symbol/test1.js b/test/addons-napi/test_symbol/test1.js index 25eb473c4b1b9d..9232210c46da46 100644 --- a/test/addons-napi/test_symbol/test1.js +++ b/test/addons-napi/test_symbol/test1.js @@ -8,11 +8,10 @@ const test_symbol = require(`./build/${common.buildType}/test_symbol`); const sym = test_symbol.New('test'); assert.strictEqual(sym.toString(), 'Symbol(test)'); - const myObj = {}; const fooSym = test_symbol.New('foo'); const otherSym = test_symbol.New('bar'); -myObj['foo'] = 'bar'; +myObj.foo = 'bar'; myObj[fooSym] = 'baz'; myObj[otherSym] = 'bing'; assert.strictEqual(myObj.foo, 'bar'); diff --git a/test/addons-napi/test_symbol/test2.js b/test/addons-napi/test_symbol/test2.js index 60512431110a5b..8bc731b40cb5fe 100644 --- a/test/addons-napi/test_symbol/test2.js +++ b/test/addons-napi/test_symbol/test2.js @@ -7,7 +7,7 @@ const test_symbol = require(`./build/${common.buildType}/test_symbol`); const fooSym = test_symbol.New('foo'); const myObj = {}; -myObj['foo'] = 'bar'; +myObj.foo = 'bar'; myObj[fooSym] = 'baz'; Object.keys(myObj); // -> [ 'foo' ] Object.getOwnPropertyNames(myObj); // -> [ 'foo' ] diff --git a/test/common/index.js b/test/common/index.js index 5433c6472c9ea5..8efd72fc7d162a 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -512,7 +512,7 @@ exports.canCreateSymLink = function() { // whoami.exe needs to be the one from System32 // If unix tools are in the path, they can shadow the one we want, // so use the full path while executing whoami - const whoamiPath = path.join(process.env['SystemRoot'], + const whoamiPath = path.join(process.env.SystemRoot, 'System32', 'whoami.exe'); let err = false; diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index 8fc778555d0454..2a05f58625031f 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -167,9 +167,7 @@ class InspectorSession { reject(message.error); } else { if (message.method === 'Debugger.scriptParsed') { - const script = message['params']; - const scriptId = script['scriptId']; - const url = script['url']; + const { scriptId, url } = message.params; this._scriptsIdsByUrl.set(scriptId, url); if (url === _MAINSCRIPT) this.mainScriptId = scriptId; @@ -188,12 +186,12 @@ class InspectorSession { _sendMessage(message) { const msg = JSON.parse(JSON.stringify(message)); // Clone! - msg['id'] = this._nextId++; + msg.id = this._nextId++; if (DEBUG) console.log('[sent]', JSON.stringify(msg)); const responsePromise = new Promise((resolve, reject) => { - this._commandResponsePromises.set(msg['id'], { resolve, reject }); + this._commandResponsePromises.set(msg.id, { resolve, reject }); }); return new Promise( @@ -238,12 +236,15 @@ class InspectorSession { return notification; } - _isBreakOnLineNotification(message, line, url) { - if ('Debugger.paused' === message['method']) { - const callFrame = message['params']['callFrames'][0]; - const location = callFrame['location']; - assert.strictEqual(url, this._scriptsIdsByUrl.get(location['scriptId'])); - assert.strictEqual(line, location['lineNumber']); + _isBreakOnLineNotification(message, line, expectedScriptPath) { + if ('Debugger.paused' === message.method) { + const callFrame = message.params.callFrames[0]; + const location = callFrame.location; + const scriptPath = this._scriptsIdsByUrl.get(location.scriptId); + assert.strictEqual(scriptPath.toString(), + expectedScriptPath.toString(), + `${scriptPath} !== ${expectedScriptPath}`); + assert.strictEqual(line, location.lineNumber); return true; } } @@ -259,12 +260,12 @@ class InspectorSession { _matchesConsoleOutputNotification(notification, type, values) { if (!Array.isArray(values)) values = [ values ]; - if ('Runtime.consoleAPICalled' === notification['method']) { - const params = notification['params']; - if (params['type'] === type) { + if ('Runtime.consoleAPICalled' === notification.method) { + const params = notification.params; + if (params.type === type) { let i = 0; - for (const value of params['args']) { - if (value['value'] !== values[i++]) + for (const value of params.args) { + if (value.value !== values[i++]) return false; } return i === values.length; @@ -389,7 +390,7 @@ class NodeInstance { async connectInspectorSession() { console.log('[test]', 'Connecting to a child Node process'); const response = await this.httpGet(null, '/json/list'); - const url = response[0]['webSocketDebuggerUrl']; + const url = response[0].webSocketDebuggerUrl; return this.wsHandshake(url); } diff --git a/test/parallel/test-cluster-fork-env.js b/test/parallel/test-cluster-fork-env.js index 5dd28163084a21..57e7881013d0fd 100644 --- a/test/parallel/test-cluster-fork-env.js +++ b/test/parallel/test-cluster-fork-env.js @@ -31,8 +31,8 @@ const cluster = require('cluster'); if (cluster.isWorker) { const result = cluster.worker.send({ - prop: process.env['cluster_test_prop'], - overwrite: process.env['cluster_test_overwrite'] + prop: process.env.cluster_test_prop, + overwrite: process.env.cluster_test_overwrite }); assert.strictEqual(result, true); @@ -45,7 +45,7 @@ if (cluster.isWorker) { // To check that the cluster extend on the process.env we will overwrite a // property - process.env['cluster_test_overwrite'] = 'old'; + process.env.cluster_test_overwrite = 'old'; // Fork worker const worker = cluster.fork({ diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index 72cba6ed5f190c..9f04b19cf3eddc 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -71,13 +71,13 @@ const wikipedia = [ ]; for (let i = 0, l = wikipedia.length; i < l; i++) { - for (const hash in wikipedia[i]['hmac']) { + for (const hash in wikipedia[i].hmac) { // FIPS does not support MD5. if (common.hasFipsCrypto && hash === 'md5') continue; - const expected = wikipedia[i]['hmac'][hash]; - const actual = crypto.createHmac(hash, wikipedia[i]['key']) - .update(wikipedia[i]['data']) + const expected = wikipedia[i].hmac[hash]; + const actual = crypto.createHmac(hash, wikipedia[i].key) + .update(wikipedia[i].data) .digest('hex'); assert.strictEqual( actual, @@ -236,18 +236,18 @@ const rfc4231 = [ ]; for (let i = 0, l = rfc4231.length; i < l; i++) { - for (const hash in rfc4231[i]['hmac']) { + for (const hash in rfc4231[i].hmac) { const str = crypto.createHmac(hash, rfc4231[i].key); str.end(rfc4231[i].data); let strRes = str.read().toString('hex'); - let actual = crypto.createHmac(hash, rfc4231[i]['key']) - .update(rfc4231[i]['data']) + let actual = crypto.createHmac(hash, rfc4231[i].key) + .update(rfc4231[i].data) .digest('hex'); - if (rfc4231[i]['truncate']) { + if (rfc4231[i].truncate) { actual = actual.substr(0, 32); // first 128 bits == 32 hex chars strRes = strRes.substr(0, 32); } - const expected = rfc4231[i]['hmac'][hash]; + const expected = rfc4231[i].hmac[hash]; assert.strictEqual( actual, expected, @@ -368,10 +368,10 @@ const rfc2202_sha1 = [ if (!common.hasFipsCrypto) { for (let i = 0, l = rfc2202_md5.length; i < l; i++) { - const actual = crypto.createHmac('md5', rfc2202_md5[i]['key']) - .update(rfc2202_md5[i]['data']) + const actual = crypto.createHmac('md5', rfc2202_md5[i].key) + .update(rfc2202_md5[i].data) .digest('hex'); - const expected = rfc2202_md5[i]['hmac']; + const expected = rfc2202_md5[i].hmac; assert.strictEqual( actual, expected, @@ -380,10 +380,10 @@ if (!common.hasFipsCrypto) { } } for (let i = 0, l = rfc2202_sha1.length; i < l; i++) { - const actual = crypto.createHmac('sha1', rfc2202_sha1[i]['key']) - .update(rfc2202_sha1[i]['data']) + const actual = crypto.createHmac('sha1', rfc2202_sha1[i].key) + .update(rfc2202_sha1[i].data) .digest('hex'); - const expected = rfc2202_sha1[i]['hmac']; + const expected = rfc2202_sha1[i].hmac; assert.strictEqual( actual, expected, diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js index e24c07506c372e..7688c61a435cfb 100644 --- a/test/parallel/test-event-emitter-check-listener-leaks.js +++ b/test/parallel/test-event-emitter-check-listener-leaks.js @@ -32,9 +32,9 @@ const events = require('events'); for (let i = 0; i < 10; i++) { e.on('default', common.mustNotCall()); } - assert.ok(!e._events['default'].hasOwnProperty('warned')); + assert.ok(!e._events.default.hasOwnProperty('warned')); e.on('default', common.mustNotCall()); - assert.ok(e._events['default'].warned); + assert.ok(e._events.default.warned); // symbol const symbol = Symbol('symbol'); @@ -49,9 +49,9 @@ const events = require('events'); for (let i = 0; i < 5; i++) { e.on('specific', common.mustNotCall()); } - assert.ok(!e._events['specific'].hasOwnProperty('warned')); + assert.ok(!e._events.specific.hasOwnProperty('warned')); e.on('specific', common.mustNotCall()); - assert.ok(e._events['specific'].warned); + assert.ok(e._events.specific.warned); // only one e.setMaxListeners(1); @@ -65,7 +65,7 @@ const events = require('events'); for (let i = 0; i < 1000; i++) { e.on('unlimited', common.mustNotCall()); } - assert.ok(!e._events['unlimited'].hasOwnProperty('warned')); + assert.ok(!e._events.unlimited.hasOwnProperty('warned')); } // process-wide @@ -76,16 +76,16 @@ const events = require('events'); for (let i = 0; i < 42; ++i) { e.on('fortytwo', common.mustNotCall()); } - assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); + assert.ok(!e._events.fortytwo.hasOwnProperty('warned')); e.on('fortytwo', common.mustNotCall()); - assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); - delete e._events['fortytwo'].warned; + assert.ok(e._events.fortytwo.hasOwnProperty('warned')); + delete e._events.fortytwo.warned; events.EventEmitter.defaultMaxListeners = 44; e.on('fortytwo', common.mustNotCall()); - assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); + assert.ok(!e._events.fortytwo.hasOwnProperty('warned')); e.on('fortytwo', common.mustNotCall()); - assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); + assert.ok(e._events.fortytwo.hasOwnProperty('warned')); } // but _maxListeners still has precedence over defaultMaxListeners @@ -94,9 +94,9 @@ const events = require('events'); const e = new events.EventEmitter(); e.setMaxListeners(1); e.on('uno', common.mustNotCall()); - assert.ok(!e._events['uno'].hasOwnProperty('warned')); + assert.ok(!e._events.uno.hasOwnProperty('warned')); e.on('uno', common.mustNotCall()); - assert.ok(e._events['uno'].hasOwnProperty('warned')); + assert.ok(e._events.uno.hasOwnProperty('warned')); // chainable assert.strictEqual(e, e.setMaxListeners(1)); diff --git a/test/parallel/test-http-automatic-headers.js b/test/parallel/test-http-automatic-headers.js index 5a6a8e524c76ee..5e99f1ee39dd6b 100644 --- a/test/parallel/test-http-automatic-headers.js +++ b/test/parallel/test-http-automatic-headers.js @@ -22,8 +22,8 @@ server.on('listening', common.mustCall(() => { assert.strictEqual(res.headers['x-date'], 'foo'); assert.strictEqual(res.headers['x-connection'], 'bar'); assert.strictEqual(res.headers['x-content-length'], 'baz'); - assert(res.headers['date']); - assert.strictEqual(res.headers['connection'], 'keep-alive'); + assert(res.headers.date); + assert.strictEqual(res.headers.connection, 'keep-alive'); assert.strictEqual(res.headers['content-length'], '0'); server.close(); agent.destroy(); diff --git a/test/parallel/test-http-flush-headers.js b/test/parallel/test-http-flush-headers.js index 8ca5e92e5e02bc..88e8bddaed9e54 100644 --- a/test/parallel/test-http-flush-headers.js +++ b/test/parallel/test-http-flush-headers.js @@ -5,7 +5,7 @@ const http = require('http'); const server = http.createServer(); server.on('request', function(req, res) { - assert.strictEqual(req.headers['foo'], 'bar'); + assert.strictEqual(req.headers.foo, 'bar'); res.end('ok'); server.close(); }); diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js index b8045568d49ac7..0f0a1387b56733 100644 --- a/test/parallel/test-http-flush-response-headers.js +++ b/test/parallel/test-http-flush-response-headers.js @@ -20,7 +20,7 @@ server.listen(0, common.localhostIPv4, function() { req.end(); function onResponse(res) { - assert.strictEqual(res.headers['foo'], 'bar'); + assert.strictEqual(res.headers.foo, 'bar'); res.destroy(); server.close(); } diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js index a6267faaa6715c..8781679c0a45b8 100644 --- a/test/parallel/test-http-proxy.js +++ b/test/parallel/test-http-proxy.js @@ -50,7 +50,7 @@ const proxy = http.createServer(function(req, res) { console.error(`proxy res headers: ${JSON.stringify(proxy_res.headers)}`); - assert.strictEqual('world', proxy_res.headers['hello']); + assert.strictEqual('world', proxy_res.headers.hello); assert.strictEqual('text/plain', proxy_res.headers['content-type']); assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']); @@ -81,7 +81,7 @@ function startReq() { console.error('got res'); assert.strictEqual(200, res.statusCode); - assert.strictEqual('world', res.headers['hello']); + assert.strictEqual('world', res.headers.hello); assert.strictEqual('text/plain', res.headers['content-type']); assert.deepStrictEqual(cookies, res.headers['set-cookie']); diff --git a/test/parallel/test-http-server-multiheaders.js b/test/parallel/test-http-server-multiheaders.js index 201a95c346ae65..bf918ad24cc168 100644 --- a/test/parallel/test-http-server-multiheaders.js +++ b/test/parallel/test-http-server-multiheaders.js @@ -38,7 +38,7 @@ const srv = http.createServer(function(req, res) { assert.strictEqual(req.headers['sec-websocket-protocol'], 'chat, share'); assert.strictEqual(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz'); - assert.strictEqual(req.headers['constructor'], 'foo, bar, baz'); + assert.strictEqual(req.headers.constructor, 'foo, bar, baz'); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('EOF'); diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js index 143643c4be4eaf..ae776753f2049f 100644 --- a/test/parallel/test-http-write-head.js +++ b/test/parallel/test-http-write-head.js @@ -66,7 +66,7 @@ s.listen(0, common.mustCall(runTest)); function runTest() { http.get({ port: this.address().port }, common.mustCall((response) => { response.on('end', common.mustCall(() => { - assert.strictEqual(response.headers['test'], '2'); + assert.strictEqual(response.headers.test, '2'); assert(response.rawHeaders.includes('Test')); s.close(); })); diff --git a/test/parallel/test-http.js b/test/parallel/test-http.js index 52bebc476e1510..e9a48c0fba3826 100644 --- a/test/parallel/test-http.js +++ b/test/parallel/test-http.js @@ -33,8 +33,8 @@ const server = http.Server(common.mustCall(function(req, res) { switch (req.url) { case '/hello': assert.strictEqual(req.method, 'GET'); - assert.strictEqual(req.headers['accept'], '*/*'); - assert.strictEqual(req.headers['foo'], 'bar'); + assert.strictEqual(req.headers.accept, '*/*'); + assert.strictEqual(req.headers.foo, 'bar'); assert.strictEqual(req.headers.cookie, 'foo=bar; bar=baz; baz=quux'); break; case '/there': diff --git a/test/parallel/test-http2-compat-expect-handling.js b/test/parallel/test-http2-compat-expect-handling.js index f36032c972fc45..e987118476337d 100644 --- a/test/parallel/test-http2-compat-expect-handling.js +++ b/test/parallel/test-http2-compat-expect-handling.js @@ -11,7 +11,7 @@ const expectValue = 'meoww'; const server = http2.createServer(common.mustNotCall()); server.once('checkExpectation', common.mustCall((req, res) => { - assert.strictEqual(req.headers['expect'], expectValue); + assert.strictEqual(req.headers.expect, expectValue); res.statusCode = 417; res.end(); })); diff --git a/test/parallel/test-http2-compat-serverresponse-createpushresponse.js b/test/parallel/test-http2-compat-serverresponse-createpushresponse.js index 18b3ba15be841c..1b9aa66808eeff 100755 --- a/test/parallel/test-http2-compat-serverresponse-createpushresponse.js +++ b/test/parallel/test-http2-compat-serverresponse-createpushresponse.js @@ -77,7 +77,7 @@ server.listen(0, common.mustCall(() => { let actual = ''; pushStream.on('push', common.mustCall((headers) => { assert.strictEqual(headers[':status'], 200); - assert(headers['date']); + assert(headers.date); })); pushStream.setEncoding('utf8'); pushStream.on('data', (chunk) => actual += chunk); @@ -89,7 +89,7 @@ server.listen(0, common.mustCall(() => { req.on('response', common.mustCall((headers) => { assert.strictEqual(headers[':status'], 200); - assert(headers['date']); + assert(headers.date); })); let actual = ''; diff --git a/test/parallel/test-http2-create-client-secure-session.js b/test/parallel/test-http2-create-client-secure-session.js index b0111e15b69c15..1f20ec8e42a871 100644 --- a/test/parallel/test-http2-create-client-secure-session.js +++ b/test/parallel/test-http2-create-client-secure-session.js @@ -62,7 +62,7 @@ function verifySecureSession(key, cert, ca, opts) { req.on('response', common.mustCall((headers) => { assert.strictEqual(headers[':status'], 200); assert.strictEqual(headers['content-type'], 'application/json'); - assert(headers['date']); + assert(headers.date); })); let data = ''; diff --git a/test/parallel/test-http2-create-client-session.js b/test/parallel/test-http2-create-client-session.js index 963db2faa173b7..34e4e975d92d81 100644 --- a/test/parallel/test-http2-create-client-session.js +++ b/test/parallel/test-http2-create-client-session.js @@ -58,7 +58,7 @@ server.on('listening', common.mustCall(() => { assert.strictEqual(headers[':status'], 200, 'status code is set'); assert.strictEqual(headers['content-type'], 'text/html', 'content type is set'); - assert(headers['date'], 'there is a date'); + assert(headers.date); })); let data = ''; diff --git a/test/parallel/test-http2-multiheaders-raw.js b/test/parallel/test-http2-multiheaders-raw.js index 50486450d5aeb7..da9aa3a68eaa51 100644 --- a/test/parallel/test-http2-multiheaders-raw.js +++ b/test/parallel/test-http2-multiheaders-raw.js @@ -12,7 +12,7 @@ const src = Object.create(null); src['www-authenticate'] = 'foo'; src['WWW-Authenticate'] = 'bar'; src['WWW-AUTHENTICATE'] = 'baz'; -src['test'] = 'foo, bar, baz'; +src.test = 'foo, bar, baz'; server.on('stream', common.mustCall((stream, headers, flags, rawHeaders) => { const expected = [ diff --git a/test/parallel/test-http2-multiheaders.js b/test/parallel/test-http2-multiheaders.js index 9bf8f76d22e60e..6611dcf054d42a 100644 --- a/test/parallel/test-http2-multiheaders.js +++ b/test/parallel/test-http2-multiheaders.js @@ -24,21 +24,21 @@ src.constructor = 'foo'; src.Constructor = 'bar'; src.CONSTRUCTOR = 'baz'; // eslint-disable-next-line no-proto -src['__proto__'] = 'foo'; -src['__PROTO__'] = 'bar'; -src['__Proto__'] = 'baz'; +src.__proto__ = 'foo'; +src.__PROTO__ = 'bar'; +src.__Proto__ = 'baz'; function checkHeaders(headers) { - assert.deepStrictEqual(headers['accept'], + assert.deepStrictEqual(headers.accept, 'abc, def, ghijklmnop'); assert.deepStrictEqual(headers['www-authenticate'], 'foo, bar, baz'); assert.deepStrictEqual(headers['proxy-authenticate'], 'foo, bar, baz'); assert.deepStrictEqual(headers['x-foo'], 'foo, bar, baz'); - assert.deepStrictEqual(headers['constructor'], 'foo, bar, baz'); + assert.deepStrictEqual(headers.constructor, 'foo, bar, baz'); // eslint-disable-next-line no-proto - assert.deepStrictEqual(headers['__proto__'], 'foo, bar, baz'); + assert.deepStrictEqual(headers.__proto__, 'foo, bar, baz'); } server.on('stream', common.mustCall((stream, headers) => { diff --git a/test/parallel/test-http2-server-rst-stream.js b/test/parallel/test-http2-server-rst-stream.js index 4b59a5ebe859bc..4a58091aa61d7f 100644 --- a/test/parallel/test-http2-server-rst-stream.js +++ b/test/parallel/test-http2-server-rst-stream.js @@ -26,7 +26,7 @@ const tests = [ const server = http2.createServer(); server.on('stream', (stream, headers) => { - stream.close(headers['rstcode'] | 0); + stream.close(headers.rstcode | 0); }); server.listen(0, common.mustCall(() => { diff --git a/test/parallel/test-http2-server-set-header.js b/test/parallel/test-http2-server-set-header.js index 4b6228053f8ece..83f373ec21b314 100644 --- a/test/parallel/test-http2-server-set-header.js +++ b/test/parallel/test-http2-server-set-header.js @@ -20,7 +20,7 @@ server.listen(0, common.mustCall(() => { const req = client.request(headers); req.setEncoding('utf8'); req.on('response', common.mustCall(function(headers) { - assert.strictEqual(headers['foobar'], 'baz'); + assert.strictEqual(headers.foobar, 'baz'); assert.strictEqual(headers['x-powered-by'], 'node-test'); })); diff --git a/test/parallel/test-https-agent-session-reuse.js b/test/parallel/test-https-agent-session-reuse.js index 0330e111e9bd47..0717a3f8165d67 100644 --- a/test/parallel/test-https-agent-session-reuse.js +++ b/test/parallel/test-https-agent-session-reuse.js @@ -112,11 +112,11 @@ const server = https.createServer(options, function(req, res) { process.on('exit', function() { assert.strictEqual(serverRequests, 6); - assert.strictEqual(clientSessions['first'].toString('hex'), + assert.strictEqual(clientSessions.first.toString('hex'), clientSessions['first-reuse'].toString('hex')); - assert.notStrictEqual(clientSessions['first'].toString('hex'), + assert.notStrictEqual(clientSessions.first.toString('hex'), clientSessions['cipher-change'].toString('hex')); - assert.notStrictEqual(clientSessions['first'].toString('hex'), + assert.notStrictEqual(clientSessions.first.toString('hex'), clientSessions['before-drop'].toString('hex')); assert.notStrictEqual(clientSessions['cipher-change'].toString('hex'), clientSessions['before-drop'].toString('hex')); diff --git a/test/parallel/test-internal-util-decorate-error-stack.js b/test/parallel/test-internal-util-decorate-error-stack.js index d428e3c7ee2a7b..95f96ea5805d76 100644 --- a/test/parallel/test-internal-util-decorate-error-stack.js +++ b/test/parallel/test-internal-util-decorate-error-stack.js @@ -7,8 +7,8 @@ const internalUtil = require('internal/util'); const binding = process.binding('util'); const spawnSync = require('child_process').spawnSync; -const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol']; -const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; +const kArrowMessagePrivateSymbolIndex = binding.arrow_message_private_symbol; +const kDecoratedPrivateSymbolIndex = binding.decorated_private_symbol; const decorateErrorStack = internalUtil.decorateErrorStack; diff --git a/test/parallel/test-memory-usage-emfile.js b/test/parallel/test-memory-usage-emfile.js index c5345079a7f47b..f8d1fc90da7aec 100644 --- a/test/parallel/test-memory-usage-emfile.js +++ b/test/parallel/test-memory-usage-emfile.js @@ -10,4 +10,4 @@ while (files.length < 256) files.push(fs.openSync(__filename, 'r')); const r = process.memoryUsage(); -assert.strictEqual(true, r['rss'] > 0); +assert.strictEqual(true, r.rss > 0); diff --git a/test/parallel/test-module-globalpaths-nodepath.js b/test/parallel/test-module-globalpaths-nodepath.js index dce5bf12c1604e..c4492169ad7e81 100644 --- a/test/parallel/test-module-globalpaths-nodepath.js +++ b/test/parallel/test-module-globalpaths-nodepath.js @@ -30,11 +30,11 @@ const partC = ''; if (common.isWindows) { partA = 'C:\\Users\\Rocko Artischocko\\AppData\\Roaming\\npm'; partB = 'C:\\Program Files (x86)\\nodejs\\'; - process.env['NODE_PATH'] = `${partA};${partB};${partC}`; + process.env.NODE_PATH = `${partA};${partB};${partC}`; } else { partA = '/usr/test/lib/node_modules'; partB = '/usr/test/lib/node'; - process.env['NODE_PATH'] = `${partA}:${partB}:${partC}`; + process.env.NODE_PATH = `${partA}:${partB}:${partC}`; } mod._initPaths(); diff --git a/test/parallel/test-module-loading-globalpaths.js b/test/parallel/test-module-loading-globalpaths.js index e82e6ad4b9dd45..aff96543735428 100644 --- a/test/parallel/test-module-loading-globalpaths.js +++ b/test/parallel/test-module-loading-globalpaths.js @@ -42,14 +42,14 @@ if (process.argv[2] === 'child') { const env = Object.assign({}, process.env); // Turn on module debug to aid diagnosing failures. - env['NODE_DEBUG'] = 'module'; + env.NODE_DEBUG = 'module'; // Unset NODE_PATH. - delete env['NODE_PATH']; + delete env.NODE_PATH; // Test empty global path. const noPkgHomeDir = path.join(tmpdir.path, 'home-no-pkg'); fs.mkdirSync(noPkgHomeDir); - env['HOME'] = env['USERPROFILE'] = noPkgHomeDir; + env.HOME = env.USERPROFILE = noPkgHomeDir; assert.throws( () => { child_process.execFileSync(testExecPath, [ __filename, 'child' ], @@ -59,17 +59,17 @@ if (process.argv[2] === 'child') { // Test module in $HOME/.node_modules. const modHomeDir = path.join(testFixturesDir, 'home-pkg-in-node_modules'); - env['HOME'] = env['USERPROFILE'] = modHomeDir; + env.HOME = env.USERPROFILE = modHomeDir; runTest('$HOME/.node_modules', env); // Test module in $HOME/.node_libraries. const libHomeDir = path.join(testFixturesDir, 'home-pkg-in-node_libraries'); - env['HOME'] = env['USERPROFILE'] = libHomeDir; + env.HOME = env.USERPROFILE = libHomeDir; runTest('$HOME/.node_libraries', env); // Test module both $HOME/.node_modules and $HOME/.node_libraries. const bothHomeDir = path.join(testFixturesDir, 'home-pkg-in-both'); - env['HOME'] = env['USERPROFILE'] = bothHomeDir; + env.HOME = env.USERPROFILE = bothHomeDir; runTest('$HOME/.node_modules', env); // Test module in $PREFIX/lib/node. @@ -82,22 +82,22 @@ if (process.argv[2] === 'child') { const pkgPath = path.join(prefixLibNodePath, `${pkgName}.js`); fs.writeFileSync(pkgPath, `exports.string = '${expectedString}';`); - env['HOME'] = env['USERPROFILE'] = noPkgHomeDir; + env.HOME = env.USERPROFILE = noPkgHomeDir; runTest(expectedString, env); // Test module in all global folders. - env['HOME'] = env['USERPROFILE'] = bothHomeDir; + env.HOME = env.USERPROFILE = bothHomeDir; runTest('$HOME/.node_modules', env); // Test module in NODE_PATH is loaded ahead of global folders. - env['HOME'] = env['USERPROFILE'] = bothHomeDir; - env['NODE_PATH'] = path.join(testFixturesDir, 'node_path'); + env.HOME = env.USERPROFILE = bothHomeDir; + env.NODE_PATH = path.join(testFixturesDir, 'node_path'); runTest('$NODE_PATH', env); // Test module in local folder is loaded ahead of global folders. const localDir = path.join(testFixturesDir, 'local-pkg'); - env['HOME'] = env['USERPROFILE'] = bothHomeDir; - env['NODE_PATH'] = path.join(testFixturesDir, 'node_path'); + env.HOME = env.USERPROFILE = bothHomeDir; + env.NODE_PATH = path.join(testFixturesDir, 'node_path'); const child = child_process.execFileSync(testExecPath, [ path.join(localDir, 'test.js') ], { encoding: 'utf8', env: env }); diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index ed628204025b16..a50a0354c74014 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -24,7 +24,7 @@ const cipherlist = { }; function test(size, type, name, next) { - const cipher = type ? cipherlist[type] : cipherlist['NOT_PFS']; + const cipher = type ? cipherlist[type] : cipherlist.NOT_PFS; if (name) tls.DEFAULT_ECDH_CURVE = name; diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index d9f8e30616657d..00ee7c0f80141e 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -273,7 +273,7 @@ assert.strictEqual( '{ writeonly: [Setter] }'); const value = {}; - value['a'] = value; + value.a = value; assert.strictEqual(util.inspect(value), '{ a: [Circular] }'); } diff --git a/test/parallel/test-util-internal.js b/test/parallel/test-util-internal.js index 63e782f15de1e8..cb3d3122f9be4e 100644 --- a/test/parallel/test-util-internal.js +++ b/test/parallel/test-util-internal.js @@ -6,7 +6,7 @@ const assert = require('assert'); const fixtures = require('../common/fixtures'); const binding = process.binding('util'); -const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol']; +const kArrowMessagePrivateSymbolIndex = binding.arrow_message_private_symbol; function getHiddenValue(obj, index) { return function() { diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js index 1f1679b5e149f8..5dd8d9ab14ea4f 100644 --- a/test/sequential/test-init.js +++ b/test/sequential/test-init.js @@ -25,7 +25,7 @@ const assert = require('assert'); const child = require('child_process'); const fixtures = require('../common/fixtures'); -if (process.env['TEST_INIT']) { +if (process.env.TEST_INIT) { return process.stdout.write('Loaded successfully!'); } diff --git a/test/sequential/test-inspector-bindings.js b/test/sequential/test-inspector-bindings.js index b2140c11a3329a..bf97d8b5124e86 100644 --- a/test/sequential/test-inspector-bindings.js +++ b/test/sequential/test-inspector-bindings.js @@ -27,9 +27,9 @@ function checkScope(session, scopeId) { } function debuggerPausedCallback(session, notification) { - const params = notification['params']; - const callFrame = params['callFrames'][0]; - const scopeId = callFrame['scopeChain'][0]['object']['objectId']; + const params = notification.params; + const callFrame = params.callFrames[0]; + const scopeId = callFrame.scopeChain[0].object.objectId; checkScope(session, scopeId); } @@ -65,11 +65,11 @@ function testSampleDebugSession() { scopeCallback = function(error, result) { const i = cur++; let v, actual, expected; - for (v of result['result']) { - actual = v['value']['value']; - expected = expects[v['name']][i]; + for (v of result.result) { + actual = v.value.value; + expected = expects[v.name][i]; if (actual !== expected) { - failures.push(`Iteration ${i} variable: ${v['name']} ` + + failures.push(`Iteration ${i} variable: ${v.name} ` + `expected: ${expected} actual: ${actual}`); } } diff --git a/test/sequential/test-inspector-ip-detection.js b/test/sequential/test-inspector-ip-detection.js index f7dee4494d3c03..fb86b3ea4a574e 100644 --- a/test/sequential/test-inspector-ip-detection.js +++ b/test/sequential/test-inspector-ip-detection.js @@ -14,12 +14,12 @@ if (!ip) function checkIpAddress(ip, response) { const res = response[0]; - const wsUrl = res['webSocketDebuggerUrl']; + const wsUrl = res.webSocketDebuggerUrl; assert.ok(wsUrl); const match = wsUrl.match(/^ws:\/\/(.*):\d+\/(.*)/); assert.strictEqual(ip, match[1]); - assert.strictEqual(res['id'], match[2]); - assert.strictEqual(ip, res['devtoolsFrontendUrl'].match(/.*ws=(.*):\d+/)[1]); + assert.strictEqual(res.id, match[2]); + assert.strictEqual(ip, res.devtoolsFrontendUrl.match(/.*ws=(.*):\d+/)[1]); } function pickIPv4Address() { diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js index 992a12e90229ed..50fcff2d425655 100644 --- a/test/sequential/test-inspector.js +++ b/test/sequential/test-inspector.js @@ -10,10 +10,10 @@ const { mainScriptPath, function checkListResponse(response) { assert.strictEqual(1, response.length); - assert.ok(response[0]['devtoolsFrontendUrl']); + assert.ok(response[0].devtoolsFrontendUrl); assert.ok( /ws:\/\/127\.0\.0\.1:\d+\/[0-9A-Fa-f]{8}-/ - .test(response[0]['webSocketDebuggerUrl'])); + .test(response[0].webSocketDebuggerUrl)); } function checkVersion(response) { @@ -33,7 +33,7 @@ function checkBadPath(err) { } function checkException(message) { - assert.strictEqual(message['exceptionDetails'], undefined, + assert.strictEqual(message.exceptionDetails, undefined, 'An exception occurred during execution'); } @@ -46,10 +46,10 @@ function assertNoUrlsWhileConnected(response) { function assertScopeValues({ result }, expected) { const unmatched = new Set(Object.keys(expected)); for (const actual of result) { - const value = expected[actual['name']]; + const value = expected[actual.name]; if (value) { - assert.strictEqual(value, actual['value']['value']); - unmatched.delete(actual['name']); + assert.strictEqual(value, actual.value.value); + unmatched.delete(actual.name); } } if (unmatched.size) @@ -125,14 +125,14 @@ async function testBreakpoint(session) { } }); - assert.strictEqual(1002, result['value']); + assert.strictEqual(1002, result.value); result = (await session.send({ 'method': 'Runtime.evaluate', 'params': { 'expression': '5 * 5' } })).result; - assert.strictEqual(25, result['value']); + assert.strictEqual(25, result.value); } async function testI18NCharacters(session) { @@ -169,7 +169,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.strictEqual(result['result']['value'], true); + assert.strictEqual(result.result.value, true); // the global require has the same properties as a normal `require` result = await session.send( @@ -184,7 +184,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.strictEqual(result['result']['value'], true); + assert.strictEqual(result.result.value, true); // `require` twice returns the same value result = await session.send( { @@ -200,7 +200,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.strictEqual(result['result']['value'], true); + assert.strictEqual(result.result.value, true); // after require the module appears in require.cache result = await session.send( { @@ -212,7 +212,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.deepStrictEqual(JSON.parse(result['result']['value']), + assert.deepStrictEqual(JSON.parse(result.result.value), { old: 'yes' }); // remove module from require.cache result = await session.send( @@ -223,7 +223,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.strictEqual(result['result']['value'], true); + assert.strictEqual(result.result.value, true); // require again, should get fresh (empty) exports result = await session.send( { @@ -233,7 +233,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.deepStrictEqual(JSON.parse(result['result']['value']), {}); + assert.deepStrictEqual(JSON.parse(result.result.value), {}); // require 2nd module, exports an empty object result = await session.send( { @@ -243,7 +243,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.deepStrictEqual(JSON.parse(result['result']['value']), {}); + assert.deepStrictEqual(JSON.parse(result.result.value), {}); // both modules end up with the same module.parent result = await session.send( { @@ -258,7 +258,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.deepStrictEqual(JSON.parse(result['result']['value']), { + assert.deepStrictEqual(JSON.parse(result.result.value), { parentsEqual: true, parentId: '' }); @@ -275,7 +275,7 @@ async function testCommandLineAPI(session) { } }); checkException(result); - assert.notStrictEqual(result['result']['value'], + assert.notStrictEqual(result.result.value, ''); }