@@ -1858,6 +1858,39 @@ ruleTester.run('no-unused-prop-types', rule, {
1858
1858
'}'
1859
1859
] . join ( '\n' ) ,
1860
1860
parserOptions : Object . assign ( { } , parserOptions , { ecmaVersion : 2017 } )
1861
+ } ,
1862
+ {
1863
+ // Destructured assignment with Shape propTypes issue #816
1864
+ code : [
1865
+ 'export default class NavigationButton extends React.Component {' ,
1866
+ ' static propTypes = {' ,
1867
+ ' route: PropTypes.shape({' ,
1868
+ ' getBarTintColor: PropTypes.func.isRequired,' ,
1869
+ ' }).isRequired,' ,
1870
+ ' };' ,
1871
+
1872
+ ' renderTitle() {' ,
1873
+ ' const { route } = this.props;' ,
1874
+ ' return <Title tintColor={route.getBarTintColor()}>TITLE</Title>;' ,
1875
+ ' }' ,
1876
+ '}'
1877
+ ] . join ( '\n' ) ,
1878
+ parser : 'babel-eslint'
1879
+ } , {
1880
+ // Destructured assignment without Shape propTypes issue #816
1881
+ code : [
1882
+ 'const Component = ({ children: aNode }) => (' ,
1883
+ ' <div>{aNode}</div>' ,
1884
+ ');' ,
1885
+
1886
+ 'Component.defaultProps = {' ,
1887
+ ' children: null,' ,
1888
+ '};' ,
1889
+
1890
+ 'Component.propTypes = {' ,
1891
+ ' children: React.PropTypes.node,' ,
1892
+ '};'
1893
+ ] . join ( '\n' )
1861
1894
}
1862
1895
] ,
1863
1896
@@ -3189,8 +3222,29 @@ ruleTester.run('no-unused-prop-types', rule, {
3189
3222
} , {
3190
3223
message : '\'prop2.*\' PropType is defined but prop is never used'
3191
3224
} ]
3225
+ } , {
3226
+ // Destructured assignment with Shape propTypes with skipShapeProps off issue #816
3227
+ code : [
3228
+ 'export default class NavigationButton extends React.Component {' ,
3229
+ ' static propTypes = {' ,
3230
+ ' route: PropTypes.shape({' ,
3231
+ ' getBarTintColor: PropTypes.func.isRequired,' ,
3232
+ ' }).isRequired,' ,
3233
+ ' };' ,
3192
3234
3235
+ ' renderTitle() {' ,
3236
+ ' const { route } = this.props;' ,
3237
+ ' return <Title tintColor={route.getBarTintColor()}>TITLE</Title>;' ,
3238
+ ' }' ,
3239
+ '}'
3240
+ ] . join ( '\n' ) ,
3241
+ parser : 'babel-eslint' ,
3242
+ options : [ { skipShapeProps : false } ] ,
3243
+ errors : [ {
3244
+ message : '\'route.getBarTintColor\' PropType is defined but prop is never used'
3245
+ } ]
3193
3246
}
3247
+
3194
3248
/* , {
3195
3249
// Enable this when the following issue is fixed
3196
3250
// https://github.com/yannickcr/eslint-plugin-react/issues/296
0 commit comments