@@ -57,7 +57,7 @@ function alphabeticalCompare(a, b, ignoreCase) {
57
57
function getGroupsOfSortableAttributes ( attributes ) {
58
58
const sortableAttributeGroups = [ ] ;
59
59
let groupCount = 0 ;
60
- for ( var i = 0 ; i < attributes . length ; i ++ ) {
60
+ for ( let i = 0 ; i < attributes . length ; i ++ ) {
61
61
const lastAttr = attributes [ i - 1 ] ;
62
62
// If we have no groups or if the last attribute was JSXSpreadAttribute
63
63
// then we start a new group. Append attributes to the group until we
@@ -77,30 +77,30 @@ function getGroupsOfSortableAttributes(attributes) {
77
77
return sortableAttributeGroups ;
78
78
}
79
79
80
- function generateFixerFunction ( node , context ) {
81
- var sourceCode = context . getSourceCode ( ) ;
82
- var attributes = node . attributes . slice ( 0 ) ;
83
- var configuration = context . options [ 0 ] || { } ;
84
- var ignoreCase = configuration . ignoreCase || false ;
80
+ const generateFixerFunction = ( node , context ) => {
81
+ const sourceCode = context . getSourceCode ( ) ;
82
+ const attributes = node . attributes . slice ( 0 ) ;
83
+ const configuration = context . options [ 0 ] || { } ;
84
+ const ignoreCase = configuration . ignoreCase || false ;
85
85
86
86
// Sort props according to the context. Only supports ignoreCase.
87
87
// Since we cannot safely move JSXSpreadAttribute (due to potential variable overrides),
88
88
// we only consider groups of sortable attributes.
89
89
const sortableAttributeGroups = getGroupsOfSortableAttributes ( attributes ) ;
90
- const sortedAttributeGroups = sortableAttributeGroups . slice ( 0 ) . map ( function ( group ) {
91
- return group . slice ( 0 ) . sort ( function ( a , b ) {
92
- return alphabeticalCompare ( propName ( a ) , propName ( b ) , ignoreCase ) ;
93
- } ) ;
94
- } ) ;
90
+ const sortedAttributeGroups = sortableAttributeGroups . slice ( 0 ) . map ( group =>
91
+ group . slice ( 0 ) . sort ( ( a , b ) =>
92
+ alphabeticalCompare ( propName ( a ) , propName ( b ) , ignoreCase )
93
+ )
94
+ ) ;
95
95
96
96
return function ( fixer ) {
97
97
const fixers = [ ] ;
98
98
99
99
// Replace each unsorted attribute with the sorted one.
100
- sortableAttributeGroups . forEach ( function ( sortableGroup , ii ) {
101
- sortableGroup . forEach ( function ( attr , jj ) {
102
- var sortedAttr = sortedAttributeGroups [ ii ] [ jj ] ;
103
- var sortedAttrText = sourceCode . getText ( sortedAttr ) ;
100
+ sortableAttributeGroups . forEach ( ( sortableGroup , ii ) => {
101
+ sortableGroup . forEach ( ( attr , jj ) => {
102
+ const sortedAttr = sortedAttributeGroups [ ii ] [ jj ] ;
103
+ const sortedAttrText = sourceCode . getText ( sortedAttr ) ;
104
104
fixers . push (
105
105
fixer . replaceTextRange ( [ attr . start , attr . end ] , sortedAttrText )
106
106
) ;
@@ -109,7 +109,7 @@ function generateFixerFunction(node, context) {
109
109
110
110
return fixers ;
111
111
} ;
112
- }
112
+ } ;
113
113
114
114
/**
115
115
* Checks if the `reservedFirst` option is valid
0 commit comments