From 55b80f9029fb7d6a8b4212a9eebabdae970f7e52 Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Wed, 8 May 2019 20:45:10 +0200 Subject: tools: enable block-scoped-var eslint rule PR-URL: https://github.com/nodejs/node/pull/27616 Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- benchmark/fixtures/simple-http-server.js | 3 ++- benchmark/http/_chunky_http_client.js | 6 +++--- benchmark/http/cluster.js | 3 ++- benchmark/napi/function_call/index.js | 3 ++- benchmark/util/priority-queue.js | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) (limited to 'benchmark') diff --git a/benchmark/fixtures/simple-http-server.js b/benchmark/fixtures/simple-http-server.js index 013ac468f5..2b4f1ea956 100644 --- a/benchmark/fixtures/simple-http-server.js +++ b/benchmark/fixtures/simple-http-server.js @@ -10,8 +10,9 @@ const storedUnicode = Object.create(null); const useDomains = process.env.NODE_USE_DOMAINS; // Set up one global domain. +let domain; if (useDomains) { - var domain = require('domain'); + domain = require('domain'); const gdom = domain.create(); gdom.on('error', (er) => { console.error('Error on global domain', er); diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index 5164f8c619..1bf7fa284a 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -16,7 +16,7 @@ function main({ len, n }) { const headers = []; // Chose 7 because 9 showed "Connection error" / "Connection closed" // An odd number could result in a better length dispersion. - for (var i = 7; i <= 7 * 7 * 7; i *= 7) + for (let i = 7; i <= 7 * 7 * 7; i *= 7) headers.push('o'.repeat(i)); function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { @@ -31,7 +31,7 @@ function main({ len, n }) { 'Chrome/39.0.2171.71 Safari/537.36'); todo.push('Accept-Encoding: gzip, deflate, sdch'); todo.push('Accept-Language: en-US,en;q=0.8'); - for (var i = 0; i < extra_header_count; i++) { + for (let i = 0; i < extra_header_count; i++) { // Utilize first three powers of a small integer for an odd cycle and // because the fourth power of some integers overloads the server. todo.push(`X-Header-${i}: ${headers[i % 3]}`); @@ -41,7 +41,7 @@ function main({ len, n }) { todo = todo.join('\r\n'); // Using odd numbers in many places may increase length coverage. const chunksize = 37; - for (i = 0; i < todo.length; i += chunksize) { + for (let i = 0; i < todo.length; i += chunksize) { const cur = todo.slice(i, i + chunksize); channel.write(cur); } diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js index 7f72db533e..c2d6d8e1a7 100644 --- a/benchmark/http/cluster.js +++ b/benchmark/http/cluster.js @@ -3,8 +3,9 @@ const common = require('../common.js'); const PORT = common.PORT; const cluster = require('cluster'); +let bench; if (cluster.isMaster) { - var bench = common.createBenchmark(main, { + bench = common.createBenchmark(main, { // Unicode confuses ab on os x. type: ['bytes', 'buffer'], len: [4, 1024, 102400], diff --git a/benchmark/napi/function_call/index.js b/benchmark/napi/function_call/index.js index b63d805fe3..3eebf9c05a 100644 --- a/benchmark/napi/function_call/index.js +++ b/benchmark/napi/function_call/index.js @@ -11,8 +11,9 @@ const common = require('../../common.js'); // which is quite common for benchmarks. so in that case, just // abort quietly. +let binding; try { - var binding = require(`./build/${common.buildType}/binding`); + binding = require(`./build/${common.buildType}/binding`); } catch { console.error('misc/function_call.js Binding failed to load'); process.exit(0); diff --git a/benchmark/util/priority-queue.js b/benchmark/util/priority-queue.js index 9cff7cbbac..ea4601a002 100644 --- a/benchmark/util/priority-queue.js +++ b/benchmark/util/priority-queue.js @@ -10,9 +10,9 @@ function main({ n, type }) { const PriorityQueue = require('internal/priority_queue'); const queue = new PriorityQueue(); bench.start(); - for (var i = 0; i < n; i++) + for (let i = 0; i < n; i++) queue.insert(Math.random() * 1e7 | 0); - for (i = 0; i < n; i++) + for (let i = 0; i < n; i++) queue.shift(); bench.end(n); } -- cgit v1.2.3