From 6345acb792479d8adc128e72d55ae6b73cb4d7ee Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 13 Jan 2016 16:14:28 -0800 Subject: [PATCH] tools: enable no-redeclare rule for linter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/5047 Reviewed-By: Colin Ihrig Reviewed-By: Roman Reiss Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- .eslintrc | 2 ++ lib/dgram.js | 2 +- test/parallel/test-crypto-dh.js | 10 +++++----- test/parallel/test-fs-utimes.js | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.eslintrc b/.eslintrc index c02364e40f452a..5b95af8045f61e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -48,6 +48,8 @@ rules: # list: https://github.com/eslint/eslint/tree/master/docs/rules#best-practices ## require falls through comment on switch-case no-fallthrough: 2 + ## disallow declaring the same variable more than once + no-redeclare: 2 # Stylistic Issues # list: https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues diff --git a/lib/dgram.js b/lib/dgram.js index 91d64dcee12c0f..93ae5c5ca1df48 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -332,7 +332,7 @@ Socket.prototype.send = function(buffer, !!callback); if (err && callback) { // don't emit as error, dgram_legacy.js compatibility - var ex = exceptionWithHostPort(err, 'send', address, port); + const ex = exceptionWithHostPort(err, 'send', address, port); process.nextTick(callback, ex); } } diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js index 6eda535ee56f5d..d3919457ea5033 100644 --- a/test/parallel/test-crypto-dh.js +++ b/test/parallel/test-crypto-dh.js @@ -152,10 +152,10 @@ assert.equal(bad_dh.verifyError, constants.DH_NOT_SUITABLE_GENERATOR); // Test ECDH var ecdh1 = crypto.createECDH('prime256v1'); var ecdh2 = crypto.createECDH('prime256v1'); -var key1 = ecdh1.generateKeys(); -var key2 = ecdh2.generateKeys('hex'); -var secret1 = ecdh1.computeSecret(key2, 'hex', 'base64'); -var secret2 = ecdh2.computeSecret(key1, 'binary', 'buffer'); +key1 = ecdh1.generateKeys(); +key2 = ecdh2.generateKeys('hex'); +secret1 = ecdh1.computeSecret(key2, 'hex', 'base64'); +secret2 = ecdh2.computeSecret(key1, 'binary', 'buffer'); assert.equal(secret1, secret2.toString('base64')); @@ -168,7 +168,7 @@ crypto.createHash('sha256'); assert.equal(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4); var firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0]; assert(firstByte === 2 || firstByte === 3); -var firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0]; +firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0]; assert(firstByte === 6 || firstByte === 7); // ECDH should check that point is on curve diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index 5d5cb40ec1eede..f245a7962da0f4 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -18,7 +18,7 @@ function stat_resource(resource) { } function check_mtime(resource, mtime) { - var mtime = fs._toUnixTimestamp(mtime); + mtime = fs._toUnixTimestamp(mtime); var stats = stat_resource(resource); var real_mtime = fs._toUnixTimestamp(stats.mtime); // check up to single-second precision