eslint-plugin-sort-class-members
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -27,2 +27,5 @@ "use strict"; | ||
"enum": ['getThenSet', 'setThenGet', 'together', 'any'] | ||
}, | ||
locale: { | ||
type: 'string' | ||
} | ||
@@ -29,0 +32,0 @@ }, |
@@ -52,2 +52,3 @@ "use strict"; | ||
var groupAccessors = accessorPairPositioning !== 'any'; | ||
var locale = options.locale || 'en-US'; | ||
var rules = { | ||
@@ -94,3 +95,3 @@ ClassDeclaration: function ClassDeclaration(node) { | ||
var problems = findProblems(members); | ||
var problems = findProblems(members, locale); | ||
var problemCount = problems.length; | ||
@@ -309,6 +310,7 @@ | ||
function findProblems(members) { | ||
function findProblems(members, locale) { | ||
var problems = []; | ||
var collator = new Intl.Collator(locale); | ||
forEachPair(members, function (first, second) { | ||
if (!areMembersInCorrectOrder(first, second)) { | ||
if (!areMembersInCorrectOrder(first, second, collator)) { | ||
problems.push({ | ||
@@ -332,6 +334,6 @@ source: second, | ||
function areMembersInCorrectOrder(first, second) { | ||
function areMembersInCorrectOrder(first, second, collator) { | ||
return first.acceptableSlots.some(function (a) { | ||
return second.acceptableSlots.some(function (b) { | ||
return a.index === b.index && areSlotsAlphabeticallySorted(a, b) ? first.name.localeCompare(second.name) <= 0 : a.index <= b.index; | ||
return a.index === b.index && areSlotsAlphabeticallySorted(a, b) ? collator.compare(first.name, second.name) <= 0 : a.index <= b.index; | ||
}); | ||
@@ -338,0 +340,0 @@ }); |
{ | ||
"name": "eslint-plugin-sort-class-members", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "ESLint rule for enforcing consistent ES6 class member order.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -82,2 +82,3 @@ [![build][ci-image]][ci-url] | ||
- `stopAfterFirstProblem`: Only report the first sort problem in each class (plus the number of problems found). Useful if you only want to know that the class has sort problems without spamming error messages. The default is `false`. | ||
- `locale`: Used to specify the locale for the name comparison method. The default is `en-US`. | ||
@@ -84,0 +85,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30536
600
149