From 0a8b362729ad5450b086a2152c7f5ca36c9f6f2b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2022 21:18:40 -0700 Subject: [PATCH] tools: enable no-var ESLint rule for lib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/42573 Reviewed-By: Darshan Sen Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Matteo Collina Reviewed-By: Akhil Marsonya Reviewed-By: Michaƫl Zasso --- .eslintrc.js | 1 + benchmark/.eslintrc.yaml | 1 - doc/.eslintrc.yaml | 1 - lib/internal/async_hooks.js | 2 ++ lib/internal/js_stream_socket.js | 1 + test/.eslintrc.yaml | 1 - tools/.eslintrc.yaml | 1 - 7 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d44e3f1414f438..97affb91c0c18e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -260,6 +260,7 @@ module.exports = { 'no-useless-concat': 'error', 'no-useless-constructor': 'error', 'no-useless-return': 'error', + 'no-var': 'error', 'no-void': 'error', 'no-whitespace-before-property': 'error', 'object-curly-newline': 'error', diff --git a/benchmark/.eslintrc.yaml b/benchmark/.eslintrc.yaml index 6871299adece7b..aa014eec4e3627 100644 --- a/benchmark/.eslintrc.yaml +++ b/benchmark/.eslintrc.yaml @@ -5,5 +5,4 @@ env: es6: true rules: - no-var: error prefer-arrow-callback: error diff --git a/doc/.eslintrc.yaml b/doc/.eslintrc.yaml index fbc115669a7166..e8d24adb6e00aa 100644 --- a/doc/.eslintrc.yaml +++ b/doc/.eslintrc.yaml @@ -9,7 +9,6 @@ rules: symbol-description: off # Add new ECMAScript features gradually - no-var: error prefer-const: error prefer-rest-params: error prefer-template: error diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index ebc9254d5c5109..107aab227e4637 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -196,6 +196,7 @@ function emitInitNative(asyncId, type, triggerAsyncId, resource) { try { // Using var here instead of let because "for (var ...)" is faster than let. // Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364 + // eslint-disable-next-line no-var for (var i = 0; i < active_hooks.array.length; i++) { if (typeof active_hooks.array[i][init_symbol] === 'function') { active_hooks.array[i][init_symbol]( @@ -228,6 +229,7 @@ function emitHook(symbol, asyncId) { try { // Using var here instead of let because "for (var ...)" is faster than let. // Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364 + // eslint-disable-next-line no-var for (var i = 0; i < active_hooks.array.length; i++) { if (typeof active_hooks.array[i][symbol] === 'function') { active_hooks.array[i][symbol](asyncId); diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index faad988e820ffa..f2a0ecaa1d8a65 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -171,6 +171,7 @@ class JSStreamSocket extends Socket { this.stream.cork(); // Use `var` over `let` for performance optimization. + // eslint-disable-next-line no-var for (var i = 0; i < bufs.length; ++i) this.stream.write(bufs[i], done); this.stream.uncork(); diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 878ea7b975df11..e8295cd3e23621 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -6,7 +6,6 @@ env: rules: multiline-comment-style: [error, separate-lines] - no-var: error prefer-const: error symbol-description: off diff --git a/tools/.eslintrc.yaml b/tools/.eslintrc.yaml index de30cf6d123f33..d9a7929836d91f 100644 --- a/tools/.eslintrc.yaml +++ b/tools/.eslintrc.yaml @@ -12,4 +12,3 @@ rules: - error - args: after-used prefer-arrow-callback: error - no-var: error