Skip to content

Commit

Permalink
fix(jsx-sort-props): remove the use of localeCompare
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoyopenroot committed Jan 28, 2020
1 parent e69b113 commit bbb31b9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rules/jsx-sort-props.js
Expand Up @@ -72,7 +72,7 @@ function contextCompare(a, b, options) {
aProp = aProp.toLowerCase();
bProp = bProp.toLowerCase();
}
return aProp.localeCompare(bProp);
return aProp < bProp ? -1 : 1;
}

/**
Expand All @@ -84,7 +84,7 @@ function contextCompare(a, b, options) {
function getGroupsOfSortableAttributes(attributes) {
const sortableAttributeGroups = [];
let groupCount = 0;
for (let i = 0; i < attributes.length; i++) {
for (let i = 0; i < attributes.length; i += 1) {
const lastAttr = attributes[i - 1];
// If we have no groups or if the last attribute was JSXSpreadAttribute
// then we start a new group. Append attributes to the group until we
Expand All @@ -94,7 +94,7 @@ function getGroupsOfSortableAttributes(attributes) {
(lastAttr.type === 'JSXSpreadAttribute' &&
attributes[i].type !== 'JSXSpreadAttribute')
) {
groupCount++;
groupCount += 1;
sortableAttributeGroups[groupCount - 1] = [];
}
if (attributes[i].type !== 'JSXSpreadAttribute') {
Expand Down Expand Up @@ -342,7 +342,7 @@ module.exports = {
}
}

if (!noSortAlphabetically && previousPropName.localeCompare(currentPropName) > 0) {
if (!noSortAlphabetically && previousPropName > currentPropName) {
context.report({
node: decl.name,
message: 'Props should be sorted alphabetically',
Expand Down

0 comments on commit bbb31b9

Please sign in to comment.