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 <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 809dc09 commit 7ba3599

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎tools/eslint-rules/inspector-check.js‎

Lines changed: 6 additions & 4 deletions
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-
varusesInspector=false;
17+
constmissingCheckNodes=[];
1818
varhasInspectorCheck=false;
1919

2020
functiontestInspectorUsage(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
functionreportIfMissing(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)