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 committed May 11, 2021
1 parent 89ba8c5 commit 07bbe02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/rules/jsx-no-undef.js
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
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 07bbe02

Please sign in to comment.