eslint-plugin-sort-class-members
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -36,2 +36,3 @@ 'use strict'; | ||
accessorPair: { type: 'boolean' }, | ||
sort: { enum: ['alphabetical', 'none'] }, | ||
static: { type: 'boolean' } | ||
@@ -38,0 +39,0 @@ }, |
@@ -78,3 +78,3 @@ 'use strict'; | ||
// check member positions against rule order | ||
var problems = findProblems(members, orderedSlots); | ||
var problems = findProblems(members); | ||
var problemCount = problems.length; | ||
@@ -253,3 +253,3 @@ var _iteratorNormalCompletion2 = true; | ||
return second.acceptableSlots.some(function (b) { | ||
return a <= b; | ||
return a.index === b.index && areSlotsAlphabeticallySorted(a, b) ? first.name.localeCompare(second.name) <= 0 : a.index <= b.index; | ||
}); | ||
@@ -259,5 +259,9 @@ }); | ||
function areSlotsAlphabeticallySorted(a, b) { | ||
return a.sort === 'alphabetical' && b.sort === 'alphabetical'; | ||
} | ||
function getAcceptableSlots(memberInfo, orderedSlots) { | ||
return orderedSlots.map(function (slot, index) { | ||
return { score: scoreMember(memberInfo, slot), index: index }; | ||
return { index: index, score: scoreMember(memberInfo, slot), sort: slot.sort }; | ||
}) // check member against each slot | ||
@@ -275,7 +279,3 @@ .filter(function (_ref3) { | ||
}) // take top scoring slots | ||
.map(function (_ref5) { | ||
var index = _ref5.index; | ||
return index; | ||
}) // we only need an array of slot indexes | ||
.sort(); | ||
.sort('index'); | ||
} | ||
@@ -288,6 +288,6 @@ | ||
var scores = comparers.map(function (_ref6) { | ||
var property = _ref6.property, | ||
value = _ref6.value, | ||
test = _ref6.test; | ||
var scores = comparers.map(function (_ref5) { | ||
var property = _ref5.property, | ||
value = _ref5.value, | ||
test = _ref5.test; | ||
@@ -348,4 +348,4 @@ if (slot[property] !== undefined) { | ||
function isAccessor(_ref7) { | ||
var kind = _ref7.kind; | ||
function isAccessor(_ref6) { | ||
var kind = _ref6.kind; | ||
@@ -426,2 +426,3 @@ return kind === 'get' || kind === 'set'; | ||
var builtInGroups = { | ||
constructor: { name: 'constructor', type: 'method' }, | ||
properties: { type: 'property' }, | ||
@@ -428,0 +429,0 @@ getters: { kind: 'get' }, |
{ | ||
"name": "eslint-plugin-sort-class-members", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "ESLint rule for enforcing consistent ES6 class member order.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -102,2 +102,3 @@ [![build status][travis-image]][travis-url] | ||
* `static`: `true|false` to restrict the match to static or instance members. | ||
* `sort`: `"alphabetical"|"none"`. Used to require a specific sorting within the slot for matched members. Defaults to `"none"`. | ||
@@ -110,2 +111,3 @@ A few examples: | ||
* `"/on.+/"` is shorthand for `{ "name": "/on.+/" }`, and would match all static and instance methods and properties whose names start with "on". | ||
* `{ "type": "method", "sort": "alphabetical" }` would match all methods, and enforce an alphabetical sort. | ||
@@ -112,0 +114,0 @@ **Note**: You can simply use a string if you only want to match on the name. |
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
24023
439
141