From 2a9e9d4c30e2f2f4f83af28be947919ac86d4435 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 1 Jul 2017 21:51:22 +0300 Subject: [PATCH] tools: use no-use-before-define ESLint rule Also fix repl and url libs for the rule. PR-URL: https://github.com/nodejs/node/pull/14032 Refs: http://eslint.org/docs/rules/no-use-before-define Reviewed-By: Daijiro Wachi --- .eslintrc.yaml | 3 +++ lib/_debugger.js | 3 ++- lib/repl.js | 3 ++- test/parallel/test-tls-npn-server-client.js | 5 +++-- test/parallel/test-tls-sni-option.js | 5 +++-- test/parallel/test-tls-sni-server-client.js | 4 ++-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0139d63a78a04f..2b0e4875670101 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -62,6 +62,9 @@ rules: no-delete-var: 2 no-undef: 2 no-unused-vars: [2, {args: none}] + no-use-before-define: [2, {classes: true, + functions: false, + variables: false}] # Node.js and CommonJS # http://eslint.org/docs/rules/#nodejs-and-commonjs diff --git a/lib/_debugger.js b/lib/_debugger.js index d3bf1f9ffa2dab..a3ceb457b0a7ee 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -993,7 +993,8 @@ Interface.prototype.debugEval = function(code, context, filename, callback) { return; } - var frame = client.currentFrame === NO_FRAME ? frame : undefined; + var frame = client.currentFrame; + if (frame !== NO_FRAME) frame = undefined; self.pause(); diff --git a/lib/repl.js b/lib/repl.js index 04c9ae468481a6..eb539cca0ef456 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -846,6 +846,7 @@ function complete(line, callback) { var completeOn, i, group, c; // REPL commands (e.g. ".break"). + var filter; var match = null; match = line.match(/^\s*\.(\w*)$/); if (match) { @@ -865,7 +866,7 @@ function complete(line, callback) { completeOn = match[1]; var subdir = match[2] || ''; - var filter = match[1]; + filter = match[1]; var dir, files, f, name, base, ext, abs, subfiles, s; group = []; var paths = module.paths.concat(require('module').globalPaths); diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js index 44e9b86ad71bdc..7cb8723ff5f9e6 100644 --- a/test/parallel/test-tls-npn-server-client.js +++ b/test/parallel/test-tls-npn-server-client.js @@ -1,11 +1,12 @@ 'use strict'; + +const common = require('../common'); + if (!process.features.tls_npn) { common.skip('Skipping because node compiled without NPN feature of OpenSSL.'); return; } -const common = require('../common'); - if (!common.hasCrypto) { common.skip('missing crypto'); return; diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index ba9acbf528c8f4..e1ecfb9620f5ef 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -1,11 +1,12 @@ 'use strict'; + +const common = require('../common'); + if (!process.features.tls_sni) { common.skip('node compiled without OpenSSL or with old OpenSSL version.'); return; } -const common = require('../common'); - if (!common.hasCrypto) { common.skip('missing crypto'); return; diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js index e47781a972f87d..4e1ab6484c0eec 100644 --- a/test/parallel/test-tls-sni-server-client.js +++ b/test/parallel/test-tls-sni-server-client.js @@ -1,11 +1,11 @@ 'use strict'; +const common = require('../common'); + if (!process.features.tls_sni) { common.skip('node compiled without OpenSSL or with old OpenSSL version.'); return; } -const common = require('../common'); - if (!common.hasCrypto) { common.skip('missing crypto'); return;