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