| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fd5c26b commit 3ad0fae
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,53 +12,54 @@ const utils = require('./rules-utils.js'); | |||
| 12 | 12 | const msg = 'Please add a skipIfEslintMissing() call to allow this test to ' + | |
| 13 | 13 | 'be skipped when Node.js is built from a source tarball.'; | |
| 14 | 14 | ||
| 15 | - module.exports = function(context) { | ||
| 16 | - const missingCheckNodes = []; | ||
| 17 | - let commonModuleNode = null; | ||
| 18 | - let hasEslintCheck = false; | ||
| 15 | + module.exports = { | ||
| 16 | + meta: { | ||
| 17 | + fixable: 'code', | ||
| 18 | + }, | ||
| 19 | + create: function(context) { | ||
| 20 | + const missingCheckNodes = []; | ||
| 21 | + let commonModuleNode = null; | ||
| 22 | + let hasEslintCheck = false; | ||
| 19 | 23 | ||
| 20 | - function testEslintUsage(context, node) { | ||
| 21 | - if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) { | ||
| 22 | - missingCheckNodes.push(node); | ||
| 23 | - } | ||
| 24 | + function testEslintUsage(context, node) { | ||
| 25 | + if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) { | ||
| 26 | + missingCheckNodes.push(node); | ||
| 27 | + } | ||
| 24 | 28 | ||
| 25 | - if (utils.isCommonModule(node)) { | ||
| 26 | - commonModuleNode = node; | ||
| 29 | + if (utils.isCommonModule(node)) { | ||
| 30 | + commonModuleNode = node; | ||
| 31 | + } | ||
| 27 | 32 | } | |
| 28 | - } | ||
| 29 | 33 | ||
| 30 | - function checkMemberExpression(context, node) { | ||
| 31 | - if (utils.usesCommonProperty(node, ['skipIfEslintMissing'])) { | ||
| 32 | - hasEslintCheck = true; | ||
| 34 | + function checkMemberExpression(context, node) { | ||
| 35 | + if (utils.usesCommonProperty(node, ['skipIfEslintMissing'])) { | ||
| 36 | + hasEslintCheck = true; | ||
| 37 | + } | ||
| 33 | 38 | } | |
| 34 | - } | ||
| 35 | 39 | ||
| 36 | - function reportIfMissing(context) { | ||
| 37 | - if (!hasEslintCheck) { | ||
| 38 | - missingCheckNodes.forEach((node) => { | ||
| 39 | - context.report({ | ||
| 40 | - node, | ||
| 41 | - message: msg, | ||
| 42 | - fix: (fixer) => { | ||
| 43 | - if (commonModuleNode) { | ||
| 44 | - return fixer.insertTextAfter( | ||
| 45 | - commonModuleNode, | ||
| 46 | - '\ncommon.skipIfEslintMissing();' | ||
| 47 | - ); | ||
| 40 | + function reportIfMissing(context) { | ||
| 41 | + if (!hasEslintCheck) { | ||
| 42 | + missingCheckNodes.forEach((node) => { | ||
| 43 | + context.report({ | ||
| 44 | + node, | ||
| 45 | + message: msg, | ||
| 46 | + fix: (fixer) => { | ||
| 47 | + if (commonModuleNode) { | ||
| 48 | + return fixer.insertTextAfter( | ||
| 49 | + commonModuleNode, | ||
| 50 | + '\ncommon.skipIfEslintMissing();' | ||
| 51 | + ); | ||
| 52 | + } | ||
| 48 | 53 | } | |
| 49 | - } | ||
| 54 | + }); | ||
| 50 | 55 | }); | |
| 51 | - }); | ||
| 56 | + } | ||
| 52 | 57 | } | |
| 53 | - } | ||
| 54 | 58 | ||
| 55 | - return { | ||
| 56 | - 'CallExpression': (node) => testEslintUsage(context, node), | ||
| 57 | - 'MemberExpression': (node) => checkMemberExpression(context, node), | ||
| 58 | - 'Program:exit': () => reportIfMissing(context) | ||
| 59 | - }; | ||
| 60 | - }; | ||
| 61 | - | ||
| 62 | - module.exports.meta = { | ||
| 63 | - fixable: 'code' | ||
| 59 | + return { | ||
| 60 | + 'CallExpression': (node) => testEslintUsage(context, node), | ||
| 61 | + 'MemberExpression': (node) => checkMemberExpression(context, node), | ||
| 62 | + 'Program:exit': () => reportIfMissing(context) | ||
| 63 | + }; | ||
| 64 | + } | ||
| 64 | 65 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments