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 <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
8215c671d3
commit
c2d63a9785
@ -14,12 +14,12 @@ const msg = 'Please add a skipIfInspectorDisabled() call to allow this ' +
|
|||||||
'test to be skippped when Node is built \'--without-inspector\'.';
|
'test to be skippped when Node is built \'--without-inspector\'.';
|
||||||
|
|
||||||
module.exports = function(context) {
|
module.exports = function(context) {
|
||||||
var usesInspector = false;
|
const missingCheckNodes = [];
|
||||||
var hasInspectorCheck = false;
|
var hasInspectorCheck = false;
|
||||||
|
|
||||||
function testInspectorUsage(context, node) {
|
function testInspectorUsage(context, node) {
|
||||||
if (utils.isRequired(node, ['inspector'])) {
|
if (utils.isRequired(node, ['inspector'])) {
|
||||||
usesInspector = true;
|
missingCheckNodes.push(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +30,10 @@ module.exports = function(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reportIfMissing(context, node) {
|
function reportIfMissing(context, node) {
|
||||||
if (usesInspector && !hasInspectorCheck) {
|
if (!hasInspectorCheck) {
|
||||||
context.report(node, msg);
|
missingCheckNodes.forEach((node) => {
|
||||||
|
context.report(node, msg);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user