From 7ba35995a767c49a4579a9ebd31f7a870532b387 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 23 Oct 2017 11:28:47 +0200 Subject: [PATCH] tools: fix inspector-check reporting Currently the inspector-check rule does not store the node when the usage of a require('inspector') is done. This means that it is not possible to disable this rule. For example, if you add the following to a test that uses the inspector module: //common.skipIfInspectorDisabled(); /* eslint-disable inspector-check */ This will not disable the check and there will still be a lint error reported. This commit stores the node where the require statement is done which allows for the rule to also be disabled. PR-URL: https://github.com/nodejs/node/pull/16902 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- tools/eslint-rules/inspector-check.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/eslint-rules/inspector-check.js b/tools/eslint-rules/inspector-check.js index f225b34cb6b0ca..e65dd17d768ac2 100644 --- a/tools/eslint-rules/inspector-check.js +++ b/tools/eslint-rules/inspector-check.js @@ -14,12 +14,12 @@ const msg = 'Please add a skipIfInspectorDisabled() call to allow this ' + 'test to be skippped when Node is built \'--without-inspector\'.'; module.exports = function(context) { - var usesInspector = false; + const missingCheckNodes = []; var hasInspectorCheck = false; function testInspectorUsage(context, node) { if (utils.isRequired(node, ['inspector'])) { - usesInspector = true; + missingCheckNodes.push(node); } } @@ -30,8 +30,10 @@ module.exports = function(context) { } function reportIfMissing(context, node) { - if (usesInspector && !hasInspectorCheck) { - context.report(node, msg); + if (!hasInspectorCheck) { + missingCheckNodes.forEach((node) => { + context.report(node, msg); + }); } }