@@ -382,6 +382,45 @@ ruleTester.run('sort-prop-types', rule, {
382
382
options : [ {
383
383
sortShapeProp : true
384
384
} ]
385
+ } , {
386
+ code : `
387
+ const shape = {
388
+ a: PropTypes.any,
389
+ b: PropTypes.bool,
390
+ c: PropTypes.any,
391
+ };
392
+ class Component extends React.Component {
393
+ static propTypes = {
394
+ x: PropTypes.shape(shape),
395
+ };
396
+ render() {
397
+ return <div />;
398
+ }
399
+ }
400
+ ` ,
401
+ options : [ {
402
+ sortShapeProp : true
403
+ } ] ,
404
+ parser : 'babel-eslint'
405
+ } , {
406
+ code : `
407
+ const shape = {
408
+ a: PropTypes.any,
409
+ b: PropTypes.bool,
410
+ c: PropTypes.any,
411
+ };
412
+ class Component extends React.Component {
413
+ render() {
414
+ return <div />;
415
+ }
416
+ }
417
+ Component.propTypes = {
418
+ x: PropTypes.shape(shape)
419
+ };
420
+ ` ,
421
+ options : [ {
422
+ sortShapeProp : true
423
+ } ]
385
424
} ] ,
386
425
387
426
invalid : [ {
@@ -1471,5 +1510,98 @@ ruleTester.run('sort-prop-types', rule, {
1471
1510
}
1472
1511
}
1473
1512
`
1513
+ } , {
1514
+ code : `
1515
+ const shape = {
1516
+ c: PropTypes.any,
1517
+ a: PropTypes.any,
1518
+ b: PropTypes.bool,
1519
+ };
1520
+ class Component extends React.Component {
1521
+ static propTypes = {
1522
+ x: PropTypes.shape(shape),
1523
+ };
1524
+
1525
+ render() {
1526
+ return <div />;
1527
+ }
1528
+ }
1529
+ ` ,
1530
+ options : [ {
1531
+ sortShapeProp : true
1532
+ } ] ,
1533
+ parser : 'babel-eslint' ,
1534
+ errors : [ {
1535
+ message : ERROR_MESSAGE ,
1536
+ line : 4 ,
1537
+ column : 9 ,
1538
+ type : 'Property'
1539
+ } , {
1540
+ message : ERROR_MESSAGE ,
1541
+ line : 5 ,
1542
+ column : 9 ,
1543
+ type : 'Property'
1544
+ } ] ,
1545
+ output : `
1546
+ const shape = {
1547
+ a: PropTypes.any,
1548
+ b: PropTypes.bool,
1549
+ c: PropTypes.any,
1550
+ };
1551
+ class Component extends React.Component {
1552
+ static propTypes = {
1553
+ x: PropTypes.shape(shape),
1554
+ };
1555
+
1556
+ render() {
1557
+ return <div />;
1558
+ }
1559
+ }
1560
+ `
1561
+ } , {
1562
+ code : `
1563
+ const shape = {
1564
+ c: PropTypes.any,
1565
+ a: PropTypes.any,
1566
+ b: PropTypes.bool,
1567
+ };
1568
+ class Component extends React.Component {
1569
+ render() {
1570
+ return <div />;
1571
+ }
1572
+ }
1573
+ Component.propTypes = {
1574
+ x: PropTypes.shape(shape)
1575
+ };
1576
+ ` ,
1577
+ options : [ {
1578
+ sortShapeProp : true
1579
+ } ] ,
1580
+ errors : [ {
1581
+ message : ERROR_MESSAGE ,
1582
+ line : 4 ,
1583
+ column : 9 ,
1584
+ type : 'Property'
1585
+ } , {
1586
+ message : ERROR_MESSAGE ,
1587
+ line : 5 ,
1588
+ column : 9 ,
1589
+ type : 'Property'
1590
+ } ] ,
1591
+ output : `
1592
+ const shape = {
1593
+ a: PropTypes.any,
1594
+ b: PropTypes.bool,
1595
+ c: PropTypes.any,
1596
+ };
1597
+ class Component extends React.Component {
1598
+ render() {
1599
+ return <div />;
1600
+ }
1601
+ }
1602
+ Component.propTypes = {
1603
+ x: PropTypes.shape(shape)
1604
+ };
1605
+ `
1474
1606
} ]
1475
1607
} ) ;
0 commit comments