@@ -1858,6 +1858,39 @@ ruleTester.run('no-unused-prop-types', rule, {
18581858 '}'
18591859 ] . join ( '\n' ) ,
18601860 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' )
18611894 }
18621895 ] ,
18631896
@@ -3189,8 +3222,29 @@ ruleTester.run('no-unused-prop-types', rule, {
31893222 } , {
31903223 message : '\'prop2.*\' PropType is defined but prop is never used'
31913224 } ]
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+ ' };' ,
31923234
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+ } ]
31933246 }
3247+
31943248 /* , {
31953249 // Enable this when the following issue is fixed
31963250 // https://github.com/yannickcr/eslint-plugin-react/issues/296
0 commit comments