diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-10-17 01:37:14 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2017-10-24 00:21:11 +0300 |
commit | 509b3b81d68095cee8a0c732b527072bc9537260 (patch) | |
tree | 1890b6b09113740971d7e97aeabd21a44ce7118b /test | |
parent | 0ddb00d3c224184c0ad6efa8a8bdae0fcebeb13e (diff) |
tools: enable additional eslint rules
Enable additional rules that node either already adheres to
or it makes sense to do so going forward: for-direction,
accessor-pairs, no-lonely-if and symbol-description.
Fix all instances of no-lonely-if in lib & test and disable
accessor-pairs in test-util-inspect.
PR-URL: https://github.com/nodejs/node/pull/16243
Refs: https://eslint.org/docs/rules/for-direction
Refs: https://eslint.org/docs/rules/accessor-pairs
Refs: https://eslint.org/docs/rules/no-lonely-if
Refs: https://eslint.org/docs/rules/symbol-description
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/.eslintrc.yaml | 1 | ||||
-rw-r--r-- | test/abort/test-abort-uncaught-exception.js | 7 | ||||
-rw-r--r-- | test/parallel/test-cluster-disconnect-unshared-tcp.js | 8 | ||||
-rw-r--r-- | test/parallel/test-cluster-disconnect-unshared-udp.js | 8 | ||||
-rw-r--r-- | test/parallel/test-cluster-worker-destroy.js | 22 | ||||
-rw-r--r-- | test/parallel/test-tls-server-verify.js | 26 | ||||
-rw-r--r-- | test/parallel/test-util-inspect.js | 3 |
7 files changed, 35 insertions, 40 deletions
diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 58e072c1951..6be0ca4e3f8 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -5,6 +5,7 @@ rules: # http://eslint.org/docs/rules/#ecmascript-6 no-var: error prefer-const: error + symbol-description: off # Custom rules in tools/eslint-rules prefer-assert-iferror: error diff --git a/test/abort/test-abort-uncaught-exception.js b/test/abort/test-abort-uncaught-exception.js index e88a56a4895..4acddf349c2 100644 --- a/test/abort/test-abort-uncaught-exception.js +++ b/test/abort/test-abort-uncaught-exception.js @@ -24,11 +24,10 @@ function run(flags, signals) { assert.strictEqual(code, 0xC0000005); else assert.strictEqual(code, 1); + } else if (signals) { + assert(signals.includes(sig), `Unexpected signal ${sig}`); } else { - if (signals) - assert(signals.includes(sig), `Unexpected signal ${sig}`); - else - assert.strictEqual(sig, null); + assert.strictEqual(sig, null); } })); } diff --git a/test/parallel/test-cluster-disconnect-unshared-tcp.js b/test/parallel/test-cluster-disconnect-unshared-tcp.js index 59df0c54795..e18617788c5 100644 --- a/test/parallel/test-cluster-disconnect-unshared-tcp.js +++ b/test/parallel/test-cluster-disconnect-unshared-tcp.js @@ -37,10 +37,8 @@ if (cluster.isMaster) { unbound.disconnect(); unbound.on('disconnect', cluster.disconnect); } -} else { - if (process.env.BOUND === 'y') { - const source = net.createServer(); +} else if (process.env.BOUND === 'y') { + const source = net.createServer(); - source.listen(0); - } + source.listen(0); } diff --git a/test/parallel/test-cluster-disconnect-unshared-udp.js b/test/parallel/test-cluster-disconnect-unshared-udp.js index b0670f3e323..5857e9132f9 100644 --- a/test/parallel/test-cluster-disconnect-unshared-udp.js +++ b/test/parallel/test-cluster-disconnect-unshared-udp.js @@ -40,10 +40,8 @@ if (cluster.isMaster) { unbound.disconnect(); unbound.on('disconnect', cluster.disconnect); } -} else { - if (process.env.BOUND === 'y') { - const source = dgram.createSocket('udp4'); +} else if (process.env.BOUND === 'y') { + const source = dgram.createSocket('udp4'); - source.bind(0); - } + source.bind(0); } diff --git a/test/parallel/test-cluster-worker-destroy.js b/test/parallel/test-cluster-worker-destroy.js index e4223b826d8..65b41381f56 100644 --- a/test/parallel/test-cluster-worker-destroy.js +++ b/test/parallel/test-cluster-worker-destroy.js @@ -41,17 +41,15 @@ if (cluster.isMaster) { worker.on('disconnect', common.mustCall()); worker.on('exit', common.mustCall()); }); -} else { - if (cluster.worker.id === 1) { - // Call destroy when worker is disconnected - cluster.worker.process.on('disconnect', function() { - cluster.worker.destroy(); - }); - - const w = cluster.worker.disconnect(); - assert.strictEqual(w, cluster.worker); - } else { - // Call destroy when worker is not disconnected yet +} else if (cluster.worker.id === 1) { + // Call destroy when worker is disconnected + cluster.worker.process.on('disconnect', function() { cluster.worker.destroy(); - } + }); + + const w = cluster.worker.disconnect(); + assert.strictEqual(w, cluster.worker); +} else { + // Call destroy when worker is not disconnected yet + cluster.worker.destroy(); } diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index f9075539c69..69378aab94e 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -335,21 +335,19 @@ function runTest(port, testIndex) { port = server.address().port; if (tcase.debug) { console.error(`${prefix}TLS server running on port ${port}`); + } else if (tcase.renegotiate) { + runNextClient(0); } else { - if (tcase.renegotiate) { - runNextClient(0); - } else { - let clientsCompleted = 0; - for (let i = 0; i < tcase.clients.length; i++) { - runClient(`${prefix}${i} `, port, tcase.clients[i], function() { - clientsCompleted++; - if (clientsCompleted === tcase.clients.length) { - server.close(); - successfulTests++; - runTest(port, nextTest++); - } - }); - } + let clientsCompleted = 0; + for (let i = 0; i < tcase.clients.length; i++) { + runClient(`${prefix}${i} `, port, tcase.clients[i], function() { + clientsCompleted++; + if (clientsCompleted === tcase.clients.length) { + server.close(); + successfulTests++; + runTest(port, nextTest++); + } + }); } } }); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 733a6843009..722ae7d4bd9 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -26,6 +26,8 @@ const JSStream = process.binding('js_stream').JSStream; const util = require('util'); const vm = require('vm'); +/* eslint-disable accessor-pairs */ + assert.strictEqual(util.inspect(1), '1'); assert.strictEqual(util.inspect(false), 'false'); assert.strictEqual(util.inspect(''), "''"); @@ -1124,3 +1126,4 @@ if (typeof Symbol !== 'undefined') { } assert.doesNotThrow(() => util.inspect(process)); +/* eslint-enable accessor-pairs */ |