Skip to content

Commit

Permalink
[Fix] jsx-no-undef: ignore namespaces
Browse files Browse the repository at this point in the history
JSX namespaces are transpiled into strings, not identifiers.
  • Loading branch information
remcohaszing authored and ljharb committed May 11, 2021
1 parent f864ac1 commit 9aa539d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
### Fixed
* [`jsx-handler-names`]: properly substitute value into message ([#2975][] @G-Rath)
* [`jsx-uses-vars`]: ignore namespaces ([#2985][] @remcohaszing)
* [`jsx-no-undef`]: ignore namespaces ([#2986][] @remcohaszing)

### Changed
* [Docs] [`jsx-newline`]: Fix minor spelling error on rule name ([#2974][] @DennisSkoko)
* [Refactor] [`void-dom-elements-no-children`]: improve performance
* [readme] fix missing trailing commas ([#2980][] @sugardon)
* [readme] fix broken anchor link ([#2982][] @vzvu3k6k)

[#2986]: https://github.com/yannickcr/eslint-plugin-react/pull/2986
[#2985]: https://github.com/yannickcr/eslint-plugin-react/pull/2985
[#2982]: https://github.com/yannickcr/eslint-plugin-react/pull/2982
[#2980]: https://github.com/yannickcr/eslint-plugin-react/pull/2980
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/jsx-no-undef.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ module.exports = {
} while (node && node.type !== 'JSXIdentifier');
break;
case 'JSXNamespacedName':
node = node.name.namespace;
break;
return;
default:
break;
}
Expand Down
8 changes: 2 additions & 6 deletions tests/lib/rules/jsx-no-undef.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ ruleTester.run('jsx-no-undef', rule, {
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.Foo />);'
}, {
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.foo.Bar />);'
}, {
code: '/*eslint no-undef:1*/ var React; React.render(<Apppp:Foo />);'
}, {
code: `
/*eslint no-undef:1*/
Expand Down Expand Up @@ -87,12 +89,6 @@ ruleTester.run('jsx-no-undef', rule, {
messageId: 'undefined',
data: {identifier: 'Appp'}
}]
}, {
code: '/*eslint no-undef:1*/ var React; React.render(<Apppp:Foo />);',
errors: [{
messageId: 'undefined',
data: {identifier: 'Apppp'}
}]
}, {
code: '/*eslint no-undef:1*/ var React; React.render(<appp.Foo />);',
errors: [{
Expand Down

0 comments on commit 9aa539d

Please sign in to comment.