-
Notifications
You must be signed in to change notification settings - Fork 6
/
sort-member-config.js
36 lines (34 loc) · 1.46 KB
/
sort-member-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const defaultGroups = {
"accessor-pairs": [{ "accessorPair": true, "sort": "alphabetical" }],
"accessors": [{ "kind": "get", "accessorPair": false, "sort": "alphabetical" }, { "kind": "set", "accessorPair": false, "sort": "alphabetical" }],
"methods": [{ "type": "method", "sort": "alphabetical" }],
"private-accessor-pairs": [{ "name": "/_.+/", "accessorPair": true, "sort": "alphabetical" }],
"private-accessors": [{ "name": "/_.+/", "kind": "get", "accessorPair": false, "sort": "alphabetical" }, { "name": "/_.+/", "kind": "set", "accessorPair": false, "sort": "alphabetical" }],
"private-methods": [{ "name": "/_.+/", "type": "method", "sort": "alphabetical" }],
"private-properties": [{ "name": "/_.+/", "type": "property", "sort": "none" }],
"properties": [{ "type": "property", "sort": "none" }],
"static-methods": [{ "type": "method", "sort": "alphabetical", "static": true }],
"static-properties": [{ "type": "property", "sort": "none", "static": true }]
};
const defaultOrder = [
"[static-properties]",
"[static-methods]",
"[properties]",
"constructor",
"[accessor-pairs]",
"[accessors]",
"[methods]",
"[private-properties]",
"[private-accessor-pairs]",
"[private-accessors]",
"[private-methods]"
];
module.exports.getSortMemberRules = (order, groups) => {
return {
"sort-class-members/sort-class-members": [2, {
"order": order ? order : defaultOrder,
"groups": {...defaultGroups, ...groups},
"accessorPairPositioning": "getThenSet"
}]
};
};