prop-types
rule reports for Array.prototype.length is missing #1047
Closed
Description
h2. Expected
When a propType React.PropTypes.arrayOf(<something>)
, you shouldn't be prompted to add
length
by eslint.
h2. What happens
You get '.length' is missing in props validation (react/prop-types) from eslint
h2. Example
class MyClass extends React.Component {
static propTypes = {
results: PropTypes.arrayOf(
PropTypes.shape({
items: PropTypes.arrayOf(PropTypes.shape(<Shape definition>))
})
)
};
get hasItems() {
this.props.results && this.props.results.items && this.props.results.items.length > 0;
}
}
Results in this:
'results.items.length' is missing in props validation (react/prop-types)