@@ -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 : [ {
@@ -1533,5 +1572,98 @@ ruleTester.run('sort-prop-types', rule, {
1533
1572
' }' ,
1534
1573
'});'
1535
1574
] . join ( '\n' )
1575
+ } , {
1576
+ code : `
1577
+ const shape = {
1578
+ c: PropTypes.any,
1579
+ a: PropTypes.any,
1580
+ b: PropTypes.bool,
1581
+ };
1582
+ class Component extends React.Component {
1583
+ static propTypes = {
1584
+ x: PropTypes.shape(shape),
1585
+ };
1586
+
1587
+ render() {
1588
+ return <div />;
1589
+ }
1590
+ }
1591
+ ` ,
1592
+ options : [ {
1593
+ sortShapeProp : true
1594
+ } ] ,
1595
+ parser : 'babel-eslint' ,
1596
+ errors : [ {
1597
+ message : ERROR_MESSAGE ,
1598
+ line : 4 ,
1599
+ column : 9 ,
1600
+ type : 'Property'
1601
+ } , {
1602
+ message : ERROR_MESSAGE ,
1603
+ line : 5 ,
1604
+ column : 9 ,
1605
+ type : 'Property'
1606
+ } ] ,
1607
+ output : `
1608
+ const shape = {
1609
+ a: PropTypes.any,
1610
+ b: PropTypes.bool,
1611
+ c: PropTypes.any,
1612
+ };
1613
+ class Component extends React.Component {
1614
+ static propTypes = {
1615
+ x: PropTypes.shape(shape),
1616
+ };
1617
+
1618
+ render() {
1619
+ return <div />;
1620
+ }
1621
+ }
1622
+ `
1623
+ } , {
1624
+ code : `
1625
+ const shape = {
1626
+ c: PropTypes.any,
1627
+ a: PropTypes.any,
1628
+ b: PropTypes.bool,
1629
+ };
1630
+ class Component extends React.Component {
1631
+ render() {
1632
+ return <div />;
1633
+ }
1634
+ }
1635
+ Component.propTypes = {
1636
+ x: PropTypes.shape(shape)
1637
+ };
1638
+ ` ,
1639
+ options : [ {
1640
+ sortShapeProp : true
1641
+ } ] ,
1642
+ errors : [ {
1643
+ message : ERROR_MESSAGE ,
1644
+ line : 4 ,
1645
+ column : 9 ,
1646
+ type : 'Property'
1647
+ } , {
1648
+ message : ERROR_MESSAGE ,
1649
+ line : 5 ,
1650
+ column : 9 ,
1651
+ type : 'Property'
1652
+ } ] ,
1653
+ output : `
1654
+ const shape = {
1655
+ a: PropTypes.any,
1656
+ b: PropTypes.bool,
1657
+ c: PropTypes.any,
1658
+ };
1659
+ class Component extends React.Component {
1660
+ render() {
1661
+ return <div />;
1662
+ }
1663
+ }
1664
+ Component.propTypes = {
1665
+ x: PropTypes.shape(shape)
1666
+ };
1667
+ `
1536
1668
} ]
1537
1669
} ) ;
0 commit comments