Xo: no-unused-vars rule does not work with React components

Created on 16 Jan 2016  路  3Comments  路  Source: xojs/xo

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

bug

All 3 comments

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EdJoPaTo picture EdJoPaTo  路  3Comments

sindresorhus picture sindresorhus  路  3Comments

sindresorhus picture sindresorhus  路  8Comments

sindresorhus picture sindresorhus  路  5Comments

dawsbot picture dawsbot  路  5Comments