Skip to content

Commit 7ba3599

Browse files
danbevevanlucas
authored andcommitted
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: #16902 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 809dc09 commit 7ba3599

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/eslint-rules/inspector-check.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const msg = 'Please add a skipIfInspectorDisabled() call to allow this ' +
1414
'test to be skippped when Node is built \'--without-inspector\'.';
1515

1616
module.exports = function(context) {
17-
var usesInspector = false;
17+
const missingCheckNodes = [];
1818
var hasInspectorCheck = false;
1919

2020
function testInspectorUsage(context, node) {
2121
if (utils.isRequired(node, ['inspector'])) {
22-
usesInspector = true;
22+
missingCheckNodes.push(node);
2323
}
2424
}
2525

@@ -30,8 +30,10 @@ module.exports = function(context) {
3030
}
3131

3232
function reportIfMissing(context, node) {
33-
if (usesInspector && !hasInspectorCheck) {
34-
context.report(node, msg);
33+
if (!hasInspectorCheck) {
34+
missingCheckNodes.forEach((node) => {
35+
context.report(node, msg);
36+
});
3537
}
3638
}
3739

0 commit comments

Comments
 (0)