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

no-unused-vars rule does not work with React components #74

Closed
vadimdemedes opened this issue Jan 16, 2016 · 3 comments
Closed

no-unused-vars rule does not work with React components #74

vadimdemedes opened this issue Jan 16, 2016 · 3 comments
Labels

Comments

@vadimdemedes
Copy link

Latest xo has problems with detecting usage of React components over the code (no-unused-vars). Even though components are used in code, xo reports them as defined but never used.

example.js:

const React = require('react');

const Button = React.createClass({});

const Container = React.createClass({
    render: function () {
        return <Button />;
    }
});

package.json:

{
  "scripts": {
    "test": "xo"
  },
  "devDependencies": {
    "xo": "^0.12.1"
  }
}
$ npm test

screen shot 2016-01-16 at 12 27 31 pm

@sindresorhus
Copy link
Member

Yes, ESLint doesn't support React semantics, only parsing JSX. What you want is https://github.com/sindresorhus/eslint-config-xo-react and https://github.com/yannickcr/eslint-plugin-react. I guess I could make that clearer in the readme.

@vadimdemedes
Copy link
Author

Thanks! Yeah, that would be great. Because readme states JSX is supported by default, but it kinda isn't.

@sindresorhus
Copy link
Member

@vdemedes JSX per its spec is, but React semantics is slightly different from what I can remember.

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

No branches or pull requests

2 participants