(context)
| 18 | fixable: 'code', |
| 19 | }, |
| 20 | create(context) { |
| 21 | const missingCheckNodes = []; |
| 22 | let commonModuleNode = null; |
| 23 | let hasInspectorCheck = false; |
| 24 | |
| 25 | function testInspectorUsage(context, node) { |
| 26 | if (utils.isRequired(node, ['inspector'])) { |
| 27 | missingCheckNodes.push(node); |
| 28 | } |
| 29 | |
| 30 | if (utils.isCommonModule(node)) { |
| 31 | commonModuleNode = node; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | function checkMemberExpression(context, node) { |
| 36 | if (utils.usesCommonProperty(node, ['skipIfInspectorDisabled'])) { |
| 37 | hasInspectorCheck = true; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | function reportIfMissing(context) { |
| 42 | if (!hasInspectorCheck) { |
| 43 | missingCheckNodes.forEach((node) => { |
| 44 | context.report({ |
| 45 | node, |
| 46 | message: msg, |
| 47 | fix: (fixer) => { |
| 48 | if (commonModuleNode) { |
| 49 | return fixer.insertTextAfter( |
| 50 | commonModuleNode, |
| 51 | '\ncommon.skipIfInspectorDisabled();', |
| 52 | ); |
| 53 | } |
| 54 | }, |
| 55 | }); |
| 56 | }); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return { |
| 61 | 'CallExpression': (node) => testInspectorUsage(context, node), |
| 62 | 'MemberExpression': (node) => checkMemberExpression(context, node), |
| 63 | 'Program:exit': () => reportIfMissing(context), |
| 64 | }; |
| 65 | }, |
| 66 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…