diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1866e352d8..3bf5fee151 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,8 +11,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
### Fixed
* [`function-component-definition`]: ignore object properties ([#2771][] @stefan-wullems)
+* [`forbid-component-props`]: Implemented support for "namespaced" components ([#2767][] @mnn)
[#2771]: https://github.com/yannickcr/eslint-plugin-react/pull/2771
+[#2767]: https://github.com/yannickcr/eslint-plugin-react/pull/2767
[#2761]: https://github.com/yannickcr/eslint-plugin-react/pull/2761
[#2748]: https://github.com/yannickcr/eslint-plugin-react/pull/2748
diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js
index e5d8185961..f04fdcc881 100644
--- a/lib/rules/forbid-component-props.js
+++ b/lib/rules/forbid-component-props.js
@@ -78,8 +78,11 @@ module.exports = {
return {
JSXAttribute(node) {
- const tag = node.parent.name.name;
- if (tag && tag[0] !== tag[0].toUpperCase()) {
+ const parentName = node.parent.name;
+ // Extract a component name when using a "namespace", e.g. ``.
+ const tag = parentName.name || `${parentName.object.name}.${parentName.property.name}`;
+ const componentName = parentName.name || parentName.property.name;
+ if (componentName && componentName[0] !== componentName[0].toUpperCase()) {
// This is a DOM node, not a Component, so exit.
return;
}
diff --git a/tests/lib/rules/forbid-component-props.js b/tests/lib/rules/forbid-component-props.js
index 910d2c240f..380e0b788d 100644
--- a/tests/lib/rules/forbid-component-props.js
+++ b/tests/lib/rules/forbid-component-props.js
@@ -104,6 +104,16 @@ ruleTester.run('forbid-component-props', rule, {
options: [{
forbid: [{propName: 'className', allowedFor: ['ReactModal']}]
}]
+ }, {
+ code: 'const item = ();',
+ options: [{
+ forbid: [{propName: 'className', allowedFor: ['AntdLayout.Content']}]
+ }]
+ }, {
+ code: 'const item = ();',
+ options: [{
+ forbid: [{propName: 'className', allowedFor: ['this.ReactModal']}]
+ }]
}],
invalid: [{