mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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:
1 parent
5c8fb6a976
commit
85fd7bb8f7
1 file changed
+6
-4
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user