Skip to content

Commit d55e4ad

Browse files
BridgeARMylesBorins
authored andcommitted
test,benchmark,doc: enable dot-notation rule
This enables the eslint dot-notation rule for all code instead of only in /lib. PR-URL: #18749 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com>
1 parent 35e691c commit d55e4ad

38 files changed

Lines changed: 132 additions & 131 deletions

‎.eslintrc.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ rules:
4444
# http://eslint.org/docs/rules/#best-practices
4545
accessor-pairs: error
4646
dot-location: [error, property]
47+
dot-notation: error
4748
eqeqeq: [error, smart]
4849
no-fallthrough: error
4950
no-global-assign: error

‎benchmark/misc/object-property-bench.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* eslint-disable dot-notation */
4+
35
constcommon=require('../common.js');
46

57
constbench=common.createBenchmark(main,{

‎doc/api/http2.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ const server = http2.createServer();
12361236
server.on('stream', (stream) => {
12371237
stream.respond({ ':status':200 }, {
12381238
getTrailers(trailers) {
1239-
trailers['ABC']='some value to send';
1239+
trailers.ABC='some value to send';
12401240
}
12411241
});
12421242
stream.end('some data');
@@ -1326,7 +1326,7 @@ server.on('stream', (stream) => {
13261326
};
13271327
stream.respondWithFD(fd, headers, {
13281328
getTrailers(trailers) {
1329-
trailers['ABC']='some value to send';
1329+
trailers.ABC='some value to send';
13301330
}
13311331
});
13321332

@@ -1435,7 +1435,7 @@ const http2 = require('http2');
14351435
constserver=http2.createServer();
14361436
server.on('stream', (stream) => {
14371437
functiongetTrailers(trailers) {
1438-
trailers['ABC']='some value to send';
1438+
trailers.ABC='some value to send';
14391439
}
14401440
stream.respondWithFile('/some/file',
14411441
{ 'content-type':'text/plain' },

‎lib/.eslintrc.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
rules:
2-
dot-notation: error
3-
42
# Custom rules in tools/eslint-rules
53
require-buffer: error
64
buffer-constructor: error

‎test/addons-napi/test_symbol/test1.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ const test_symbol = require(`./build/${common.buildType}/test_symbol`);
88
constsym=test_symbol.New('test');
99
assert.strictEqual(sym.toString(),'Symbol(test)');
1010

11-
1211
constmyObj={};
1312
constfooSym=test_symbol.New('foo');
1413
constotherSym=test_symbol.New('bar');
15-
myObj['foo']='bar';
14+
myObj.foo='bar';
1615
myObj[fooSym]='baz';
1716
myObj[otherSym]='bing';
1817
assert.strictEqual(myObj.foo,'bar');

‎test/addons-napi/test_symbol/test2.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const test_symbol = require(`./build/${common.buildType}/test_symbol`);
77

88
constfooSym=test_symbol.New('foo');
99
constmyObj={};
10-
myObj['foo']='bar';
10+
myObj.foo='bar';
1111
myObj[fooSym]='baz';
1212
Object.keys(myObj);// -> [ 'foo' ]
1313
Object.getOwnPropertyNames(myObj);// -> [ 'foo' ]

‎test/common/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ exports.canCreateSymLink = function() {
512512
// whoami.exe needs to be the one from System32
513513
// If unix tools are in the path, they can shadow the one we want,
514514
// so use the full path while executing whoami
515-
constwhoamiPath=path.join(process.env['SystemRoot'],
515+
constwhoamiPath=path.join(process.env.SystemRoot,
516516
'System32','whoami.exe');
517517

518518
leterr=false;

‎test/common/inspector-helper.js‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ class InspectorSession {
167167
reject(message.error);
168168
}else{
169169
if(message.method==='Debugger.scriptParsed'){
170-
constscript=message['params'];
171-
constscriptId=script['scriptId'];
172-
consturl=script['url'];
170+
const{ scriptId, url }=message.params;
173171
this._scriptsIdsByUrl.set(scriptId,url);
174172
if(url===_MAINSCRIPT)
175173
this.mainScriptId=scriptId;
@@ -188,12 +186,12 @@ class InspectorSession {
188186

189187
_sendMessage(message){
190188
constmsg=JSON.parse(JSON.stringify(message));// Clone!
191-
msg['id']=this._nextId++;
189+
msg.id=this._nextId++;
192190
if(DEBUG)
193191
console.log('[sent]',JSON.stringify(msg));
194192

195193
constresponsePromise=newPromise((resolve,reject)=>{
196-
this._commandResponsePromises.set(msg['id'],{ resolve, reject });
194+
this._commandResponsePromises.set(msg.id,{ resolve, reject });
197195
});
198196

199197
returnnewPromise(
@@ -238,12 +236,15 @@ class InspectorSession {
238236
returnnotification;
239237
}
240238

241-
_isBreakOnLineNotification(message,line,url){
242-
if('Debugger.paused'===message['method']){
243-
constcallFrame=message['params']['callFrames'][0];
244-
constlocation=callFrame['location'];
245-
assert.strictEqual(url,this._scriptsIdsByUrl.get(location['scriptId']));
246-
assert.strictEqual(line,location['lineNumber']);
239+
_isBreakOnLineNotification(message,line,expectedScriptPath){
240+
if('Debugger.paused'===message.method){
241+
constcallFrame=message.params.callFrames[0];
242+
constlocation=callFrame.location;
243+
constscriptPath=this._scriptsIdsByUrl.get(location.scriptId);
244+
assert.strictEqual(scriptPath.toString(),
245+
expectedScriptPath.toString(),
246+
`${scriptPath} !== ${expectedScriptPath}`);
247+
assert.strictEqual(line,location.lineNumber);
247248
returntrue;
248249
}
249250
}
@@ -259,12 +260,12 @@ class InspectorSession {
259260
_matchesConsoleOutputNotification(notification,type,values){
260261
if(!Array.isArray(values))
261262
values=[values];
262-
if('Runtime.consoleAPICalled'===notification['method']){
263-
constparams=notification['params'];
264-
if(params['type']===type){
263+
if('Runtime.consoleAPICalled'===notification.method){
264+
constparams=notification.params;
265+
if(params.type===type){
265266
leti=0;
266-
for(constvalueofparams['args']){
267-
if(value['value']!==values[i++])
267+
for(constvalueofparams.args){
268+
if(value.value!==values[i++])
268269
returnfalse;
269270
}
270271
returni===values.length;
@@ -389,7 +390,7 @@ class NodeInstance {
389390
asyncconnectInspectorSession(){
390391
console.log('[test]','Connecting to a child Node process');
391392
constresponse=awaitthis.httpGet(null,'/json/list');
392-
consturl=response[0]['webSocketDebuggerUrl'];
393+
consturl=response[0].webSocketDebuggerUrl;
393394
returnthis.wsHandshake(url);
394395
}
395396

‎test/parallel/test-cluster-fork-env.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const cluster = require('cluster');
3131

3232
if(cluster.isWorker){
3333
constresult=cluster.worker.send({
34-
prop: process.env['cluster_test_prop'],
35-
overwrite: process.env['cluster_test_overwrite']
34+
prop: process.env.cluster_test_prop,
35+
overwrite: process.env.cluster_test_overwrite
3636
});
3737

3838
assert.strictEqual(result,true);
@@ -45,7 +45,7 @@ if (cluster.isWorker) {
4545

4646
// To check that the cluster extend on the process.env we will overwrite a
4747
// property
48-
process.env['cluster_test_overwrite']='old';
48+
process.env.cluster_test_overwrite='old';
4949

5050
// Fork worker
5151
constworker=cluster.fork({

‎test/parallel/test-crypto-hmac.js‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ const wikipedia = [
7171
];
7272

7373
for(leti=0,l=wikipedia.length;i<l;i++){
74-
for(consthashinwikipedia[i]['hmac']){
74+
for(consthashinwikipedia[i].hmac){
7575
// FIPS does not support MD5.
7676
if(common.hasFipsCrypto&&hash==='md5')
7777
continue;
78-
constexpected=wikipedia[i]['hmac'][hash];
79-
constactual=crypto.createHmac(hash,wikipedia[i]['key'])
80-
.update(wikipedia[i]['data'])
78+
constexpected=wikipedia[i].hmac[hash];
79+
constactual=crypto.createHmac(hash,wikipedia[i].key)
80+
.update(wikipedia[i].data)
8181
.digest('hex');
8282
assert.strictEqual(
8383
actual,
@@ -236,18 +236,18 @@ const rfc4231 = [
236236
];
237237

238238
for(leti=0,l=rfc4231.length;i<l;i++){
239-
for(consthashinrfc4231[i]['hmac']){
239+
for(consthashinrfc4231[i].hmac){
240240
conststr=crypto.createHmac(hash,rfc4231[i].key);
241241
str.end(rfc4231[i].data);
242242
letstrRes=str.read().toString('hex');
243-
letactual=crypto.createHmac(hash,rfc4231[i]['key'])
244-
.update(rfc4231[i]['data'])
243+
letactual=crypto.createHmac(hash,rfc4231[i].key)
244+
.update(rfc4231[i].data)
245245
.digest('hex');
246-
if(rfc4231[i]['truncate']){
246+
if(rfc4231[i].truncate){
247247
actual=actual.substr(0,32);// first 128 bits == 32 hex chars
248248
strRes=strRes.substr(0,32);
249249
}
250-
constexpected=rfc4231[i]['hmac'][hash];
250+
constexpected=rfc4231[i].hmac[hash];
251251
assert.strictEqual(
252252
actual,
253253
expected,
@@ -368,10 +368,10 @@ const rfc2202_sha1 = [
368368

369369
if(!common.hasFipsCrypto){
370370
for(leti=0,l=rfc2202_md5.length;i<l;i++){
371-
constactual=crypto.createHmac('md5',rfc2202_md5[i]['key'])
372-
.update(rfc2202_md5[i]['data'])
371+
constactual=crypto.createHmac('md5',rfc2202_md5[i].key)
372+
.update(rfc2202_md5[i].data)
373373
.digest('hex');
374-
constexpected=rfc2202_md5[i]['hmac'];
374+
constexpected=rfc2202_md5[i].hmac;
375375
assert.strictEqual(
376376
actual,
377377
expected,
@@ -380,10 +380,10 @@ if (!common.hasFipsCrypto) {
380380
}
381381
}
382382
for(leti=0,l=rfc2202_sha1.length;i<l;i++){
383-
constactual=crypto.createHmac('sha1',rfc2202_sha1[i]['key'])
384-
.update(rfc2202_sha1[i]['data'])
383+
constactual=crypto.createHmac('sha1',rfc2202_sha1[i].key)
384+
.update(rfc2202_sha1[i].data)
385385
.digest('hex');
386-
constexpected=rfc2202_sha1[i]['hmac'];
386+
constexpected=rfc2202_sha1[i].hmac;
387387
assert.strictEqual(
388388
actual,
389389
expected,

0 commit comments

Comments
 (0)