@@ -1255,6 +1255,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1255
1255
'}'
1256
1256
] . join ( '\n' ) ,
1257
1257
parser : 'babel-eslint'
1258
+ } , {
1259
+ // Destructured function props in componentWillReceiveProps shouldn't throw errors when used createReactClass
1260
+ code : [
1261
+ 'var Hello = createReactClass({' ,
1262
+ ' propTypes: {' ,
1263
+ ' something: PropTypes.bool,' ,
1264
+ ' },' ,
1265
+ ' componentWillReceiveProps ({something}) {' ,
1266
+ ' doSomething(something);' ,
1267
+ ' }' ,
1268
+ '})'
1269
+ ] . join ( '\n' ) ,
1270
+ parser : 'babel-eslint'
1258
1271
} , {
1259
1272
// Destructured props in the constructor shouldn't throw errors
1260
1273
code : [
@@ -1285,57 +1298,57 @@ ruleTester.run('no-unused-prop-types', rule, {
1285
1298
] . join ( '\n' ) ,
1286
1299
parser : 'babel-eslint'
1287
1300
} , {
1288
- // Destructured props in the `componentWillReceiveProps ` method shouldn't throw errors
1301
+ // Destructured props in the `shouldComponentUpdate ` method shouldn't throw errors
1289
1302
code : [
1290
1303
'class Hello extends Component {' ,
1291
1304
' static propTypes = {' ,
1292
1305
' something: PropTypes.bool' ,
1293
1306
' }' ,
1294
- ' componentWillReceiveProps (nextProps, nextState) {' ,
1307
+ ' shouldComponentUpdate (nextProps, nextState) {' ,
1295
1308
' const {something} = nextProps;' ,
1296
1309
' return something;' ,
1297
1310
' }' ,
1298
1311
'}'
1299
1312
] . join ( '\n' ) ,
1300
1313
parser : 'babel-eslint'
1301
1314
} , {
1302
- // Destructured function props in the `componentWillReceiveProps` method shouldn't throw errors
1315
+ // Destructured props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass
1303
1316
code : [
1304
- 'class Hello extends Component {' ,
1305
- ' static propTypes = {' ,
1306
- ' something: PropTypes.bool' ,
1307
- ' }' ,
1308
- ' componentWillReceiveProps ({something}, nextState) {' ,
1317
+ 'var Hello = createReactClass({' ,
1318
+ ' propTypes: {' ,
1319
+ ' something: PropTypes.bool,' ,
1320
+ ' },' ,
1321
+ ' shouldComponentUpdate (nextProps, nextState) {' ,
1322
+ ' const {something} = nextProps;' ,
1309
1323
' return something;' ,
1310
1324
' }' ,
1311
- '}'
1325
+ '}) '
1312
1326
] . join ( '\n' ) ,
1313
1327
parser : 'babel-eslint'
1314
1328
} , {
1315
- // Destructured props in the `shouldComponentUpdate` method shouldn't throw errors
1329
+ // Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
1316
1330
code : [
1317
1331
'class Hello extends Component {' ,
1318
1332
' static propTypes = {' ,
1319
1333
' something: PropTypes.bool' ,
1320
1334
' }' ,
1321
- ' shouldComponentUpdate (nextProps, nextState) {' ,
1322
- ' const {something} = nextProps;' ,
1335
+ ' shouldComponentUpdate ({something}, nextState) {' ,
1323
1336
' return something;' ,
1324
1337
' }' ,
1325
1338
'}'
1326
1339
] . join ( '\n' ) ,
1327
1340
parser : 'babel-eslint'
1328
1341
} , {
1329
- // Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
1342
+ // Destructured function props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass
1330
1343
code : [
1331
- 'class Hello extends Component {' ,
1332
- ' static propTypes = {' ,
1333
- ' something: PropTypes.bool' ,
1334
- ' }' ,
1344
+ 'var Hello = createReactClass( {' ,
1345
+ ' propTypes: {' ,
1346
+ ' something: PropTypes.bool, ' ,
1347
+ ' }, ' ,
1335
1348
' shouldComponentUpdate ({something}, nextState) {' ,
1336
1349
' return something;' ,
1337
1350
' }' ,
1338
- '}'
1351
+ '}) '
1339
1352
] . join ( '\n' ) ,
1340
1353
parser : 'babel-eslint'
1341
1354
} , {
@@ -1352,6 +1365,20 @@ ruleTester.run('no-unused-prop-types', rule, {
1352
1365
'}'
1353
1366
] . join ( '\n' ) ,
1354
1367
parser : 'babel-eslint'
1368
+ } , {
1369
+ // Destructured props in `componentWillUpdate` shouldn't throw errors when used createReactClass
1370
+ code : [
1371
+ 'var Hello = createReactClass({' ,
1372
+ ' propTypes: {' ,
1373
+ ' something: PropTypes.bool,' ,
1374
+ ' },' ,
1375
+ ' componentWillUpdate (nextProps, nextState) {' ,
1376
+ ' const {something} = nextProps;' ,
1377
+ ' return something;' ,
1378
+ ' }' ,
1379
+ '})'
1380
+ ] . join ( '\n' ) ,
1381
+ parser : 'babel-eslint'
1355
1382
} , {
1356
1383
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors
1357
1384
code : [
@@ -1365,33 +1392,73 @@ ruleTester.run('no-unused-prop-types', rule, {
1365
1392
'}'
1366
1393
] . join ( '\n' ) ,
1367
1394
parser : 'babel-eslint'
1395
+ } , {
1396
+ // Destructured function props in the `componentWillUpdate` method shouldn't throw errors when used createReactClass
1397
+ code : [
1398
+ 'var Hello = createReactClass({' ,
1399
+ ' propTypes: {' ,
1400
+ ' something: PropTypes.bool,' ,
1401
+ ' },' ,
1402
+ ' componentWillUpdate ({something}, nextState) {' ,
1403
+ ' return something;' ,
1404
+ ' }' ,
1405
+ '})'
1406
+ ] . join ( '\n' ) ,
1407
+ parser : 'babel-eslint'
1368
1408
} , {
1369
1409
// Destructured props in the `componentDidUpdate` method shouldn't throw errors
1370
1410
code : [
1371
1411
'class Hello extends Component {' ,
1372
1412
' static propTypes = {' ,
1373
1413
' something: PropTypes.bool' ,
1374
1414
' }' ,
1375
- ' componentDidUpdate (prevProps, nextState ) {' ,
1415
+ ' componentDidUpdate (prevProps, prevState ) {' ,
1376
1416
' const {something} = prevProps;' ,
1377
1417
' return something;' ,
1378
1418
' }' ,
1379
1419
'}'
1380
1420
] . join ( '\n' ) ,
1381
1421
parser : 'babel-eslint'
1422
+ } , {
1423
+ // Destructured props in `componentDidUpdate` shouldn't throw errors when used createReactClass
1424
+ code : [
1425
+ 'var Hello = createReactClass({' ,
1426
+ ' propTypes: {' ,
1427
+ ' something: PropTypes.bool,' ,
1428
+ ' },' ,
1429
+ ' componentDidUpdate (prevProps, prevState) {' ,
1430
+ ' const {something} = prevProps;' ,
1431
+ ' return something;' ,
1432
+ ' }' ,
1433
+ '})'
1434
+ ] . join ( '\n' ) ,
1435
+ parser : 'babel-eslint'
1382
1436
} , {
1383
1437
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors
1384
1438
code : [
1385
1439
'class Hello extends Component {' ,
1386
1440
' static propTypes = {' ,
1387
1441
' something: PropTypes.bool' ,
1388
1442
' }' ,
1389
- ' componentDidUpdate ({something}, nextState ) {' ,
1443
+ ' componentDidUpdate ({something}, prevState ) {' ,
1390
1444
' return something;' ,
1391
1445
' }' ,
1392
1446
'}'
1393
1447
] . join ( '\n' ) ,
1394
1448
parser : 'babel-eslint'
1449
+ } , {
1450
+ // Destructured function props in the `componentDidUpdate` method shouldn't throw errors when used createReactClass
1451
+ code : [
1452
+ 'var Hello = createReactClass({' ,
1453
+ ' propTypes: {' ,
1454
+ ' something: PropTypes.bool,' ,
1455
+ ' },' ,
1456
+ ' componentDidUpdate ({something}, prevState) {' ,
1457
+ ' return something;' ,
1458
+ ' }' ,
1459
+ '})'
1460
+ ] . join ( '\n' ) ,
1461
+ parser : 'babel-eslint'
1395
1462
} , {
1396
1463
// Destructured state props in `componentDidUpdate` [Issue #825]
1397
1464
code : [
@@ -1405,6 +1472,19 @@ ruleTester.run('no-unused-prop-types', rule, {
1405
1472
'}'
1406
1473
] . join ( '\n' ) ,
1407
1474
parser : 'babel-eslint'
1475
+ } , {
1476
+ // Destructured state props in `componentDidUpdate` [Issue #825] when used createReactClass
1477
+ code : [
1478
+ 'var Hello = createReactClass({' ,
1479
+ ' propTypes: {' ,
1480
+ ' something: PropTypes.bool,' ,
1481
+ ' },' ,
1482
+ ' componentDidUpdate ({something}, {state1, state2}) {' ,
1483
+ ' return something;' ,
1484
+ ' }' ,
1485
+ '})'
1486
+ ] . join ( '\n' ) ,
1487
+ parser : 'babel-eslint'
1408
1488
} , {
1409
1489
// Destructured state props in `componentDidUpdate` without custom parser [Issue #825]
1410
1490
code : [
@@ -1417,6 +1497,18 @@ ruleTester.run('no-unused-prop-types', rule, {
1417
1497
' }' ,
1418
1498
'});'
1419
1499
] . join ( '\n' )
1500
+ } , {
1501
+ // Destructured state props in `componentDidUpdate` without custom parser [Issue #825] when used createReactClass
1502
+ code : [
1503
+ 'var Hello = createReactClass({' ,
1504
+ ' propTypes: {' ,
1505
+ ' something: PropTypes.bool,' ,
1506
+ ' },' ,
1507
+ ' componentDidUpdate: function ({something}, {state1, state2}) {' ,
1508
+ ' return something;' ,
1509
+ ' }' ,
1510
+ '})'
1511
+ ] . join ( '\n' )
1420
1512
} , {
1421
1513
// Destructured props in a stateless function
1422
1514
code : [
0 commit comments