Skip to content

prop-types warns even if you don’t use props at all #4

Closed
@lo1tuma

Description

The prop-types rule warns always if you don’t specify the propTypes property within a react component even if you don’t use any props.

I suggest to only warn if a used prop is not defined within propTypes. This would also be good if you have specified the propTypes property somehow but not defined every used prop.

So the following should not be considered as a warning:

var Hello = React.createClass({
  render: function() {
    return <div>Hello World</div>;
  }
});

But this should be considered as a warning:

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

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions