Skip to content

Commit 9aa539d

Browse files
remcohaszingljharb
authored andcommitted
[Fix] jsx-no-undef: ignore namespaces
JSX namespaces are transpiled into strings, not identifiers.
1 parent f864ac1 commit 9aa539d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1212
### Fixed
1313
* [`jsx-handler-names`]: properly substitute value into message ([#2975][] @G-Rath)
1414
* [`jsx-uses-vars`]: ignore namespaces ([#2985][] @remcohaszing)
15+
* [`jsx-no-undef`]: ignore namespaces ([#2986][] @remcohaszing)
1516

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

23+
[#2986]: https://github.com/yannickcr/eslint-plugin-react/pull/2986
2224
[#2985]: https://github.com/yannickcr/eslint-plugin-react/pull/2985
2325
[#2982]: https://github.com/yannickcr/eslint-plugin-react/pull/2982
2426
[#2980]: https://github.com/yannickcr/eslint-plugin-react/pull/2980

lib/rules/jsx-no-undef.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ module.exports = {
102102
} while (node && node.type !== 'JSXIdentifier');
103103
break;
104104
case 'JSXNamespacedName':
105-
node = node.name.namespace;
106-
break;
105+
return;
107106
default:
108107
break;
109108
}

tests/lib/rules/jsx-no-undef.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ ruleTester.run('jsx-no-undef', rule, {
4545
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.Foo />);'
4646
}, {
4747
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.foo.Bar />);'
48+
}, {
49+
code: '/*eslint no-undef:1*/ var React; React.render(<Apppp:Foo />);'
4850
}, {
4951
code: `
5052
/*eslint no-undef:1*/
@@ -87,12 +89,6 @@ ruleTester.run('jsx-no-undef', rule, {
8789
messageId: 'undefined',
8890
data: {identifier: 'Appp'}
8991
}]
90-
}, {
91-
code: '/*eslint no-undef:1*/ var React; React.render(<Apppp:Foo />);',
92-
errors: [{
93-
messageId: 'undefined',
94-
data: {identifier: 'Apppp'}
95-
}]
9692
}, {
9793
code: '/*eslint no-undef:1*/ var React; React.render(<appp.Foo />);',
9894
errors: [{

0 commit comments

Comments
 (0)