@@ -1242,6 +1242,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1242
1242
'})'
1243
1243
] . join ( '\n' ) ,
1244
1244
parser : 'babel-eslint'
1245
+ } , {
1246
+ // Destructured props in componentWillReceiveProps shouldn't throw errors when used createReactClass, with default parser
1247
+ code : [
1248
+ 'var Hello = createReactClass({' ,
1249
+ ' propTypes: {' ,
1250
+ ' something: PropTypes.bool,' ,
1251
+ ' },' ,
1252
+ ' componentWillReceiveProps (nextProps) {' ,
1253
+ ' const {something} = nextProps;' ,
1254
+ ' doSomething(something);' ,
1255
+ ' }' ,
1256
+ '})'
1257
+ ] . join ( '\n' )
1245
1258
} , {
1246
1259
// Destructured function props in componentWillReceiveProps shouldn't throw errors
1247
1260
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 when used createReactClass, with default parser
1286
+ code : [
1287
+ 'var Hello = createReactClass({' ,
1288
+ ' propTypes: {' ,
1289
+ ' something: PropTypes.bool,' ,
1290
+ ' },' ,
1291
+ ' componentWillReceiveProps ({something}) {' ,
1292
+ ' doSomething(something);' ,
1293
+ ' }' ,
1294
+ '})'
1295
+ ] . join ( '\n' )
1271
1296
} , {
1272
1297
// Destructured props in the constructor shouldn't throw errors
1273
1298
code : [
@@ -1325,6 +1350,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1325
1350
'})'
1326
1351
] . join ( '\n' ) ,
1327
1352
parser : 'babel-eslint'
1353
+ } , {
1354
+ // Destructured props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
1355
+ code : [
1356
+ 'var Hello = createReactClass({' ,
1357
+ ' propTypes: {' ,
1358
+ ' something: PropTypes.bool,' ,
1359
+ ' },' ,
1360
+ ' shouldComponentUpdate (nextProps, nextState) {' ,
1361
+ ' const {something} = nextProps;' ,
1362
+ ' return something;' ,
1363
+ ' }' ,
1364
+ '})'
1365
+ ] . join ( '\n' )
1328
1366
} , {
1329
1367
// Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
1330
1368
code : [
@@ -1351,6 +1389,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1351
1389
'})'
1352
1390
] . join ( '\n' ) ,
1353
1391
parser : 'babel-eslint'
1392
+ } , {
1393
+ // Destructured function props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
1394
+ code : [
1395
+ 'var Hello = createReactClass({' ,
1396
+ ' propTypes: {' ,
1397
+ ' something: PropTypes.bool,' ,
1398
+ ' },' ,
1399
+ ' shouldComponentUpdate ({something}, nextState) {' ,
1400
+ ' return something;' ,
1401
+ ' }' ,
1402
+ '})'
1403
+ ] . join ( '\n' )
1354
1404
} , {
1355
1405
// Destructured props in the `componentWillUpdate` method shouldn't throw errors
1356
1406
code : [
@@ -1379,6 +1429,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1379
1429
'})'
1380
1430
] . join ( '\n' ) ,
1381
1431
parser : 'babel-eslint'
1432
+ } , {
1433
+ // Destructured props in `componentWillUpdate` shouldn't throw errors when used createReactClass, with default parser
1434
+ code : [
1435
+ 'var Hello = createReactClass({' ,
1436
+ ' propTypes: {' ,
1437
+ ' something: PropTypes.bool,' ,
1438
+ ' },' ,
1439
+ ' componentWillUpdate (nextProps, nextState) {' ,
1440
+ ' const {something} = nextProps;' ,
1441
+ ' return something;' ,
1442
+ ' }' ,
1443
+ '})'
1444
+ ] . join ( '\n' )
1382
1445
} , {
1383
1446
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors
1384
1447
code : [
@@ -1405,6 +1468,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1405
1468
'})'
1406
1469
] . join ( '\n' ) ,
1407
1470
parser : 'babel-eslint'
1471
+ } , {
1472
+ // Destructured function props in the `componentWillUpdate` method shouldn't throw errors when used createReactClass, with default parser
1473
+ code : [
1474
+ 'var Hello = createReactClass({' ,
1475
+ ' propTypes: {' ,
1476
+ ' something: PropTypes.bool,' ,
1477
+ ' },' ,
1478
+ ' componentWillUpdate ({something}, nextState) {' ,
1479
+ ' return something;' ,
1480
+ ' }' ,
1481
+ '})'
1482
+ ] . join ( '\n' )
1408
1483
} , {
1409
1484
// Destructured props in the `componentDidUpdate` method shouldn't throw errors
1410
1485
code : [
@@ -1433,6 +1508,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1433
1508
'})'
1434
1509
] . join ( '\n' ) ,
1435
1510
parser : 'babel-eslint'
1511
+ } , {
1512
+ // Destructured props in `componentDidUpdate` shouldn't throw errors when used createReactClass, with default parser
1513
+ code : [
1514
+ 'var Hello = createReactClass({' ,
1515
+ ' propTypes: {' ,
1516
+ ' something: PropTypes.bool,' ,
1517
+ ' },' ,
1518
+ ' componentDidUpdate (prevProps, prevState) {' ,
1519
+ ' const {something} = prevProps;' ,
1520
+ ' return something;' ,
1521
+ ' }' ,
1522
+ '})'
1523
+ ] . join ( '\n' )
1436
1524
} , {
1437
1525
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors
1438
1526
code : [
@@ -1459,6 +1547,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1459
1547
'})'
1460
1548
] . join ( '\n' ) ,
1461
1549
parser : 'babel-eslint'
1550
+ } , {
1551
+ // Destructured function props in the `componentDidUpdate` method shouldn't throw errors when used createReactClass, with default parser
1552
+ code : [
1553
+ 'var Hello = createReactClass({' ,
1554
+ ' propTypes: {' ,
1555
+ ' something: PropTypes.bool,' ,
1556
+ ' },' ,
1557
+ ' componentDidUpdate ({something}, prevState) {' ,
1558
+ ' return something;' ,
1559
+ ' }' ,
1560
+ '})'
1561
+ ] . join ( '\n' )
1462
1562
} , {
1463
1563
// Destructured state props in `componentDidUpdate` [Issue #825]
1464
1564
code : [
0 commit comments