Skip to content

Commit

Permalink
[fix] jsx-uses-vars: 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 9df5b41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/rules/jsx-uses-vars.js
Expand Up @@ -26,10 +26,11 @@ module.exports = {
return {
JSXOpeningElement(node) {
let name;
if (node.name.namespace && node.name.namespace.name) {
if (node.name.namespace) {
// <Foo:Bar>
name = node.name.namespace.name;
} else if (node.name.name) {
return;
}
if (node.name.name) {
// <Foo>
name = node.name.name;
} else if (node.name.object) {
Expand Down
8 changes: 1 addition & 7 deletions tests/lib/rules/jsx-uses-vars.js
Expand Up @@ -79,12 +79,6 @@ ruleTester.run('no-unused-vars', ruleNoUnusedVars, {
var App;
<App.Hello />
`
}, {
code: `
/* eslint jsx-uses-vars: 1 */
var App;
<App:Hello />
`
}, {
code: `
/* eslint jsx-uses-vars: 1 */
Expand Down Expand Up @@ -143,7 +137,7 @@ ruleTester.run('no-unused-vars', ruleNoUnusedVars, {
var Hello;
React.render(<App:Hello/>);
`,
errors: [{message: '\'Hello\' is defined but never used.'}]
errors: [{message: '\'App\' is defined but never used.'}, {message: '\'Hello\' is defined but never used.'}]
}, {
code: `
/* eslint jsx-uses-vars: 1 */
Expand Down

0 comments on commit 9df5b41

Please sign in to comment.