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-prop-types does not trigger if class does not use any properties #1162

Closed
Wilfred opened this issue Apr 24, 2017 · 5 comments
Closed

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Apr 24, 2017

import React from "react";

var Hello = React.createClass({
  propTypes: {
    name: React.PropTypes.string
  },
  render: function() {
    return <div>Hello Bob</div>;
  }
});

This is almost identical to the first example in the docs.

$ eslint --no-eslintrc --parser-options="{sourceType: \"module\", ecmaVersion: 6, ecmaFeatures: {jsx:true}}" --plugin react --rule react/no-unused-prop-types:error js/Hello.jsx
# No errors shown.

By contrast, this does trigger:

import React from "react";

var Hello = React.createClass({
  propTypes: {
    name: React.PropTypes.string
  },
  render: function() {
    return <div>Hello Bob {this.props.foo}</div>;
  }
});
$ eslint --no-eslintrc --parser-options="{sourceType: \"module\", ecmaVersion: 6, ecmaFeatures: {jsx:true}}" --plugin react --rule react/no-unused-prop-types:error js/Hello.jsx

js/Hello.jsx
  5:11  error  'name' PropType is defined but prop is never used  react/no-unused-prop-types

✖ 1 problem (1 error, 0 warnings)
@ljharb ljharb added the bug label Apr 24, 2017
@ljharb
Copy link
Member

ljharb commented Apr 24, 2017

Both React.createClass and React.PropTypes are officially deprecated as of v15.5; but we should still fix this case.

@DianaSuvorova
Copy link
Contributor

I will work on it.

@DianaSuvorova
Copy link
Contributor

@ljharb , do you usually close issues after fix was merged to master or released or you follow some other process?

@ljharb
Copy link
Member

ljharb commented Jul 21, 2017

Ah, when the PR says fixes #x github does it for me :-)' (on merge)

Fixed in #1303.

@ljharb ljharb closed this as completed Jul 21, 2017
@DianaSuvorova
Copy link
Contributor

Got it. Will follow that. Thanks!

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

No branches or pull requests

3 participants