@@ -1228,6 +1228,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1228
1228
'}'
1229
1229
] . join ( '\n' ) ,
1230
1230
parser : 'babel-eslint'
1231
+ } , {
1232
+ // Destructured props in componentWillReceiveProps shouldn't throw errors
1233
+ code : [
1234
+ 'class Hello extends Component {' ,
1235
+ ' componentWillReceiveProps (nextProps) {' ,
1236
+ ' const {something} = nextProps;' ,
1237
+ ' doSomething(something);' ,
1238
+ ' }' ,
1239
+ '}' ,
1240
+ 'Hello.propTypes = {' ,
1241
+ ' something: PropTypes.bool,' ,
1242
+ '};'
1243
+ ] . join ( '\n' )
1231
1244
} , {
1232
1245
// Destructured props in componentWillReceiveProps shouldn't throw errors when used createReactClass
1233
1246
code : [
@@ -1268,6 +1281,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1268
1281
'}'
1269
1282
] . join ( '\n' ) ,
1270
1283
parser : 'babel-eslint'
1284
+ } , {
1285
+ // Destructured function props in componentWillReceiveProps shouldn't throw errors
1286
+ code : [
1287
+ 'class Hello extends Component {' ,
1288
+ ' componentWillReceiveProps ({something}) {' ,
1289
+ ' doSomething(something);' ,
1290
+ ' }' ,
1291
+ '}' ,
1292
+ 'Hello.propTypes = {' ,
1293
+ ' something: PropTypes.bool,' ,
1294
+ '};'
1295
+ ] . join ( '\n' )
1271
1296
} , {
1272
1297
// Destructured function props in componentWillReceiveProps shouldn't throw errors when used createReactClass
1273
1298
code : [
@@ -1308,6 +1333,20 @@ ruleTester.run('no-unused-prop-types', rule, {
1308
1333
'}'
1309
1334
] . join ( '\n' ) ,
1310
1335
parser : 'babel-eslint'
1336
+ } , {
1337
+ // Destructured props in the constructor shouldn't throw errors
1338
+ code : [
1339
+ 'class Hello extends Component {' ,
1340
+ ' constructor (props) {' ,
1341
+ ' super(props);' ,
1342
+ ' const {something} = props;' ,
1343
+ ' doSomething(something);' ,
1344
+ ' }' ,
1345
+ '}' ,
1346
+ 'Hello.propTypes = {' ,
1347
+ ' something: PropTypes.bool,' ,
1348
+ '};'
1349
+ ] . join ( '\n' )
1311
1350
} , {
1312
1351
// Destructured function props in the constructor shouldn't throw errors
1313
1352
code : [
@@ -1322,6 +1361,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1322
1361
'}'
1323
1362
] . join ( '\n' ) ,
1324
1363
parser : 'babel-eslint'
1364
+ } , {
1365
+ // Destructured function props in the constructor shouldn't throw errors
1366
+ code : [
1367
+ 'class Hello extends Component {' ,
1368
+ ' constructor ({something}) {' ,
1369
+ ' super({something});' ,
1370
+ ' doSomething(something);' ,
1371
+ ' }' ,
1372
+ '}' ,
1373
+ 'Hello.propTypes = {' ,
1374
+ ' something: PropTypes.bool,' ,
1375
+ '};'
1376
+ ] . join ( '\n' )
1325
1377
} , {
1326
1378
// Destructured props in the `shouldComponentUpdate` method shouldn't throw errors
1327
1379
code : [
@@ -1336,6 +1388,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1336
1388
'}'
1337
1389
] . join ( '\n' ) ,
1338
1390
parser : 'babel-eslint'
1391
+ } , {
1392
+ // Destructured props in the `shouldComponentUpdate` method shouldn't throw errors
1393
+ code : [
1394
+ 'class Hello extends Component {' ,
1395
+ ' shouldComponentUpdate (nextProps, nextState) {' ,
1396
+ ' const {something} = nextProps;' ,
1397
+ ' return something;' ,
1398
+ ' }' ,
1399
+ '}' ,
1400
+ 'Hello.propTypes = {' ,
1401
+ ' something: PropTypes.bool,' ,
1402
+ '};'
1403
+ ] . join ( '\n' )
1339
1404
} , {
1340
1405
// Destructured props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass
1341
1406
code : [
@@ -1376,6 +1441,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1376
1441
'}'
1377
1442
] . join ( '\n' ) ,
1378
1443
parser : 'babel-eslint'
1444
+ } , {
1445
+ // Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
1446
+ code : [
1447
+ 'class Hello extends Component {' ,
1448
+ ' shouldComponentUpdate ({something}, nextState) {' ,
1449
+ ' return something;' ,
1450
+ ' }' ,
1451
+ '}' ,
1452
+ 'Hello.propTypes = {' ,
1453
+ ' something: PropTypes.bool,' ,
1454
+ '};'
1455
+ ] . join ( '\n' )
1379
1456
} , {
1380
1457
// Destructured function props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass
1381
1458
code : [
@@ -1415,6 +1492,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1415
1492
'}'
1416
1493
] . join ( '\n' ) ,
1417
1494
parser : 'babel-eslint'
1495
+ } , {
1496
+ // Destructured props in the `componentWillUpdate` method shouldn't throw errors
1497
+ code : [
1498
+ 'class Hello extends Component {' ,
1499
+ ' componentWillUpdate (nextProps, nextState) {' ,
1500
+ ' const {something} = nextProps;' ,
1501
+ ' return something;' ,
1502
+ ' }' ,
1503
+ '}' ,
1504
+ 'Hello.propTypes = {' ,
1505
+ ' something: PropTypes.bool,' ,
1506
+ '};'
1507
+ ] . join ( '\n' )
1418
1508
} , {
1419
1509
// Destructured props in `componentWillUpdate` shouldn't throw errors when used createReactClass
1420
1510
code : [
@@ -1455,6 +1545,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1455
1545
'}'
1456
1546
] . join ( '\n' ) ,
1457
1547
parser : 'babel-eslint'
1548
+ } , {
1549
+ // Destructured function props in the `componentWillUpdate` method shouldn't throw errors
1550
+ code : [
1551
+ 'class Hello extends Component {' ,
1552
+ ' componentWillUpdate ({something}, nextState) {' ,
1553
+ ' return something;' ,
1554
+ ' }' ,
1555
+ '}' ,
1556
+ 'Hello.propTypes = {' ,
1557
+ ' something: PropTypes.bool,' ,
1558
+ '};'
1559
+ ] . join ( '\n' )
1458
1560
} , {
1459
1561
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors when used createReactClass
1460
1562
code : [
@@ -1494,6 +1596,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1494
1596
'}'
1495
1597
] . join ( '\n' ) ,
1496
1598
parser : 'babel-eslint'
1599
+ } , {
1600
+ // Destructured props in the `componentDidUpdate` method shouldn't throw errors
1601
+ code : [
1602
+ 'class Hello extends Component {' ,
1603
+ ' componentDidUpdate (prevProps, prevState) {' ,
1604
+ ' const {something} = prevProps;' ,
1605
+ ' return something;' ,
1606
+ ' }' ,
1607
+ '}' ,
1608
+ 'Hello.propTypes = {' ,
1609
+ ' something: PropTypes.bool,' ,
1610
+ '};'
1611
+ ] . join ( '\n' )
1497
1612
} , {
1498
1613
// Destructured props in `componentDidUpdate` shouldn't throw errors when used createReactClass
1499
1614
code : [
@@ -1534,6 +1649,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1534
1649
'}'
1535
1650
] . join ( '\n' ) ,
1536
1651
parser : 'babel-eslint'
1652
+ } , {
1653
+ // Destructured function props in the `componentDidUpdate` method shouldn't throw errors
1654
+ code : [
1655
+ 'class Hello extends Component {' ,
1656
+ ' componentDidUpdate ({something}, prevState) {' ,
1657
+ ' return something;' ,
1658
+ ' }' ,
1659
+ '}' ,
1660
+ 'Hello.propTypes = {' ,
1661
+ ' something: PropTypes.bool,' ,
1662
+ '};'
1663
+ ] . join ( '\n' )
1537
1664
} , {
1538
1665
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors when used createReactClass
1539
1666
code : [
@@ -1572,6 +1699,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1572
1699
'}'
1573
1700
] . join ( '\n' ) ,
1574
1701
parser : 'babel-eslint'
1702
+ } , {
1703
+ // Destructured state props in `componentDidUpdate` [Issue #825]
1704
+ code : [
1705
+ 'class Hello extends Component {' ,
1706
+ ' componentDidUpdate ({something}, {state1, state2}) {' ,
1707
+ ' return something;' ,
1708
+ ' }' ,
1709
+ '}' ,
1710
+ 'Hello.propTypes = {' ,
1711
+ ' something: PropTypes.bool,' ,
1712
+ '};'
1713
+ ] . join ( '\n' )
1575
1714
} , {
1576
1715
// Destructured state props in `componentDidUpdate` [Issue #825] when used createReactClass
1577
1716
code : [
0 commit comments