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

[fix] jsx-uses-vars: ignore namespaces #2985

Merged
merged 1 commit into from May 17, 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 @@ -11,13 +11,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)

### 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)

[#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
[#2977]: https://github.com/yannickcr/eslint-plugin-react/pull/2977
Expand Down
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