Skip to content

Commit e707116

Browse files
ROSSROSALESljharb
authored andcommitted
[].concat() for invalid test, removed option
1 parent 66cc55d commit e707116

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

lib/rules/jsx-sort-props.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ function contextCompare(a, b, options) {
5858
let aProp = propName(a);
5959
let bProp = propName(b);
6060

61+
const aSortToEnd = shouldSortToEnd(a);
62+
const bSortToEnd = shouldSortToEnd(b);
63+
if (aSortToEnd && !bSortToEnd) {
64+
return 1;
65+
}
66+
if (!aSortToEnd && bSortToEnd) {
67+
return -1;
68+
}
69+
6170
if (options.reservedFirst) {
6271
const aIsReserved = isReservedPropName(aProp, options.reservedList);
6372
const bIsReserved = isReservedPropName(bProp, options.reservedList);
@@ -106,17 +115,6 @@ function contextCompare(a, b, options) {
106115
return 0;
107116
}
108117

109-
if (options.commentbetween) {
110-
const aSortToEnd = shouldSortToEnd(a);
111-
const bSortToEnd = shouldSortToEnd(b);
112-
if (aSortToEnd && !bSortToEnd) {
113-
return 1;
114-
}
115-
if (!aSortToEnd && bSortToEnd) {
116-
return -1;
117-
}
118-
}
119-
120118
const actualLocale = options.locale === 'auto' ? undefined : options.locale;
121119

122120
if (options.ignoreCase) {
@@ -223,7 +221,6 @@ function generateFixerFunction(node, context, reservedList) {
223221
const noSortAlphabetically = configuration.noSortAlphabetically || false;
224222
const reservedFirst = configuration.reservedFirst || false;
225223
const locale = configuration.locale || 'auto';
226-
const commentbetween = configuration.commentbetween || true;
227224

228225
// Sort props according to the context. Only supports ignoreCase.
229226
// Since we cannot safely move JSXSpreadAttribute (due to potential variable overrides),
@@ -238,7 +235,6 @@ function generateFixerFunction(node, context, reservedList) {
238235
reservedFirst,
239236
reservedList,
240237
locale,
241-
commentbetween,
242238
};
243239
const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes, context);
244240
const sortedAttributeGroups = sortableAttributeGroups

tests/lib/rules/jsx-sort-props.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ ruleTester.run('jsx-sort-props', rule, {
298298
options: [{ locale: 'sk-SK' }],
299299
} : []
300300
)),
301-
invalid: parsers.all([
301+
invalid: parsers.all([].concat(
302302
{
303303
code: '<App b a />;',
304304
errors: [expectedError],
@@ -1048,5 +1048,5 @@ ruleTester.run('jsx-sort-props', rule, {
10481048
},
10491049
],
10501050
} : [],
1051-
]),
1051+
)),
10521052
});

0 commit comments

Comments
 (0)