Skip to content

Commit

Permalink
[Fix] forbid-component-props: support JSXNamespacedName
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 8, 2021
1 parent 2f376e0 commit cbe99e0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
// Extract a component name when using a "namespace", e.g. `<AntdLayout.Content />`.
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;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ ruleTester.run('forbid-component-props', rule, {
options: [{
forbid: [{propName: 'className', allowedFor: ['this.ReactModal']}]
}]
}, {
code: '<fbt:param name="Total number of files" number={true} />'
}],

invalid: [{
Expand Down

0 comments on commit cbe99e0

Please sign in to comment.