Skip to content

Commit b74a693

Browse files
authored
Merge pull request #1221 from jseminck/sort-props-regression
Fix regression bug in jsx-sort-props
2 parents a8d4c9b + 12067db commit b74a693

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rules/jsx-sort-props.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ module.exports = {
150150
var currentPropName = propName(decl);
151151
var previousValue = memo.value;
152152
var currentValue = decl.value;
153+
var previousIsCallback = isCallbackPropName(previousPropName);
154+
var currentIsCallback = isCallbackPropName(currentPropName);
153155

154156
if (ignoreCase) {
155157
previousPropName = previousPropName.toLowerCase();
@@ -186,9 +188,6 @@ module.exports = {
186188
}
187189

188190
if (callbacksLast) {
189-
var previousIsCallback = isCallbackPropName(previousPropName);
190-
var currentIsCallback = isCallbackPropName(currentPropName);
191-
192191
if (!previousIsCallback && currentIsCallback) {
193192
// Entering the callback prop section
194193
return decl;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ var expectedInvalidReservedFirstError = {
5656
var callbacksLastArgs = [{
5757
callbacksLast: true
5858
}];
59+
var ignoreCaseAndCallbackLastArgs = [{
60+
callbacksLast: true,
61+
ignoreCase: true
62+
}];
5963
var shorthandFirstArgs = [{
6064
shorthandFirst: true
6165
}];
@@ -109,6 +113,7 @@ ruleTester.run('jsx-sort-props', rule, {
109113
{code: '<App A b C />;', options: ignoreCaseArgs},
110114
// Sorting callbacks below all other props
111115
{code: '<App a z onBar onFoo />;', options: callbacksLastArgs},
116+
{code: '<App z onBar onFoo />;', options: ignoreCaseAndCallbackLastArgs},
112117
// Sorting shorthand props before others
113118
{code: '<App a b="b" />;', options: shorthandFirstArgs},
114119
{code: '<App z a="a" />;', options: shorthandFirstArgs},

0 commit comments

Comments
 (0)