Skip to content

Commit

Permalink
tools: fix inspector-check reporting
Browse files Browse the repository at this point in the history
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: #16902
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
danbev committed Nov 13, 2017
1 parent 8215c67 commit c2d63a9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/eslint-rules/inspector-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
});
}
}

Expand Down

0 comments on commit c2d63a9

Please sign in to comment.