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

Only mark component types as used, not prop names. #69

Merged
merged 1 commit into from
Apr 17, 2015

Conversation

burnnat
Copy link
Contributor

@burnnat burnnat commented Apr 17, 2015

Previously, all JSX identifiers were marked as "used", even for prop names. This is an issue in cases where component props happened by chance to have the same name as a local variable, like this:

    var App;
    var foo;
    React.render(<App foo="bar"/>);

Here, the "foo" prop prevents the foo variable from being marked as unused and ESLint gives no warnings for the no-unused-vars rule, even though foo is not actually referenced anywhere.

This change updates the jsx-uses-vars rule to only mark variables as used if they occur in a JSXOpeningElement node (thus excluding prop names, as they exist in JSXAttribute nodes instead).

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.92% when pulling 3fc121b on burnnat:fix-jsx-props into 3e2e92d on yannickcr:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.92% when pulling 3fc121b on burnnat:fix-jsx-props into 3e2e92d on yannickcr:master.

yannickcr added a commit that referenced this pull request Apr 17, 2015
Only mark component types as used, not prop names.
@yannickcr yannickcr merged commit 8624343 into jsx-eslint:master Apr 17, 2015
@yannickcr
Copy link
Member

Nice catch! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants