From eac5a435bdbbd8fd4ba5beaf8eed462e95adec56 Mon Sep 17 00:00:00 2001 From: Alex Kovar Date: Tue, 16 Jun 2020 14:28:06 -0500 Subject: [PATCH] Forbid forbidden function argument #2662 --- lib/rules/forbid-prop-types.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index 8898b8614c..e208be6559 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -59,6 +59,15 @@ module.exports = { return forbid.indexOf(type) >= 0; } + function reportIfForbidden(type, declaration, target) { + if (isForbidden(type)) { + context.report({ + node: declaration, + message: `Prop type \`${target}\` is forbidden` + }); + } + } + function shouldCheckContextTypes(node) { if (checkContextTypes && propsUtil.isContextTypesDeclaration(node)) { return true; @@ -94,6 +103,9 @@ module.exports = { value = value.object; } if (value.type === 'CallExpression') { + value.arguments.forEach((arg) => { + reportIfForbidden(arg.name, declaration, target); + }); value = value.callee; } if (value.property) { @@ -101,12 +113,7 @@ module.exports = { } else if (value.type === 'Identifier') { target = value.name; } - if (isForbidden(target)) { - context.report({ - node: declaration, - message: `Prop type \`${target}\` is forbidden` - }); - } + reportIfForbidden(target, declaration, target); }); }