@@ -412,6 +412,45 @@ ruleTester.run('sort-prop-types', rule, {
412
412
options : [ {
413
413
noSortAlphabetically : true
414
414
} ]
415
+ } , {
416
+ code : `
417
+ const shape = {
418
+ a: PropTypes.any,
419
+ b: PropTypes.bool,
420
+ c: PropTypes.any,
421
+ };
422
+ class Component extends React.Component {
423
+ static propTypes = {
424
+ x: PropTypes.shape(shape),
425
+ };
426
+ render() {
427
+ return <div />;
428
+ }
429
+ }
430
+ ` ,
431
+ options : [ {
432
+ sortShapeProp : true
433
+ } ] ,
434
+ parser : 'babel-eslint'
435
+ } , {
436
+ code : `
437
+ const shape = {
438
+ a: PropTypes.any,
439
+ b: PropTypes.bool,
440
+ c: PropTypes.any,
441
+ };
442
+ class Component extends React.Component {
443
+ render() {
444
+ return <div />;
445
+ }
446
+ }
447
+ Component.propTypes = {
448
+ x: PropTypes.shape(shape)
449
+ };
450
+ ` ,
451
+ options : [ {
452
+ sortShapeProp : true
453
+ } ]
415
454
} ] ,
416
455
417
456
invalid : [ {
@@ -1567,5 +1606,98 @@ ruleTester.run('sort-prop-types', rule, {
1567
1606
' }' ,
1568
1607
'});'
1569
1608
] . join ( '\n' )
1609
+ } , {
1610
+ code : `
1611
+ const shape = {
1612
+ c: PropTypes.any,
1613
+ a: PropTypes.any,
1614
+ b: PropTypes.bool,
1615
+ };
1616
+ class Component extends React.Component {
1617
+ static propTypes = {
1618
+ x: PropTypes.shape(shape),
1619
+ };
1620
+
1621
+ render() {
1622
+ return <div />;
1623
+ }
1624
+ }
1625
+ ` ,
1626
+ options : [ {
1627
+ sortShapeProp : true
1628
+ } ] ,
1629
+ parser : 'babel-eslint' ,
1630
+ errors : [ {
1631
+ message : ERROR_MESSAGE ,
1632
+ line : 4 ,
1633
+ column : 9 ,
1634
+ type : 'Property'
1635
+ } , {
1636
+ message : ERROR_MESSAGE ,
1637
+ line : 5 ,
1638
+ column : 9 ,
1639
+ type : 'Property'
1640
+ } ] ,
1641
+ output : `
1642
+ const shape = {
1643
+ a: PropTypes.any,
1644
+ b: PropTypes.bool,
1645
+ c: PropTypes.any,
1646
+ };
1647
+ class Component extends React.Component {
1648
+ static propTypes = {
1649
+ x: PropTypes.shape(shape),
1650
+ };
1651
+
1652
+ render() {
1653
+ return <div />;
1654
+ }
1655
+ }
1656
+ `
1657
+ } , {
1658
+ code : `
1659
+ const shape = {
1660
+ c: PropTypes.any,
1661
+ a: PropTypes.any,
1662
+ b: PropTypes.bool,
1663
+ };
1664
+ class Component extends React.Component {
1665
+ render() {
1666
+ return <div />;
1667
+ }
1668
+ }
1669
+ Component.propTypes = {
1670
+ x: PropTypes.shape(shape)
1671
+ };
1672
+ ` ,
1673
+ options : [ {
1674
+ sortShapeProp : true
1675
+ } ] ,
1676
+ errors : [ {
1677
+ message : ERROR_MESSAGE ,
1678
+ line : 4 ,
1679
+ column : 9 ,
1680
+ type : 'Property'
1681
+ } , {
1682
+ message : ERROR_MESSAGE ,
1683
+ line : 5 ,
1684
+ column : 9 ,
1685
+ type : 'Property'
1686
+ } ] ,
1687
+ output : `
1688
+ const shape = {
1689
+ a: PropTypes.any,
1690
+ b: PropTypes.bool,
1691
+ c: PropTypes.any,
1692
+ };
1693
+ class Component extends React.Component {
1694
+ render() {
1695
+ return <div />;
1696
+ }
1697
+ }
1698
+ Component.propTypes = {
1699
+ x: PropTypes.shape(shape)
1700
+ };
1701
+ `
1570
1702
} ]
1571
1703
} ) ;
0 commit comments