Skip to content

Commit

Permalink
Fix fixer for jsx-sort-comp in case of more than 10 props
Browse files Browse the repository at this point in the history
  • Loading branch information
tihonove committed Oct 8, 2018
1 parent 8f2663e commit 4fa4469
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const generateFixerFunction = (node, context, reservedList) => {
});
});

fixers.sort((a, b) => a.range[0] < b.range[0]);
fixers.sort((a, b) => Math.sign(b.range[0] - a.range[0]));

const rangeStart = fixers[fixers.length - 1].range[0];
const rangeEnd = fixers[0].range[1];
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ ruleTester.run('jsx-sort-props', rule, {
`,
errors: 3
},
{
code: '<App b={2} c={3} d={4} e={5} f={6} g={7} h={8} i={9} j={10} k={11} a={1} />',
output: '<App a={1} b={2} c={3} d={4} e={5} f={6} g={7} h={8} i={9} j={10} k={11} />',
errors: 1
},
{
code: '<App key="key" b c="c" />',
errors: [expectedShorthandLastError],
Expand Down

0 comments on commit 4fa4469

Please sign in to comment.