Eslint-plugin-react: no-unused-prop-types rule not detect nest object

Created on 17 Sep 2016  路  3Comments  路  Source: yannickcr/eslint-plugin-react

this is working :

class Foo extends React.Component {
    render: function () {
        return <div>{this.props.bar.baz}</div>
    }
}
Foo.propTypes = {
    bar: React.PropTypes.shape({  
        baz: React.PropTypes.string      // ok
    })
};

but this seems not work:

class Foo extends React.Component {
    const bar = this.props.bar;

    render: function () {
        return <div>{bar.baz}</div>
    }
}
Foo.propTypes = {
    bar: React.PropTypes.shape({  
        baz: React.PropTypes.string      // not ok, Prop defined but not used
    })
};
bug

Most helpful comment

seems no-unused-prop-types rule cause this bug
and many others :
#810 #811 #818 #816 #818 #819 #823 #836 #837 #840 #851 #855 #861 #871

All 3 comments

seems no-unused-prop-types rule cause this bug
and many others :
#810 #811 #818 #816 #818 #819 #823 #836 #837 #840 #851 #855 #861 #871

The no-unused-prop-types rule does not support shape props at the moment as such detection is very difficult. If you use shape props, I recommend setting the skipShapeProps option to true on the rule.

Duplicate of #819. Will track further discussion of shape props there.

Is this still unsupported?

Was this page helpful?
0 / 5 - 0 ratings