@@ -428,6 +428,45 @@ ruleTester.run('sort-prop-types', rule, {
428
428
options : [ {
429
429
ignoreCase : true
430
430
} ]
431
+ } , {
432
+ code : `
433
+ const shape = {
434
+ a: PropTypes.any,
435
+ b: PropTypes.bool,
436
+ c: PropTypes.any,
437
+ };
438
+ class Component extends React.Component {
439
+ static propTypes = {
440
+ x: PropTypes.shape(shape),
441
+ };
442
+ render() {
443
+ return <div />;
444
+ }
445
+ }
446
+ ` ,
447
+ options : [ {
448
+ sortShapeProp : true
449
+ } ] ,
450
+ parser : 'babel-eslint'
451
+ } , {
452
+ code : `
453
+ const shape = {
454
+ a: PropTypes.any,
455
+ b: PropTypes.bool,
456
+ c: PropTypes.any,
457
+ };
458
+ class Component extends React.Component {
459
+ render() {
460
+ return <div />;
461
+ }
462
+ }
463
+ Component.propTypes = {
464
+ x: PropTypes.shape(shape)
465
+ };
466
+ ` ,
467
+ options : [ {
468
+ sortShapeProp : true
469
+ } ]
431
470
} ] ,
432
471
433
472
invalid : [ {
@@ -1615,5 +1654,98 @@ ruleTester.run('sort-prop-types', rule, {
1615
1654
1: PropTypes.any,
1616
1655
};
1617
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
+ static propTypes = {
1666
+ x: PropTypes.shape(shape),
1667
+ };
1668
+
1669
+ render() {
1670
+ return <div />;
1671
+ }
1672
+ }
1673
+ ` ,
1674
+ options : [ {
1675
+ sortShapeProp : true
1676
+ } ] ,
1677
+ parser : 'babel-eslint' ,
1678
+ errors : [ {
1679
+ message : ERROR_MESSAGE ,
1680
+ line : 4 ,
1681
+ column : 9 ,
1682
+ type : 'Property'
1683
+ } , {
1684
+ message : ERROR_MESSAGE ,
1685
+ line : 5 ,
1686
+ column : 9 ,
1687
+ type : 'Property'
1688
+ } ] ,
1689
+ output : `
1690
+ const shape = {
1691
+ a: PropTypes.any,
1692
+ b: PropTypes.bool,
1693
+ c: PropTypes.any,
1694
+ };
1695
+ class Component extends React.Component {
1696
+ static propTypes = {
1697
+ x: PropTypes.shape(shape),
1698
+ };
1699
+
1700
+ render() {
1701
+ return <div />;
1702
+ }
1703
+ }
1704
+ `
1705
+ } , {
1706
+ code : `
1707
+ const shape = {
1708
+ c: PropTypes.any,
1709
+ a: PropTypes.any,
1710
+ b: PropTypes.bool,
1711
+ };
1712
+ class Component extends React.Component {
1713
+ render() {
1714
+ return <div />;
1715
+ }
1716
+ }
1717
+ Component.propTypes = {
1718
+ x: PropTypes.shape(shape)
1719
+ };
1720
+ ` ,
1721
+ options : [ {
1722
+ sortShapeProp : true
1723
+ } ] ,
1724
+ errors : [ {
1725
+ message : ERROR_MESSAGE ,
1726
+ line : 4 ,
1727
+ column : 9 ,
1728
+ type : 'Property'
1729
+ } , {
1730
+ message : ERROR_MESSAGE ,
1731
+ line : 5 ,
1732
+ column : 9 ,
1733
+ type : 'Property'
1734
+ } ] ,
1735
+ output : `
1736
+ const shape = {
1737
+ a: PropTypes.any,
1738
+ b: PropTypes.bool,
1739
+ c: PropTypes.any,
1740
+ };
1741
+ class Component extends React.Component {
1742
+ render() {
1743
+ return <div />;
1744
+ }
1745
+ }
1746
+ Component.propTypes = {
1747
+ x: PropTypes.shape(shape)
1748
+ };
1749
+ `
1618
1750
} ]
1619
1751
} ) ;
0 commit comments