From cbe99e019c5b1daaa344dd3e58bfd6d4948db3da Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 8 Apr 2021 12:42:00 -0700 Subject: [PATCH] [Fix] `forbid-component-props`: support `JSXNamespacedName` See https://github.com/AriPerkkio/eslint-remote-tester/issues/29#issuecomment-815856045 --- CHANGELOG.md | 3 ++- lib/rules/forbid-component-props.js | 2 +- tests/lib/rules/forbid-component-props.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06a43334a4..c2dac37f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Fixed * [`jsx-max-depth`]: Prevent getting stuck in circular references ([#2957][] @AriPerkkio) * [`jsx-no-target-blank`]: fix handling of `warnOnSpreadAttributes` being false ([#2953][] @Nokel81) -* [`forbid-dom-props`]: support `JSXNamespacedName` [#2961][] @mrtnzlml) +* [`forbid-dom-props`]: support `JSXNamespacedName` ([#2961][] @mrtnzlml) +* [`forbid-component-props`]: support `JSXNamespacedName` (@ljharb) ### Changed * Fix CHANGELOG.md ([#2950][] @JounQin) diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index 5aafe099fd..d1f61f4171 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -86,7 +86,7 @@ module.exports = { // 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()) { + if (componentName && typeof componentName[0] === 'string' && 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 5f3ea7a3e5..fd8375a278 100644 --- a/tests/lib/rules/forbid-component-props.js +++ b/tests/lib/rules/forbid-component-props.js @@ -111,6 +111,8 @@ ruleTester.run('forbid-component-props', rule, { options: [{ forbid: [{propName: 'className', allowedFor: ['this.ReactModal']}] }] + }, { + code: '' }], invalid: [{