/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tools/eslint-rules/inspector-check.js
66 строк
2 KB
Yagiz Nizipli
meta: enable jsdoc/check-tag-names rule
18 июл 2025, 12:28
Не верифицирован
18 июл 2025, 12:28
0fd1ecd
Код
Авторство
О чём код?
/** * @file Check that common.skipIfInspectorDisabled is used if * the inspector module is required. * @author Daniel Bevenius <daniel.bevenius@gmail.com> */ 'use strict'; const utils = require('./rules-utils.js'); //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ const msg = 'Please add a skipIfInspectorDisabled() call to allow this ' + 'test to be skipped when Node is built \'--without-inspector\'.'; module.exports = { meta: { fixable: 'code', }, create(context) { const missingCheckNodes = []; let commonModuleNode = null; let hasInspectorCheck = false; function testInspectorUsage(context, node) { if (utils.isRequired(node, ['inspector'])) { missingCheckNodes.push(node); } if (utils.isCommonModule(node)) { commonModuleNode = node; } } function checkMemberExpression(context, node) { if (utils.usesCommonProperty(node, ['skipIfInspectorDisabled'])) { hasInspectorCheck = true; } } function reportIfMissing(context) { if (!hasInspectorCheck) { missingCheckNodes.forEach((node) => { context.report({ node, message: msg, fix: (fixer) => { if (commonModuleNode) { return fixer.insertTextAfter( commonModuleNode, '\ncommon.skipIfInspectorDisabled();', ); } }, }); }); } } return { 'CallExpression': (node) => testInspectorUsage(context, node), 'MemberExpression': (node) => checkMemberExpression(context, node), 'Program:exit': () => reportIfMissing(context), }; }, };