Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forbid-dom-props: support JSXNamespacedName #2961

Merged
merged 1 commit into from Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,10 +8,12 @@ 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)

### Changed
* Fix CHANGELOG.md ([#2950][] @JounQin)

[#2961]: https://github.com/yannickcr/eslint-plugin-react/pull/2961
[#2953]: https://github.com/yannickcr/eslint-plugin-react/pull/2953
[#2957]: https://github.com/yannickcr/eslint-plugin-react/pull/2957
[#2950]: https://github.com/yannickcr/eslint-plugin-react/pull/2950
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/forbid-dom-props.js
Expand Up @@ -75,8 +75,8 @@ module.exports = {
return {
JSXAttribute(node) {
const tag = node.parent.name.name;
if (!(tag && tag[0] !== tag[0].toUpperCase())) {
// This is a Component, not a DOM node, so exit.
if (!(tag && typeof tag === 'string' && tag[0] !== tag[0].toUpperCase())) {
// This is a Component, not a DOM node, so exit.
return;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/forbid-dom-props.js
Expand Up @@ -71,6 +71,13 @@ ruleTester.run('forbid-element-props', rule, {
');'
].join('\n'),
options: [{forbid: ['id']}]
}, {
code: [
'const First = (props) => (',
' <fbt:param name="name">{props.name}</fbt:param>',
');'
].join('\n'),
options: [{forbid: ['id']}]
}, {
code: [
'const First = (props) => (',
Expand Down