Skip to content

Commit 21faf02

Browse files
committed
[jsx-sort-props] Fix rule's behavior
- Remove unneccessary handling of sort-checking in jsx props, as this is being handled later by the general case anyways. - Fix erroneous call to `generateFixerFunction` in general sort-checking, which was missing the `reservedList` parameter.
1 parent 049d95e commit 21faf02

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/rules/jsx-sort-props.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,17 @@ module.exports = {
245245
const previousIsReserved = isReservedPropName(previousPropName, reservedList);
246246
const currentIsReserved = isReservedPropName(currentPropName, reservedList);
247247

248-
if ((previousIsReserved && currentIsReserved) || (!previousIsReserved && !currentIsReserved)) {
249-
if (!noSortAlphabetically && currentPropName < previousPropName) {
250-
context.report({
251-
node: decl,
252-
message: 'Props should be sorted alphabetically',
253-
fix: generateFixerFunction(node, context, reservedList)
254-
});
255-
return memo;
256-
}
248+
if (previousIsReserved && !currentIsReserved) {
249+
return decl;
257250
}
258251
if (!previousIsReserved && currentIsReserved) {
259252
context.report({
260253
node: decl,
261254
message: 'Reserved props must be listed before all other props',
262255
fix: generateFixerFunction(node, context, reservedList)
263256
});
257+
return memo;
264258
}
265-
return decl;
266259
}
267260

268261
if (callbacksLast) {
@@ -310,7 +303,7 @@ module.exports = {
310303
context.report({
311304
node: decl,
312305
message: 'Props should be sorted alphabetically',
313-
fix: generateFixerFunction(node, context)
306+
fix: generateFixerFunction(node, context, reservedList)
314307
});
315308
return memo;
316309
}

0 commit comments

Comments
 (0)