From bbb31b9a8ae55a109da7ebd763d92d50e6fea0ce Mon Sep 17 00:00:00 2001 From: tanmoyopenroot Date: Tue, 28 Jan 2020 12:37:17 +0530 Subject: [PATCH] fix(jsx-sort-props): remove the use of localeCompare --- lib/rules/jsx-sort-props.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 5b6265adb6..3785d21375 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -72,7 +72,7 @@ function contextCompare(a, b, options) { aProp = aProp.toLowerCase(); bProp = bProp.toLowerCase(); } - return aProp.localeCompare(bProp); + return aProp < bProp ? -1 : 1; } /** @@ -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 @@ -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') { @@ -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',