eslint-plugin-perfectionist 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/dist/index.mjs +687 -675
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ESLintUtils as
|
|
1
|
+
import _ from "node:path";
|
|
2
|
+
import { ESLintUtils as ue, ASTUtils as W } from "@typescript-eslint/utils";
|
|
3
3
|
import { minimatch as $ } from "minimatch";
|
|
4
|
-
import
|
|
5
|
-
import { builtinModules as
|
|
6
|
-
let
|
|
4
|
+
import de from "natural-compare-lite";
|
|
5
|
+
import { builtinModules as ce } from "node:module";
|
|
6
|
+
let v = ue.RuleCreator(
|
|
7
7
|
(t) => `https://eslint-plugin-perfectionist.azat.io/rules/${t}`
|
|
8
|
-
),
|
|
8
|
+
), E = (t, o) => {
|
|
9
9
|
for (let s = 0, l = t.length; s < l; s++) {
|
|
10
10
|
let r = t[s];
|
|
11
|
-
if (
|
|
11
|
+
if (o.group === r || Array.isArray(r) && typeof o.group == "string" && r.includes(o.group))
|
|
12
12
|
return s;
|
|
13
13
|
}
|
|
14
14
|
return t.length;
|
|
15
|
-
},
|
|
16
|
-
let [
|
|
17
|
-
return s -
|
|
18
|
-
},
|
|
19
|
-
var
|
|
20
|
-
let
|
|
21
|
-
let
|
|
22
|
-
!
|
|
15
|
+
}, O = (t) => {
|
|
16
|
+
let [o, s] = t;
|
|
17
|
+
return s - o;
|
|
18
|
+
}, j = (t) => t > 0;
|
|
19
|
+
var i = /* @__PURE__ */ ((t) => (t.alphabetical = "alphabetical", t["line-length"] = "line-length", t.natural = "natural", t))(i || {}), c = /* @__PURE__ */ ((t) => (t.desc = "desc", t.asc = "asc", t))(c || {});
|
|
20
|
+
let M = (t) => {
|
|
21
|
+
let o, s = (r) => {
|
|
22
|
+
!o && t.flat().includes(r) && (o = r);
|
|
23
23
|
};
|
|
24
24
|
return {
|
|
25
|
-
getGroup: () =>
|
|
25
|
+
getGroup: () => o ?? "unknown",
|
|
26
26
|
setCustomGroups: (r, e) => {
|
|
27
27
|
if (r)
|
|
28
|
-
for (let [a,
|
|
29
|
-
Array.isArray(
|
|
30
|
-
(
|
|
28
|
+
for (let [a, p] of Object.entries(r))
|
|
29
|
+
Array.isArray(p) && p.some(
|
|
30
|
+
(n) => $(e, n, {
|
|
31
31
|
nocomment: !0
|
|
32
32
|
})
|
|
33
|
-
) && s(a), typeof
|
|
33
|
+
) && s(a), typeof p == "string" && $(e, p, {
|
|
34
34
|
nocomment: !0
|
|
35
35
|
}) && s(a);
|
|
36
36
|
},
|
|
37
37
|
defineGroup: s
|
|
38
38
|
};
|
|
39
|
-
},
|
|
40
|
-
var a,
|
|
41
|
-
if ((a =
|
|
39
|
+
}, A = (t, o, s) => {
|
|
40
|
+
var a, p;
|
|
41
|
+
if ((a = o.dependencies) != null && a.includes(t.name))
|
|
42
42
|
return -1;
|
|
43
|
-
if ((
|
|
43
|
+
if ((p = t.dependencies) != null && p.includes(o.name))
|
|
44
44
|
return 1;
|
|
45
|
-
let l = s.order === "asc" ? 1 : -1, r, e = (
|
|
46
|
-
return s.type ===
|
|
47
|
-
let y =
|
|
48
|
-
if (
|
|
49
|
-
let d = (
|
|
50
|
-
d(y,
|
|
45
|
+
let l = s.order === "asc" ? 1 : -1, r, e = (n) => s["ignore-case"] ? n.toLowerCase() : n;
|
|
46
|
+
return s.type === i.alphabetical ? r = (n, u) => e(n.name).localeCompare(e(u.name)) : s.type === i.natural ? r = (n, u) => de(e(n.name), e(u.name)) : r = (n, u) => {
|
|
47
|
+
let y = n.size, m = u.size, f = s["max-line-length"];
|
|
48
|
+
if (f) {
|
|
49
|
+
let d = (g, b) => g > f && b.hasMultipleImportDeclarations;
|
|
50
|
+
d(y, n) && (y = n.name.length + 10), d(m, u) && (m = u.name.length + 10);
|
|
51
51
|
}
|
|
52
52
|
return y - m;
|
|
53
|
-
}, l * r(t,
|
|
54
|
-
}, w = (t,
|
|
55
|
-
let s =
|
|
53
|
+
}, l * r(t, o);
|
|
54
|
+
}, w = (t, o) => [...t].sort((s, l) => A(s, l, o)), fe = (t, o) => {
|
|
55
|
+
let s = o.getTokenAfter(t, {
|
|
56
56
|
filter: ({ value: l, type: r }) => !(r === "Punctuator" && [",", ";"].includes(l)),
|
|
57
57
|
includeComments: !0
|
|
58
58
|
});
|
|
59
59
|
return ((s == null ? void 0 : s.type) === "Block" || (s == null ? void 0 : s.type) === "Line") && t.loc.end.line === s.loc.end.line ? s : null;
|
|
60
|
-
},
|
|
61
|
-
(s) => $(
|
|
60
|
+
}, pe = (t, o) => Array.isArray(t) && t.some(
|
|
61
|
+
(s) => $(o.trim(), s, {
|
|
62
62
|
nocomment: !0
|
|
63
63
|
})
|
|
64
|
-
) || typeof t == "string" && $(
|
|
64
|
+
) || typeof t == "string" && $(o.trim(), t, {
|
|
65
65
|
nocomment: !0
|
|
66
|
-
}) || t === !0,
|
|
67
|
-
let [s, l] =
|
|
66
|
+
}) || t === !0, J = (t, o) => {
|
|
67
|
+
let [s, l] = o.getTokensBefore(t, {
|
|
68
68
|
filter: ({ value: r, type: e }) => !(e === "Punctuator" && [",", ";"].includes(r)),
|
|
69
69
|
includeComments: !0,
|
|
70
70
|
count: 2
|
|
71
71
|
});
|
|
72
72
|
return ((l == null ? void 0 : l.type) === "Block" || (l == null ? void 0 : l.type) === "Line") && t.loc.start.line - l.loc.end.line <= 1 && (s == null ? void 0 : s.loc.end.line) !== l.loc.start.line ? l : null;
|
|
73
|
-
}, T = (t,
|
|
74
|
-
var
|
|
75
|
-
let l = t.range.at(0), r = t.range.at(1), e =
|
|
76
|
-
if (
|
|
77
|
-
let
|
|
73
|
+
}, T = (t, o, s) => {
|
|
74
|
+
var p;
|
|
75
|
+
let l = t.range.at(0), r = t.range.at(1), e = o.text.slice(l, r);
|
|
76
|
+
if (W.isParenthesized(t, o)) {
|
|
77
|
+
let n = o.getTokenBefore(
|
|
78
78
|
t,
|
|
79
|
-
|
|
80
|
-
), u =
|
|
79
|
+
W.isOpeningParenToken
|
|
80
|
+
), u = o.getTokenAfter(
|
|
81
81
|
t,
|
|
82
|
-
|
|
82
|
+
W.isClosingParenToken
|
|
83
83
|
);
|
|
84
|
-
l =
|
|
84
|
+
l = n.range.at(0), r = u.range.at(1);
|
|
85
85
|
}
|
|
86
|
-
let a =
|
|
86
|
+
let a = J(t, o);
|
|
87
87
|
if (e.endsWith(";") || e.endsWith(",")) {
|
|
88
|
-
let
|
|
88
|
+
let n = o.getTokensAfter(t, {
|
|
89
89
|
includeComments: !0,
|
|
90
90
|
count: 2
|
|
91
91
|
});
|
|
92
|
-
t.loc.start.line === ((
|
|
92
|
+
t.loc.start.line === ((p = n.at(1)) == null ? void 0 : p.loc.start.line) && (r -= 1);
|
|
93
93
|
}
|
|
94
|
-
return a && !
|
|
94
|
+
return a && !pe(
|
|
95
95
|
(s == null ? void 0 : s.partitionComment) ?? !1,
|
|
96
96
|
a.value
|
|
97
97
|
) && (l = a.range.at(0)), [l, r];
|
|
98
|
-
}, L = (t,
|
|
99
|
-
var
|
|
100
|
-
let e = [], a = ((
|
|
101
|
-
for (let u = 0, y =
|
|
102
|
-
let { node: m } =
|
|
98
|
+
}, L = (t, o, s, l, r) => {
|
|
99
|
+
var p, n;
|
|
100
|
+
let e = [], a = ((p = o.at(0)) == null ? void 0 : p.node.loc.start.line) === ((n = o.at(-1)) == null ? void 0 : n.node.loc.end.line);
|
|
101
|
+
for (let u = 0, y = o.length; u < y; u++) {
|
|
102
|
+
let { node: m } = o.at(u);
|
|
103
103
|
e.push(
|
|
104
104
|
t.replaceTextRange(
|
|
105
105
|
T(m, l, r),
|
|
@@ -108,32 +108,32 @@ let G = (t) => {
|
|
|
108
108
|
)
|
|
109
109
|
)
|
|
110
110
|
);
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
113
|
-
let
|
|
114
|
-
l.getTokenBefore(
|
|
115
|
-
|
|
111
|
+
let f = fe(s.at(u).node, l);
|
|
112
|
+
if (f && !a) {
|
|
113
|
+
let g = [
|
|
114
|
+
l.getTokenBefore(f).range.at(1),
|
|
115
|
+
f.range.at(1)
|
|
116
116
|
];
|
|
117
|
-
e.push(t.replaceTextRange(
|
|
117
|
+
e.push(t.replaceTextRange(g, ""));
|
|
118
118
|
let b = l.getTokenAfter(m);
|
|
119
119
|
e.push(
|
|
120
120
|
t.insertTextAfter(
|
|
121
121
|
(b == null ? void 0 : b.loc.end.line) === m.loc.end.line ? b : m,
|
|
122
|
-
l.text.slice(...
|
|
122
|
+
l.text.slice(...g)
|
|
123
123
|
)
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
return e;
|
|
128
|
-
},
|
|
128
|
+
}, k = (t = {}, o) => Object.assign(o, t), P = (t, o) => {
|
|
129
129
|
if (t.length > 1)
|
|
130
130
|
for (let s = 1; s < t.length; s++) {
|
|
131
131
|
let l = t.at(s - 1), r = t.at(s);
|
|
132
|
-
l && r &&
|
|
132
|
+
l && r && o(l, r, s - 1);
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
const
|
|
136
|
-
name:
|
|
135
|
+
const X = "sort-svelte-attributes", ge = v({
|
|
136
|
+
name: X,
|
|
137
137
|
meta: {
|
|
138
138
|
type: "suggestion",
|
|
139
139
|
docs: {
|
|
@@ -149,16 +149,16 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
149
149
|
},
|
|
150
150
|
type: {
|
|
151
151
|
enum: [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
i.alphabetical,
|
|
153
|
+
i.natural,
|
|
154
|
+
i["line-length"]
|
|
155
155
|
],
|
|
156
|
-
default:
|
|
156
|
+
default: i.alphabetical,
|
|
157
157
|
type: "string"
|
|
158
158
|
},
|
|
159
159
|
order: {
|
|
160
|
-
enum: [
|
|
161
|
-
default:
|
|
160
|
+
enum: [c.asc, c.desc],
|
|
161
|
+
default: c.asc,
|
|
162
162
|
type: "string"
|
|
163
163
|
},
|
|
164
164
|
"ignore-case": {
|
|
@@ -178,39 +178,39 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
178
178
|
},
|
|
179
179
|
defaultOptions: [
|
|
180
180
|
{
|
|
181
|
-
type:
|
|
182
|
-
order:
|
|
181
|
+
type: i.alphabetical,
|
|
182
|
+
order: c.asc
|
|
183
183
|
}
|
|
184
184
|
],
|
|
185
|
-
create: (t) =>
|
|
186
|
-
SvelteStartTag: (
|
|
187
|
-
if (
|
|
188
|
-
let s =
|
|
189
|
-
type:
|
|
190
|
-
order:
|
|
185
|
+
create: (t) => _.extname(t.filename) !== ".svelte" ? {} : {
|
|
186
|
+
SvelteStartTag: (o) => {
|
|
187
|
+
if (o.attributes.length > 1) {
|
|
188
|
+
let s = k(t.options.at(0), {
|
|
189
|
+
type: i.alphabetical,
|
|
190
|
+
order: c.asc,
|
|
191
191
|
"ignore-case": !1,
|
|
192
192
|
"custom-groups": {},
|
|
193
193
|
groups: []
|
|
194
|
-
}), l =
|
|
194
|
+
}), l = o.attributes.reduce(
|
|
195
195
|
(r, e) => {
|
|
196
196
|
if (e.type === "SvelteSpreadAttribute")
|
|
197
197
|
return r.push([]), r;
|
|
198
|
-
let a, { getGroup:
|
|
198
|
+
let a, { getGroup: p, defineGroup: n, setCustomGroups: u } = M(
|
|
199
199
|
s.groups
|
|
200
200
|
);
|
|
201
|
-
return e.key.type === "SvelteSpecialDirectiveKey" ? a = t.sourceCode.text.slice(...e.key.range) : typeof e.key.name == "string" ? { name: a } = e.key : a = t.sourceCode.text.slice(...e.key.range), u(s["custom-groups"], a), e.type === "SvelteShorthandAttribute" && (
|
|
202
|
-
size:
|
|
201
|
+
return e.key.type === "SvelteSpecialDirectiveKey" ? a = t.sourceCode.text.slice(...e.key.range) : typeof e.key.name == "string" ? { name: a } = e.key : a = t.sourceCode.text.slice(...e.key.range), u(s["custom-groups"], a), e.type === "SvelteShorthandAttribute" && (n("svelte-shorthand"), n("shorthand")), (!("value" in e) || Array.isArray(e.value) && !e.value.at(0)) && n("shorthand"), e.loc.start.line !== e.loc.end.line && n("multiline"), r.at(-1).push({
|
|
202
|
+
size: O(e.range),
|
|
203
203
|
node: e,
|
|
204
|
-
group:
|
|
204
|
+
group: p(),
|
|
205
205
|
name: a
|
|
206
206
|
}), r;
|
|
207
207
|
},
|
|
208
208
|
[[]]
|
|
209
209
|
);
|
|
210
210
|
for (let r of l)
|
|
211
|
-
|
|
212
|
-
let
|
|
213
|
-
(
|
|
211
|
+
P(r, (e, a) => {
|
|
212
|
+
let p = E(s.groups, e), n = E(s.groups, a);
|
|
213
|
+
(p > n || p === n && j(A(e, a, s))) && t.report({
|
|
214
214
|
messageId: "unexpectedSvelteAttributesOrder",
|
|
215
215
|
data: {
|
|
216
216
|
left: e.name,
|
|
@@ -219,18 +219,18 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
219
219
|
node: a.node,
|
|
220
220
|
fix: (u) => {
|
|
221
221
|
let y = {};
|
|
222
|
-
for (let
|
|
223
|
-
let d =
|
|
222
|
+
for (let f of r) {
|
|
223
|
+
let d = E(s.groups, f);
|
|
224
224
|
d in y ? y[d] = w(
|
|
225
|
-
[...y[d],
|
|
225
|
+
[...y[d], f],
|
|
226
226
|
s
|
|
227
|
-
) : y[d] = [
|
|
227
|
+
) : y[d] = [f];
|
|
228
228
|
}
|
|
229
229
|
let m = [];
|
|
230
|
-
for (let
|
|
231
|
-
(d,
|
|
230
|
+
for (let f of Object.keys(y).sort(
|
|
231
|
+
(d, g) => Number(d) - Number(g)
|
|
232
232
|
))
|
|
233
|
-
m.push(...w(y[
|
|
233
|
+
m.push(...w(y[f], s));
|
|
234
234
|
return L(
|
|
235
235
|
u,
|
|
236
236
|
r,
|
|
@@ -243,8 +243,8 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
}),
|
|
247
|
-
name:
|
|
246
|
+
}), q = "sort-astro-attributes", ye = v({
|
|
247
|
+
name: q,
|
|
248
248
|
meta: {
|
|
249
249
|
type: "suggestion",
|
|
250
250
|
docs: {
|
|
@@ -260,16 +260,16 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
260
260
|
},
|
|
261
261
|
type: {
|
|
262
262
|
enum: [
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
i.alphabetical,
|
|
264
|
+
i.natural,
|
|
265
|
+
i["line-length"]
|
|
266
266
|
],
|
|
267
|
-
default:
|
|
267
|
+
default: i.alphabetical,
|
|
268
268
|
type: "string"
|
|
269
269
|
},
|
|
270
270
|
order: {
|
|
271
|
-
enum: [
|
|
272
|
-
default:
|
|
271
|
+
enum: [c.asc, c.desc],
|
|
272
|
+
default: c.asc,
|
|
273
273
|
type: "string"
|
|
274
274
|
},
|
|
275
275
|
"ignore-case": {
|
|
@@ -289,18 +289,18 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
289
289
|
},
|
|
290
290
|
defaultOptions: [
|
|
291
291
|
{
|
|
292
|
-
type:
|
|
293
|
-
order:
|
|
292
|
+
type: i.alphabetical,
|
|
293
|
+
order: c.asc
|
|
294
294
|
}
|
|
295
295
|
],
|
|
296
296
|
// @ts-ignore
|
|
297
|
-
create: (t) =>
|
|
298
|
-
JSXElement: (
|
|
299
|
-
let { attributes: s } =
|
|
297
|
+
create: (t) => _.extname(t.filename) !== ".astro" ? {} : {
|
|
298
|
+
JSXElement: (o) => {
|
|
299
|
+
let { attributes: s } = o.openingElement;
|
|
300
300
|
if (s.length > 1) {
|
|
301
|
-
let l =
|
|
302
|
-
type:
|
|
303
|
-
order:
|
|
301
|
+
let l = k(t.options.at(0), {
|
|
302
|
+
type: i.alphabetical,
|
|
303
|
+
order: c.asc,
|
|
304
304
|
"ignore-case": !1,
|
|
305
305
|
"custom-groups": {},
|
|
306
306
|
groups: []
|
|
@@ -308,46 +308,46 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
308
308
|
(e, a) => {
|
|
309
309
|
if (a.type === "JSXSpreadAttribute")
|
|
310
310
|
return e.push([]), e;
|
|
311
|
-
let
|
|
311
|
+
let p = typeof a.name.name == "string" ? a.name.name : t.sourceCode.text.slice(...a.name.range), { getGroup: n, defineGroup: u, setCustomGroups: y } = M(
|
|
312
312
|
l.groups
|
|
313
313
|
);
|
|
314
|
-
return y(l["custom-groups"],
|
|
315
|
-
size:
|
|
314
|
+
return y(l["custom-groups"], p), a.type === "AstroShorthandAttribute" && (u("astro-shorthand"), u("shorthand")), a.value === null && u("shorthand"), a.loc.start.line !== a.loc.end.line && u("multiline"), e.at(-1).push({
|
|
315
|
+
size: O(a.range),
|
|
316
316
|
node: a,
|
|
317
|
-
group:
|
|
318
|
-
name:
|
|
317
|
+
group: n(),
|
|
318
|
+
name: p
|
|
319
319
|
}), e;
|
|
320
320
|
},
|
|
321
321
|
[[]]
|
|
322
322
|
);
|
|
323
323
|
for (let e of r)
|
|
324
|
-
|
|
325
|
-
let
|
|
326
|
-
(
|
|
324
|
+
P(e, (a, p) => {
|
|
325
|
+
let n = E(l.groups, a), u = E(l.groups, p);
|
|
326
|
+
(n > u || n === u && j(A(a, p, l))) && t.report({
|
|
327
327
|
messageId: "unexpectedAstroAttributesOrder",
|
|
328
328
|
data: {
|
|
329
329
|
left: a.name,
|
|
330
|
-
right:
|
|
330
|
+
right: p.name
|
|
331
331
|
},
|
|
332
|
-
node:
|
|
332
|
+
node: p.node,
|
|
333
333
|
fix: (y) => {
|
|
334
334
|
let m = {};
|
|
335
335
|
for (let d of e) {
|
|
336
|
-
let
|
|
337
|
-
|
|
338
|
-
[...m[
|
|
336
|
+
let g = E(l.groups, d);
|
|
337
|
+
g in m ? m[g] = w(
|
|
338
|
+
[...m[g], d],
|
|
339
339
|
l
|
|
340
|
-
) : m[
|
|
340
|
+
) : m[g] = [d];
|
|
341
341
|
}
|
|
342
|
-
let
|
|
342
|
+
let f = [];
|
|
343
343
|
for (let d of Object.keys(m).sort(
|
|
344
|
-
(
|
|
344
|
+
(g, b) => Number(g) - Number(b)
|
|
345
345
|
))
|
|
346
|
-
|
|
346
|
+
f.push(...w(m[d], l));
|
|
347
347
|
return L(
|
|
348
348
|
y,
|
|
349
349
|
e,
|
|
350
|
-
|
|
350
|
+
f,
|
|
351
351
|
t.sourceCode
|
|
352
352
|
);
|
|
353
353
|
}
|
|
@@ -357,9 +357,9 @@ const J = "sort-svelte-attributes", fe = O({
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
});
|
|
360
|
-
let
|
|
361
|
-
const
|
|
362
|
-
name:
|
|
360
|
+
let I = (t) => t.replaceAll(/\s\s+/g, " ").trim();
|
|
361
|
+
const K = "sort-array-includes", me = v({
|
|
362
|
+
name: K,
|
|
363
363
|
meta: {
|
|
364
364
|
type: "suggestion",
|
|
365
365
|
docs: {
|
|
@@ -372,16 +372,16 @@ const q = "sort-array-includes", ye = O({
|
|
|
372
372
|
properties: {
|
|
373
373
|
type: {
|
|
374
374
|
enum: [
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
i.alphabetical,
|
|
376
|
+
i.natural,
|
|
377
|
+
i["line-length"]
|
|
378
378
|
],
|
|
379
|
-
default:
|
|
379
|
+
default: i.alphabetical,
|
|
380
380
|
type: "string"
|
|
381
381
|
},
|
|
382
382
|
order: {
|
|
383
|
-
enum: [
|
|
384
|
-
default:
|
|
383
|
+
enum: [c.asc, c.desc],
|
|
384
|
+
default: c.asc,
|
|
385
385
|
type: "string"
|
|
386
386
|
},
|
|
387
387
|
"ignore-case": {
|
|
@@ -402,45 +402,45 @@ const q = "sort-array-includes", ye = O({
|
|
|
402
402
|
},
|
|
403
403
|
defaultOptions: [
|
|
404
404
|
{
|
|
405
|
-
type:
|
|
406
|
-
order:
|
|
405
|
+
type: i.alphabetical,
|
|
406
|
+
order: c.asc
|
|
407
407
|
}
|
|
408
408
|
],
|
|
409
409
|
create: (t) => ({
|
|
410
|
-
MemberExpression: (
|
|
411
|
-
if ((
|
|
412
|
-
let s =
|
|
410
|
+
MemberExpression: (o) => {
|
|
411
|
+
if ((o.object.type === "ArrayExpression" || o.object.type === "NewExpression") && o.property.type === "Identifier" && o.property.name === "includes") {
|
|
412
|
+
let s = o.object.type === "ArrayExpression" ? o.object.elements : o.object.arguments;
|
|
413
413
|
if (s.length > 1) {
|
|
414
|
-
let l =
|
|
415
|
-
type:
|
|
416
|
-
order:
|
|
414
|
+
let l = k(t.options.at(0), {
|
|
415
|
+
type: i.alphabetical,
|
|
416
|
+
order: c.asc,
|
|
417
417
|
"ignore-case": !1,
|
|
418
418
|
"spread-last": !1
|
|
419
419
|
}), r = s.reduce(
|
|
420
420
|
(e, a) => (a !== null && e.at(0).push({
|
|
421
421
|
name: a.type === "Literal" ? `${a.value}` : t.sourceCode.text.slice(...a.range),
|
|
422
|
-
size:
|
|
422
|
+
size: O(a.range),
|
|
423
423
|
type: a.type,
|
|
424
424
|
node: a
|
|
425
425
|
}), e),
|
|
426
426
|
[[], []]
|
|
427
427
|
).flat();
|
|
428
|
-
|
|
429
|
-
let
|
|
430
|
-
l["spread-last"] && e.node.type === "Literal" && a.node.type === "SpreadElement" ?
|
|
428
|
+
P(r, (e, a) => {
|
|
429
|
+
let p;
|
|
430
|
+
l["spread-last"] && e.node.type === "Literal" && a.node.type === "SpreadElement" ? p = !1 : l["spread-last"] && e.node.type === "SpreadElement" && a.node.type === "Literal" ? p = !0 : p = j(A(e, a, l)), p && t.report({
|
|
431
431
|
messageId: "unexpectedArrayIncludesOrder",
|
|
432
432
|
data: {
|
|
433
|
-
left:
|
|
434
|
-
right:
|
|
433
|
+
left: I(e.name),
|
|
434
|
+
right: I(a.name)
|
|
435
435
|
},
|
|
436
436
|
node: a.node,
|
|
437
|
-
fix: (
|
|
437
|
+
fix: (n) => {
|
|
438
438
|
let u = w(r, l);
|
|
439
439
|
if (l["spread-last"])
|
|
440
440
|
for (let y = 0, m = u.length; y < m; y++)
|
|
441
441
|
u.at(y).node.type === "SpreadElement" && u.push(u.splice(y, 1).at(0));
|
|
442
442
|
return L(
|
|
443
|
-
|
|
443
|
+
n,
|
|
444
444
|
r,
|
|
445
445
|
u,
|
|
446
446
|
t.sourceCode
|
|
@@ -452,8 +452,8 @@ const q = "sort-array-includes", ye = O({
|
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
})
|
|
455
|
-
}),
|
|
456
|
-
name:
|
|
455
|
+
}), H = "sort-vue-attributes", he = v({
|
|
456
|
+
name: H,
|
|
457
457
|
meta: {
|
|
458
458
|
type: "suggestion",
|
|
459
459
|
docs: {
|
|
@@ -469,16 +469,16 @@ const q = "sort-array-includes", ye = O({
|
|
|
469
469
|
},
|
|
470
470
|
type: {
|
|
471
471
|
enum: [
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
i.alphabetical,
|
|
473
|
+
i.natural,
|
|
474
|
+
i["line-length"]
|
|
475
475
|
],
|
|
476
|
-
default:
|
|
476
|
+
default: i.alphabetical,
|
|
477
477
|
type: "string"
|
|
478
478
|
},
|
|
479
479
|
order: {
|
|
480
|
-
enum: [
|
|
481
|
-
default:
|
|
480
|
+
enum: [c.asc, c.desc],
|
|
481
|
+
default: c.asc,
|
|
482
482
|
type: "string"
|
|
483
483
|
},
|
|
484
484
|
"ignore-case": {
|
|
@@ -499,22 +499,22 @@ const q = "sort-array-includes", ye = O({
|
|
|
499
499
|
},
|
|
500
500
|
defaultOptions: [
|
|
501
501
|
{
|
|
502
|
-
type:
|
|
503
|
-
order:
|
|
502
|
+
type: i.alphabetical,
|
|
503
|
+
order: c.asc
|
|
504
504
|
}
|
|
505
505
|
],
|
|
506
506
|
create: (t) => {
|
|
507
|
-
if (
|
|
507
|
+
if (_.extname(t.filename) !== ".vue")
|
|
508
508
|
return {};
|
|
509
509
|
if (!("defineTemplateBodyVisitor" in t.sourceCode.parserServices))
|
|
510
510
|
return {};
|
|
511
|
-
let { defineTemplateBodyVisitor:
|
|
512
|
-
return
|
|
511
|
+
let { defineTemplateBodyVisitor: o } = t.sourceCode.parserServices;
|
|
512
|
+
return o({
|
|
513
513
|
VStartTag: (s) => {
|
|
514
514
|
if (s.attributes.length > 1) {
|
|
515
|
-
let l =
|
|
516
|
-
type:
|
|
517
|
-
order:
|
|
515
|
+
let l = k(t.options.at(0), {
|
|
516
|
+
type: i.alphabetical,
|
|
517
|
+
order: c.asc,
|
|
518
518
|
"ignore-case": !1,
|
|
519
519
|
"custom-groups": {},
|
|
520
520
|
groups: []
|
|
@@ -522,46 +522,46 @@ const q = "sort-array-includes", ye = O({
|
|
|
522
522
|
(e, a) => {
|
|
523
523
|
if (a.key.type === "VDirectiveKey" && a.key.name.rawName === "bind")
|
|
524
524
|
return e.push([]), e;
|
|
525
|
-
let
|
|
525
|
+
let p, { getGroup: n, defineGroup: u, setCustomGroups: y } = M(
|
|
526
526
|
l.groups
|
|
527
527
|
);
|
|
528
|
-
return typeof a.key.name == "string" && a.key.type !== "VDirectiveKey" ?
|
|
529
|
-
size:
|
|
528
|
+
return typeof a.key.name == "string" && a.key.type !== "VDirectiveKey" ? p = a.key.rawName : p = t.sourceCode.text.slice(...a.key.range), y(l["custom-groups"], p), a.value === null && u("shorthand"), a.loc.start.line !== a.loc.end.line && u("multiline"), e.at(-1).push({
|
|
529
|
+
size: O(a.range),
|
|
530
530
|
node: a,
|
|
531
|
-
group:
|
|
532
|
-
name:
|
|
531
|
+
group: n(),
|
|
532
|
+
name: p
|
|
533
533
|
}), e;
|
|
534
534
|
},
|
|
535
535
|
[[]]
|
|
536
536
|
);
|
|
537
537
|
for (let e of r)
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
(
|
|
538
|
+
P(e, (a, p) => {
|
|
539
|
+
let n = E(l.groups, a), u = E(l.groups, p);
|
|
540
|
+
(n > u || n === u && j(A(a, p, l))) && t.report({
|
|
541
541
|
messageId: "unexpectedVueAttributesOrder",
|
|
542
542
|
data: {
|
|
543
543
|
left: a.name,
|
|
544
|
-
right:
|
|
544
|
+
right: p.name
|
|
545
545
|
},
|
|
546
|
-
node:
|
|
546
|
+
node: p.node,
|
|
547
547
|
fix: (y) => {
|
|
548
548
|
let m = {};
|
|
549
549
|
for (let d of e) {
|
|
550
|
-
let
|
|
551
|
-
|
|
552
|
-
[...m[
|
|
550
|
+
let g = E(l.groups, d);
|
|
551
|
+
g in m ? m[g] = w(
|
|
552
|
+
[...m[g], d],
|
|
553
553
|
l
|
|
554
|
-
) : m[
|
|
554
|
+
) : m[g] = [d];
|
|
555
555
|
}
|
|
556
|
-
let
|
|
556
|
+
let f = [];
|
|
557
557
|
for (let d of Object.keys(m).sort(
|
|
558
|
-
(
|
|
558
|
+
(g, b) => Number(g) - Number(b)
|
|
559
559
|
))
|
|
560
|
-
|
|
560
|
+
f.push(...w(m[d], l));
|
|
561
561
|
return L(
|
|
562
562
|
y,
|
|
563
563
|
e,
|
|
564
|
-
|
|
564
|
+
f,
|
|
565
565
|
t.sourceCode
|
|
566
566
|
);
|
|
567
567
|
}
|
|
@@ -571,8 +571,8 @@ const q = "sort-array-includes", ye = O({
|
|
|
571
571
|
}
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
|
-
}),
|
|
575
|
-
name:
|
|
574
|
+
}), Q = "sort-named-exports", be = v({
|
|
575
|
+
name: Q,
|
|
576
576
|
meta: {
|
|
577
577
|
type: "suggestion",
|
|
578
578
|
docs: {
|
|
@@ -585,16 +585,16 @@ const q = "sort-array-includes", ye = O({
|
|
|
585
585
|
properties: {
|
|
586
586
|
type: {
|
|
587
587
|
enum: [
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
i.alphabetical,
|
|
589
|
+
i.natural,
|
|
590
|
+
i["line-length"]
|
|
591
591
|
],
|
|
592
|
-
default:
|
|
592
|
+
default: i.alphabetical,
|
|
593
593
|
type: "string"
|
|
594
594
|
},
|
|
595
595
|
order: {
|
|
596
|
-
enum: [
|
|
597
|
-
default:
|
|
596
|
+
enum: [c.asc, c.desc],
|
|
597
|
+
default: c.asc,
|
|
598
598
|
type: "string"
|
|
599
599
|
},
|
|
600
600
|
"ignore-case": {
|
|
@@ -611,24 +611,24 @@ const q = "sort-array-includes", ye = O({
|
|
|
611
611
|
},
|
|
612
612
|
defaultOptions: [
|
|
613
613
|
{
|
|
614
|
-
type:
|
|
615
|
-
order:
|
|
614
|
+
type: i.alphabetical,
|
|
615
|
+
order: c.asc
|
|
616
616
|
}
|
|
617
617
|
],
|
|
618
618
|
create: (t) => ({
|
|
619
|
-
ExportNamedDeclaration: (
|
|
620
|
-
if (
|
|
621
|
-
let s =
|
|
622
|
-
type:
|
|
619
|
+
ExportNamedDeclaration: (o) => {
|
|
620
|
+
if (o.specifiers.length > 1) {
|
|
621
|
+
let s = k(t.options.at(0), {
|
|
622
|
+
type: i.alphabetical,
|
|
623
623
|
"ignore-case": !1,
|
|
624
|
-
order:
|
|
625
|
-
}), l =
|
|
626
|
-
size:
|
|
624
|
+
order: c.asc
|
|
625
|
+
}), l = o.specifiers.map((r) => ({
|
|
626
|
+
size: O(r.range),
|
|
627
627
|
name: r.local.name,
|
|
628
628
|
node: r
|
|
629
629
|
}));
|
|
630
|
-
|
|
631
|
-
|
|
630
|
+
P(l, (r, e) => {
|
|
631
|
+
j(A(r, e, s)) && t.report({
|
|
632
632
|
messageId: "unexpectedNamedExportsOrder",
|
|
633
633
|
data: {
|
|
634
634
|
left: r.name,
|
|
@@ -646,8 +646,8 @@ const q = "sort-array-includes", ye = O({
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
})
|
|
649
|
-
}),
|
|
650
|
-
name:
|
|
649
|
+
}), Y = "sort-named-imports", xe = v({
|
|
650
|
+
name: Y,
|
|
651
651
|
meta: {
|
|
652
652
|
type: "suggestion",
|
|
653
653
|
docs: {
|
|
@@ -660,16 +660,16 @@ const q = "sort-array-includes", ye = O({
|
|
|
660
660
|
properties: {
|
|
661
661
|
type: {
|
|
662
662
|
enum: [
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
663
|
+
i.alphabetical,
|
|
664
|
+
i.natural,
|
|
665
|
+
i["line-length"]
|
|
666
666
|
],
|
|
667
|
-
default:
|
|
667
|
+
default: i.alphabetical,
|
|
668
668
|
type: "string"
|
|
669
669
|
},
|
|
670
670
|
order: {
|
|
671
|
-
enum: [
|
|
672
|
-
default:
|
|
671
|
+
enum: [c.asc, c.desc],
|
|
672
|
+
default: c.asc,
|
|
673
673
|
type: "string"
|
|
674
674
|
},
|
|
675
675
|
"ignore-case": {
|
|
@@ -690,39 +690,39 @@ const q = "sort-array-includes", ye = O({
|
|
|
690
690
|
},
|
|
691
691
|
defaultOptions: [
|
|
692
692
|
{
|
|
693
|
-
type:
|
|
694
|
-
order:
|
|
693
|
+
type: i.alphabetical,
|
|
694
|
+
order: c.asc
|
|
695
695
|
}
|
|
696
696
|
],
|
|
697
697
|
create: (t) => ({
|
|
698
|
-
ImportDeclaration: (
|
|
699
|
-
let s =
|
|
698
|
+
ImportDeclaration: (o) => {
|
|
699
|
+
let s = o.specifiers.filter(
|
|
700
700
|
({ type: l }) => l === "ImportSpecifier"
|
|
701
701
|
);
|
|
702
702
|
if (s.length > 1) {
|
|
703
|
-
let l =
|
|
704
|
-
type:
|
|
703
|
+
let l = k(t.options.at(0), {
|
|
704
|
+
type: i.alphabetical,
|
|
705
705
|
"ignore-alias": !0,
|
|
706
706
|
"ignore-case": !1,
|
|
707
|
-
order:
|
|
707
|
+
order: c.asc
|
|
708
708
|
}), r = s.map((e) => {
|
|
709
709
|
let { name: a } = e.local;
|
|
710
710
|
return l["ignore-alias"] && e.type === "ImportSpecifier" && ({ name: a } = e.imported), {
|
|
711
|
-
size:
|
|
711
|
+
size: O(e.range),
|
|
712
712
|
node: e,
|
|
713
713
|
name: a
|
|
714
714
|
};
|
|
715
715
|
});
|
|
716
|
-
|
|
717
|
-
|
|
716
|
+
P(r, (e, a) => {
|
|
717
|
+
j(A(e, a, l)) && t.report({
|
|
718
718
|
messageId: "unexpectedNamedImportsOrder",
|
|
719
719
|
data: {
|
|
720
720
|
left: e.name,
|
|
721
721
|
right: a.name
|
|
722
722
|
},
|
|
723
723
|
node: a.node,
|
|
724
|
-
fix: (
|
|
725
|
-
|
|
724
|
+
fix: (p) => L(
|
|
725
|
+
p,
|
|
726
726
|
r,
|
|
727
727
|
w(r, l),
|
|
728
728
|
t.sourceCode
|
|
@@ -733,12 +733,12 @@ const q = "sort-array-includes", ye = O({
|
|
|
733
733
|
}
|
|
734
734
|
})
|
|
735
735
|
});
|
|
736
|
-
let z = (t,
|
|
737
|
-
|
|
736
|
+
let z = (t, o, s) => t.lines.slice(
|
|
737
|
+
o.node.loc.end.line,
|
|
738
738
|
s.node.loc.start.line - 1
|
|
739
739
|
).filter((r) => !r.trim().length).length;
|
|
740
|
-
const
|
|
741
|
-
name:
|
|
740
|
+
const Z = "sort-object-types", Ee = v({
|
|
741
|
+
name: Z,
|
|
742
742
|
meta: {
|
|
743
743
|
type: "suggestion",
|
|
744
744
|
docs: {
|
|
@@ -754,16 +754,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
754
754
|
},
|
|
755
755
|
type: {
|
|
756
756
|
enum: [
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
757
|
+
i.alphabetical,
|
|
758
|
+
i.natural,
|
|
759
|
+
i["line-length"]
|
|
760
760
|
],
|
|
761
|
-
default:
|
|
761
|
+
default: i.alphabetical,
|
|
762
762
|
type: "string"
|
|
763
763
|
},
|
|
764
764
|
order: {
|
|
765
|
-
enum: [
|
|
766
|
-
default:
|
|
765
|
+
enum: [c.asc, c.desc],
|
|
766
|
+
default: c.asc,
|
|
767
767
|
type: "string"
|
|
768
768
|
},
|
|
769
769
|
"ignore-case": {
|
|
@@ -788,53 +788,53 @@ const Y = "sort-object-types", xe = O({
|
|
|
788
788
|
},
|
|
789
789
|
defaultOptions: [
|
|
790
790
|
{
|
|
791
|
-
type:
|
|
792
|
-
order:
|
|
791
|
+
type: i.alphabetical,
|
|
792
|
+
order: c.asc
|
|
793
793
|
}
|
|
794
794
|
],
|
|
795
795
|
create: (t) => ({
|
|
796
|
-
TSTypeLiteral: (
|
|
797
|
-
if (
|
|
798
|
-
let s =
|
|
796
|
+
TSTypeLiteral: (o) => {
|
|
797
|
+
if (o.members.length > 1) {
|
|
798
|
+
let s = k(t.options.at(0), {
|
|
799
799
|
"partition-by-new-line": !1,
|
|
800
|
-
type:
|
|
800
|
+
type: i.alphabetical,
|
|
801
801
|
"ignore-case": !1,
|
|
802
|
-
order:
|
|
802
|
+
order: c.asc,
|
|
803
803
|
"custom-groups": {},
|
|
804
804
|
groups: []
|
|
805
|
-
}), l =
|
|
805
|
+
}), l = o.members.reduce(
|
|
806
806
|
(r, e) => {
|
|
807
|
-
var
|
|
808
|
-
let a,
|
|
807
|
+
var N, h, C, x;
|
|
808
|
+
let a, p = t.sourceCode.text.slice(
|
|
809
809
|
e.range.at(0),
|
|
810
810
|
e.range.at(1)
|
|
811
|
-
),
|
|
811
|
+
), n = (N = r.at(-1)) == null ? void 0 : N.at(-1), { getGroup: u, defineGroup: y, setCustomGroups: m } = M(
|
|
812
812
|
s.groups
|
|
813
|
-
),
|
|
813
|
+
), f = (S) => S.replace(/(,|;)$/, "");
|
|
814
814
|
if (e.type === "TSPropertySignature")
|
|
815
815
|
e.key.type === "Identifier" ? { name: a } = e.key : e.key.type === "Literal" ? a = `${e.key.value}` : a = t.sourceCode.text.slice(
|
|
816
816
|
e.range.at(0),
|
|
817
817
|
(h = e.typeAnnotation) == null ? void 0 : h.range.at(0)
|
|
818
818
|
);
|
|
819
819
|
else if (e.type === "TSIndexSignature") {
|
|
820
|
-
let
|
|
821
|
-
a =
|
|
822
|
-
t.sourceCode.text.slice(e.range.at(0),
|
|
820
|
+
let S = ((C = e.typeAnnotation) == null ? void 0 : C.range.at(0)) ?? e.range.at(1);
|
|
821
|
+
a = f(
|
|
822
|
+
t.sourceCode.text.slice(e.range.at(0), S)
|
|
823
823
|
);
|
|
824
824
|
} else
|
|
825
|
-
a =
|
|
825
|
+
a = f(
|
|
826
826
|
t.sourceCode.text.slice(
|
|
827
827
|
e.range.at(0),
|
|
828
828
|
e.range.at(1)
|
|
829
829
|
)
|
|
830
830
|
);
|
|
831
831
|
m(s["custom-groups"], a), e.loc.start.line !== e.loc.end.line && y("multiline");
|
|
832
|
-
let
|
|
833
|
-
size:
|
|
832
|
+
let g = p.endsWith(";") || p.endsWith(",") ? 1 : 0, b = {
|
|
833
|
+
size: O(e.range) - g,
|
|
834
834
|
node: e,
|
|
835
835
|
name: a
|
|
836
836
|
};
|
|
837
|
-
return s["partition-by-new-line"] &&
|
|
837
|
+
return s["partition-by-new-line"] && n && z(t.sourceCode, n, b) && r.push([]), (x = r.at(-1)) == null || x.push({
|
|
838
838
|
...b,
|
|
839
839
|
group: u()
|
|
840
840
|
}), r;
|
|
@@ -842,29 +842,29 @@ const Y = "sort-object-types", xe = O({
|
|
|
842
842
|
[[]]
|
|
843
843
|
);
|
|
844
844
|
for (let r of l)
|
|
845
|
-
|
|
846
|
-
let
|
|
847
|
-
(
|
|
845
|
+
P(r, (e, a) => {
|
|
846
|
+
let p = E(s.groups, e), n = E(s.groups, a);
|
|
847
|
+
(p > n || p === n && j(A(e, a, s))) && t.report({
|
|
848
848
|
messageId: "unexpectedObjectTypesOrder",
|
|
849
849
|
data: {
|
|
850
|
-
left:
|
|
851
|
-
right:
|
|
850
|
+
left: I(e.name),
|
|
851
|
+
right: I(a.name)
|
|
852
852
|
},
|
|
853
853
|
node: a.node,
|
|
854
854
|
fix: (u) => {
|
|
855
855
|
let y = {};
|
|
856
|
-
for (let
|
|
857
|
-
let d =
|
|
856
|
+
for (let f of r) {
|
|
857
|
+
let d = E(s.groups, f);
|
|
858
858
|
d in y ? y[d] = w(
|
|
859
|
-
[...y[d],
|
|
859
|
+
[...y[d], f],
|
|
860
860
|
s
|
|
861
|
-
) : y[d] = [
|
|
861
|
+
) : y[d] = [f];
|
|
862
862
|
}
|
|
863
863
|
let m = [];
|
|
864
|
-
for (let
|
|
865
|
-
(d,
|
|
864
|
+
for (let f of Object.keys(y).sort(
|
|
865
|
+
(d, g) => Number(d) - Number(g)
|
|
866
866
|
))
|
|
867
|
-
m.push(...w(y[
|
|
867
|
+
m.push(...w(y[f], s));
|
|
868
868
|
return L(
|
|
869
869
|
u,
|
|
870
870
|
r,
|
|
@@ -877,8 +877,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
})
|
|
880
|
-
}),
|
|
881
|
-
name:
|
|
880
|
+
}), F = "sort-union-types", Ce = v({
|
|
881
|
+
name: F,
|
|
882
882
|
meta: {
|
|
883
883
|
type: "suggestion",
|
|
884
884
|
docs: {
|
|
@@ -891,16 +891,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
891
891
|
properties: {
|
|
892
892
|
type: {
|
|
893
893
|
enum: [
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
894
|
+
i.alphabetical,
|
|
895
|
+
i.natural,
|
|
896
|
+
i["line-length"]
|
|
897
897
|
],
|
|
898
|
-
default:
|
|
898
|
+
default: i.alphabetical,
|
|
899
899
|
type: "string"
|
|
900
900
|
},
|
|
901
901
|
order: {
|
|
902
|
-
enum: [
|
|
903
|
-
default:
|
|
902
|
+
enum: [c.asc, c.desc],
|
|
903
|
+
default: c.asc,
|
|
904
904
|
type: "string"
|
|
905
905
|
},
|
|
906
906
|
"ignore-case": {
|
|
@@ -921,50 +921,50 @@ const Y = "sort-object-types", xe = O({
|
|
|
921
921
|
},
|
|
922
922
|
defaultOptions: [
|
|
923
923
|
{
|
|
924
|
-
type:
|
|
925
|
-
order:
|
|
924
|
+
type: i.alphabetical,
|
|
925
|
+
order: c.asc
|
|
926
926
|
}
|
|
927
927
|
],
|
|
928
928
|
create: (t) => ({
|
|
929
|
-
TSUnionType: (
|
|
930
|
-
let s =
|
|
931
|
-
type:
|
|
929
|
+
TSUnionType: (o) => {
|
|
930
|
+
let s = k(t.options.at(0), {
|
|
931
|
+
type: i.alphabetical,
|
|
932
932
|
"nullable-last": !1,
|
|
933
933
|
"ignore-case": !1,
|
|
934
|
-
order:
|
|
935
|
-
}), l =
|
|
934
|
+
order: c.asc
|
|
935
|
+
}), l = o.types.map((r) => ({
|
|
936
936
|
group: r.type === "TSNullKeyword" || r.type === "TSUndefinedKeyword" ? "nullable" : "unknown",
|
|
937
937
|
name: t.sourceCode.text.slice(...r.range),
|
|
938
|
-
size:
|
|
938
|
+
size: O(r.range),
|
|
939
939
|
node: r
|
|
940
940
|
}));
|
|
941
|
-
|
|
942
|
-
let a =
|
|
941
|
+
P(l, (r, e) => {
|
|
942
|
+
let a = j(A(r, e, s));
|
|
943
943
|
s["nullable-last"] && (r.group === "nullable" && e.group === "unknown" ? a = !0 : r.group === "unknown" && e.group === "nullable" && (a = !1)), a && t.report({
|
|
944
944
|
messageId: "unexpectedUnionTypesOrder",
|
|
945
945
|
data: {
|
|
946
|
-
left:
|
|
947
|
-
right:
|
|
946
|
+
left: I(r.name),
|
|
947
|
+
right: I(e.name)
|
|
948
948
|
},
|
|
949
949
|
node: e.node,
|
|
950
|
-
fix: (
|
|
951
|
-
let
|
|
950
|
+
fix: (p) => {
|
|
951
|
+
let n = [];
|
|
952
952
|
if (s["nullable-last"]) {
|
|
953
953
|
let u = [], y = l.filter((m) => m.group === "nullable" ? (u.push(m), !1) : !0);
|
|
954
|
-
|
|
954
|
+
n = [
|
|
955
955
|
...w(y, s),
|
|
956
956
|
...w(u, s)
|
|
957
957
|
];
|
|
958
958
|
} else
|
|
959
|
-
|
|
960
|
-
return L(
|
|
959
|
+
n = w(l, s);
|
|
960
|
+
return L(p, l, n, t.sourceCode);
|
|
961
961
|
}
|
|
962
962
|
});
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
965
|
})
|
|
966
|
-
}),
|
|
967
|
-
name:
|
|
966
|
+
}), ee = "sort-interfaces", Ne = v({
|
|
967
|
+
name: ee,
|
|
968
968
|
meta: {
|
|
969
969
|
type: "suggestion",
|
|
970
970
|
docs: {
|
|
@@ -980,16 +980,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
980
980
|
},
|
|
981
981
|
type: {
|
|
982
982
|
enum: [
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
983
|
+
i.alphabetical,
|
|
984
|
+
i.natural,
|
|
985
|
+
i["line-length"]
|
|
986
986
|
],
|
|
987
|
-
default:
|
|
987
|
+
default: i.alphabetical,
|
|
988
988
|
type: "string"
|
|
989
989
|
},
|
|
990
990
|
order: {
|
|
991
|
-
enum: [
|
|
992
|
-
default:
|
|
991
|
+
enum: [c.asc, c.desc],
|
|
992
|
+
default: c.asc,
|
|
993
993
|
type: "string"
|
|
994
994
|
},
|
|
995
995
|
"ignore-case": {
|
|
@@ -1020,97 +1020,97 @@ const Y = "sort-object-types", xe = O({
|
|
|
1020
1020
|
},
|
|
1021
1021
|
defaultOptions: [
|
|
1022
1022
|
{
|
|
1023
|
-
type:
|
|
1024
|
-
order:
|
|
1023
|
+
type: i.alphabetical,
|
|
1024
|
+
order: c.asc
|
|
1025
1025
|
}
|
|
1026
1026
|
],
|
|
1027
1027
|
create: (t) => ({
|
|
1028
|
-
TSInterfaceDeclaration: (
|
|
1029
|
-
if (
|
|
1030
|
-
let s =
|
|
1028
|
+
TSInterfaceDeclaration: (o) => {
|
|
1029
|
+
if (o.body.body.length > 1) {
|
|
1030
|
+
let s = k(t.options.at(0), {
|
|
1031
1031
|
"partition-by-new-line": !1,
|
|
1032
|
-
type:
|
|
1032
|
+
type: i.alphabetical,
|
|
1033
1033
|
"ignore-case": !1,
|
|
1034
|
-
order:
|
|
1034
|
+
order: c.asc,
|
|
1035
1035
|
"ignore-pattern": [],
|
|
1036
1036
|
"custom-groups": {},
|
|
1037
1037
|
groups: []
|
|
1038
1038
|
});
|
|
1039
1039
|
if (!s["ignore-pattern"].some(
|
|
1040
|
-
(l) => $(
|
|
1040
|
+
(l) => $(o.id.name, l, {
|
|
1041
1041
|
nocomment: !0
|
|
1042
1042
|
})
|
|
1043
1043
|
)) {
|
|
1044
|
-
let l =
|
|
1044
|
+
let l = o.body.body.reduce(
|
|
1045
1045
|
(r, e) => {
|
|
1046
|
-
var
|
|
1046
|
+
var f, d, g, b;
|
|
1047
1047
|
if (e.type === "TSCallSignatureDeclaration")
|
|
1048
1048
|
return r.push([]), r;
|
|
1049
|
-
let a = (
|
|
1049
|
+
let a = (f = r.at(-1)) == null ? void 0 : f.at(-1), p, { getGroup: n, defineGroup: u, setCustomGroups: y } = M(
|
|
1050
1050
|
s.groups
|
|
1051
1051
|
);
|
|
1052
1052
|
if (e.type === "TSPropertySignature")
|
|
1053
1053
|
if (e.key.type === "Identifier")
|
|
1054
|
-
({ name:
|
|
1054
|
+
({ name: p } = e.key);
|
|
1055
1055
|
else if (e.key.type === "Literal")
|
|
1056
|
-
|
|
1056
|
+
p = `${e.key.value}`;
|
|
1057
1057
|
else {
|
|
1058
|
-
let
|
|
1059
|
-
|
|
1058
|
+
let N = ((d = e.typeAnnotation) == null ? void 0 : d.range.at(0)) ?? e.range.at(1) - (e.optional ? 1 : 0);
|
|
1059
|
+
p = t.sourceCode.text.slice(e.range.at(0), N);
|
|
1060
1060
|
}
|
|
1061
1061
|
else if (e.type === "TSIndexSignature") {
|
|
1062
|
-
let
|
|
1063
|
-
|
|
1062
|
+
let N = ((g = e.typeAnnotation) == null ? void 0 : g.range.at(0)) ?? e.range.at(1);
|
|
1063
|
+
p = t.sourceCode.text.slice(
|
|
1064
1064
|
e.range.at(0),
|
|
1065
|
-
|
|
1065
|
+
N
|
|
1066
1066
|
);
|
|
1067
1067
|
} else {
|
|
1068
|
-
let
|
|
1069
|
-
|
|
1068
|
+
let N = ((b = e.returnType) == null ? void 0 : b.range.at(0)) ?? e.range.at(1);
|
|
1069
|
+
p = t.sourceCode.text.slice(
|
|
1070
1070
|
e.range.at(0),
|
|
1071
|
-
|
|
1071
|
+
N
|
|
1072
1072
|
);
|
|
1073
1073
|
}
|
|
1074
1074
|
let m = {
|
|
1075
|
-
size:
|
|
1075
|
+
size: O(e.range),
|
|
1076
1076
|
node: e,
|
|
1077
|
-
name:
|
|
1077
|
+
name: p
|
|
1078
1078
|
};
|
|
1079
1079
|
return s["partition-by-new-line"] && a && z(
|
|
1080
1080
|
t.sourceCode,
|
|
1081
1081
|
a,
|
|
1082
1082
|
m
|
|
1083
|
-
) && r.push([]), y(s["custom-groups"],
|
|
1083
|
+
) && r.push([]), y(s["custom-groups"], p), e.loc.start.line !== e.loc.end.line && u("multiline"), r.at(-1).push({
|
|
1084
1084
|
...m,
|
|
1085
|
-
group:
|
|
1085
|
+
group: n()
|
|
1086
1086
|
}), r;
|
|
1087
1087
|
},
|
|
1088
1088
|
[[]]
|
|
1089
1089
|
);
|
|
1090
1090
|
for (let r of l)
|
|
1091
|
-
|
|
1092
|
-
let
|
|
1093
|
-
(
|
|
1091
|
+
P(r, (e, a) => {
|
|
1092
|
+
let p = E(s.groups, e), n = E(s.groups, a);
|
|
1093
|
+
(p > n || p === n && j(A(e, a, s))) && t.report({
|
|
1094
1094
|
messageId: "unexpectedInterfacePropertiesOrder",
|
|
1095
1095
|
data: {
|
|
1096
|
-
left:
|
|
1097
|
-
right:
|
|
1096
|
+
left: I(e.name),
|
|
1097
|
+
right: I(a.name)
|
|
1098
1098
|
},
|
|
1099
1099
|
node: a.node,
|
|
1100
1100
|
fix: (u) => {
|
|
1101
1101
|
let y = {};
|
|
1102
|
-
for (let
|
|
1103
|
-
let d =
|
|
1102
|
+
for (let f of r) {
|
|
1103
|
+
let d = E(s.groups, f);
|
|
1104
1104
|
d in y ? y[d] = w(
|
|
1105
|
-
[...y[d],
|
|
1105
|
+
[...y[d], f],
|
|
1106
1106
|
s
|
|
1107
|
-
) : y[d] = [
|
|
1107
|
+
) : y[d] = [f];
|
|
1108
1108
|
}
|
|
1109
1109
|
let m = [];
|
|
1110
|
-
for (let
|
|
1111
|
-
(d,
|
|
1110
|
+
for (let f of Object.keys(y).sort(
|
|
1111
|
+
(d, g) => Number(d) - Number(g)
|
|
1112
1112
|
))
|
|
1113
|
-
m.push(...w(y[
|
|
1113
|
+
m.push(...w(y[f], s));
|
|
1114
1114
|
return L(
|
|
1115
1115
|
u,
|
|
1116
1116
|
r,
|
|
@@ -1124,8 +1124,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
1126
|
})
|
|
1127
|
-
}),
|
|
1128
|
-
name:
|
|
1127
|
+
}), te = "sort-jsx-props", we = v({
|
|
1128
|
+
name: te,
|
|
1129
1129
|
meta: {
|
|
1130
1130
|
type: "suggestion",
|
|
1131
1131
|
docs: {
|
|
@@ -1141,16 +1141,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
1141
1141
|
},
|
|
1142
1142
|
type: {
|
|
1143
1143
|
enum: [
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1144
|
+
i.alphabetical,
|
|
1145
|
+
i.natural,
|
|
1146
|
+
i["line-length"]
|
|
1147
1147
|
],
|
|
1148
|
-
default:
|
|
1148
|
+
default: i.alphabetical,
|
|
1149
1149
|
type: "string"
|
|
1150
1150
|
},
|
|
1151
1151
|
order: {
|
|
1152
|
-
enum: [
|
|
1153
|
-
default:
|
|
1152
|
+
enum: [c.asc, c.desc],
|
|
1153
|
+
default: c.asc,
|
|
1154
1154
|
type: "string"
|
|
1155
1155
|
},
|
|
1156
1156
|
groups: {
|
|
@@ -1170,30 +1170,30 @@ const Y = "sort-object-types", xe = O({
|
|
|
1170
1170
|
},
|
|
1171
1171
|
defaultOptions: [
|
|
1172
1172
|
{
|
|
1173
|
-
type:
|
|
1174
|
-
order:
|
|
1173
|
+
type: i.alphabetical,
|
|
1174
|
+
order: c.asc
|
|
1175
1175
|
}
|
|
1176
1176
|
],
|
|
1177
|
-
create: (t) => [".svelte", ".astro", ".vue"].includes(
|
|
1178
|
-
JSXElement: (
|
|
1179
|
-
if (
|
|
1180
|
-
let s =
|
|
1181
|
-
type:
|
|
1177
|
+
create: (t) => [".svelte", ".astro", ".vue"].includes(_.extname(t.filename)) ? {} : {
|
|
1178
|
+
JSXElement: (o) => {
|
|
1179
|
+
if (o.openingElement.attributes.length > 1) {
|
|
1180
|
+
let s = k(t.options.at(0), {
|
|
1181
|
+
type: i.alphabetical,
|
|
1182
1182
|
"ignore-case": !1,
|
|
1183
|
-
order:
|
|
1183
|
+
order: c.asc,
|
|
1184
1184
|
"custom-groups": {},
|
|
1185
1185
|
groups: []
|
|
1186
|
-
}), l =
|
|
1186
|
+
}), l = o.openingElement.attributes.reduce(
|
|
1187
1187
|
(r, e) => {
|
|
1188
1188
|
if (e.type === "JSXSpreadAttribute")
|
|
1189
1189
|
return r.push([]), r;
|
|
1190
|
-
let a = e.name.type === "JSXNamespacedName" ? `${e.name.namespace.name}:${e.name.name.name}` : e.name.name, { getGroup:
|
|
1190
|
+
let a = e.name.type === "JSXNamespacedName" ? `${e.name.namespace.name}:${e.name.name.name}` : e.name.name, { getGroup: p, defineGroup: n, setCustomGroups: u } = M(
|
|
1191
1191
|
s.groups
|
|
1192
1192
|
);
|
|
1193
|
-
u(s["custom-groups"], a), e.value === null &&
|
|
1193
|
+
u(s["custom-groups"], a), e.value === null && n("shorthand"), e.loc.start.line !== e.loc.end.line && n("multiline");
|
|
1194
1194
|
let y = {
|
|
1195
|
-
size:
|
|
1196
|
-
group:
|
|
1195
|
+
size: O(e.range),
|
|
1196
|
+
group: p(),
|
|
1197
1197
|
node: e,
|
|
1198
1198
|
name: a
|
|
1199
1199
|
};
|
|
@@ -1202,9 +1202,9 @@ const Y = "sort-object-types", xe = O({
|
|
|
1202
1202
|
[[]]
|
|
1203
1203
|
);
|
|
1204
1204
|
for (let r of l)
|
|
1205
|
-
|
|
1206
|
-
let
|
|
1207
|
-
(
|
|
1205
|
+
P(r, (e, a) => {
|
|
1206
|
+
let p = E(s.groups, e), n = E(s.groups, a);
|
|
1207
|
+
(p > n || p === n && j(A(e, a, s))) && t.report({
|
|
1208
1208
|
messageId: "unexpectedJSXPropsOrder",
|
|
1209
1209
|
data: {
|
|
1210
1210
|
left: e.name,
|
|
@@ -1213,18 +1213,18 @@ const Y = "sort-object-types", xe = O({
|
|
|
1213
1213
|
node: a.node,
|
|
1214
1214
|
fix: (u) => {
|
|
1215
1215
|
let y = {};
|
|
1216
|
-
for (let
|
|
1217
|
-
let d =
|
|
1216
|
+
for (let f of r) {
|
|
1217
|
+
let d = E(s.groups, f);
|
|
1218
1218
|
d in y ? y[d] = w(
|
|
1219
|
-
[...y[d],
|
|
1219
|
+
[...y[d], f],
|
|
1220
1220
|
s
|
|
1221
|
-
) : y[d] = [
|
|
1221
|
+
) : y[d] = [f];
|
|
1222
1222
|
}
|
|
1223
1223
|
let m = [];
|
|
1224
|
-
for (let
|
|
1225
|
-
(d,
|
|
1224
|
+
for (let f of Object.keys(y).sort(
|
|
1225
|
+
(d, g) => Number(d) - Number(g)
|
|
1226
1226
|
))
|
|
1227
|
-
m.push(...w(y[
|
|
1227
|
+
m.push(...w(y[f], s));
|
|
1228
1228
|
return L(
|
|
1229
1229
|
u,
|
|
1230
1230
|
r,
|
|
@@ -1237,8 +1237,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
1239
|
}
|
|
1240
|
-
}),
|
|
1241
|
-
name:
|
|
1240
|
+
}), re = "sort-exports", Se = v({
|
|
1241
|
+
name: re,
|
|
1242
1242
|
meta: {
|
|
1243
1243
|
type: "suggestion",
|
|
1244
1244
|
docs: {
|
|
@@ -1251,16 +1251,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
1251
1251
|
properties: {
|
|
1252
1252
|
type: {
|
|
1253
1253
|
enum: [
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1254
|
+
i.alphabetical,
|
|
1255
|
+
i.natural,
|
|
1256
|
+
i["line-length"]
|
|
1257
1257
|
],
|
|
1258
|
-
default:
|
|
1258
|
+
default: i.alphabetical,
|
|
1259
1259
|
type: "string"
|
|
1260
1260
|
},
|
|
1261
1261
|
order: {
|
|
1262
|
-
enum: [
|
|
1263
|
-
default:
|
|
1262
|
+
enum: [c.asc, c.desc],
|
|
1263
|
+
default: c.asc,
|
|
1264
1264
|
type: "string"
|
|
1265
1265
|
},
|
|
1266
1266
|
"ignore-case": {
|
|
@@ -1277,18 +1277,18 @@ const Y = "sort-object-types", xe = O({
|
|
|
1277
1277
|
},
|
|
1278
1278
|
defaultOptions: [
|
|
1279
1279
|
{
|
|
1280
|
-
type:
|
|
1281
|
-
order:
|
|
1280
|
+
type: i.alphabetical,
|
|
1281
|
+
order: c.asc
|
|
1282
1282
|
}
|
|
1283
1283
|
],
|
|
1284
1284
|
create: (t) => {
|
|
1285
|
-
let
|
|
1286
|
-
type:
|
|
1287
|
-
order:
|
|
1285
|
+
let o = k(t.options.at(0), {
|
|
1286
|
+
type: i.alphabetical,
|
|
1287
|
+
order: c.asc,
|
|
1288
1288
|
"ignore-case": !1
|
|
1289
1289
|
}), s = [[]], l = (r) => {
|
|
1290
1290
|
r.type === "ExportAllDeclaration" && r.exported === null ? s.push([]) : s.at(-1).push({
|
|
1291
|
-
size:
|
|
1291
|
+
size: O(r.range),
|
|
1292
1292
|
name: r.source.value,
|
|
1293
1293
|
node: r
|
|
1294
1294
|
});
|
|
@@ -1300,18 +1300,18 @@ const Y = "sort-object-types", xe = O({
|
|
|
1300
1300
|
},
|
|
1301
1301
|
"Program:exit": () => {
|
|
1302
1302
|
for (let r of s)
|
|
1303
|
-
|
|
1304
|
-
|
|
1303
|
+
P(r, (e, a) => {
|
|
1304
|
+
j(A(e, a, o)) && t.report({
|
|
1305
1305
|
messageId: "unexpectedExportsOrder",
|
|
1306
1306
|
data: {
|
|
1307
1307
|
left: e.name,
|
|
1308
1308
|
right: a.name
|
|
1309
1309
|
},
|
|
1310
1310
|
node: a.node,
|
|
1311
|
-
fix: (
|
|
1312
|
-
|
|
1311
|
+
fix: (p) => L(
|
|
1312
|
+
p,
|
|
1313
1313
|
r,
|
|
1314
|
-
w(r,
|
|
1314
|
+
w(r, o),
|
|
1315
1315
|
t.sourceCode
|
|
1316
1316
|
)
|
|
1317
1317
|
});
|
|
@@ -1319,8 +1319,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1319
1319
|
}
|
|
1320
1320
|
};
|
|
1321
1321
|
}
|
|
1322
|
-
}),
|
|
1323
|
-
name:
|
|
1322
|
+
}), se = "sort-imports", Ae = v({
|
|
1323
|
+
name: se,
|
|
1324
1324
|
meta: {
|
|
1325
1325
|
type: "suggestion",
|
|
1326
1326
|
docs: {
|
|
@@ -1346,16 +1346,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
1346
1346
|
},
|
|
1347
1347
|
type: {
|
|
1348
1348
|
enum: [
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1349
|
+
i.alphabetical,
|
|
1350
|
+
i.natural,
|
|
1351
|
+
i["line-length"]
|
|
1352
1352
|
],
|
|
1353
|
-
default:
|
|
1353
|
+
default: i.alphabetical,
|
|
1354
1354
|
type: "string"
|
|
1355
1355
|
},
|
|
1356
1356
|
order: {
|
|
1357
|
-
enum: [
|
|
1358
|
-
default:
|
|
1357
|
+
enum: [c.asc, c.desc],
|
|
1358
|
+
default: c.asc,
|
|
1359
1359
|
type: "string"
|
|
1360
1360
|
},
|
|
1361
1361
|
"ignore-case": {
|
|
@@ -1398,7 +1398,7 @@ const Y = "sort-object-types", xe = O({
|
|
|
1398
1398
|
definitions: {
|
|
1399
1399
|
"is-line-length": {
|
|
1400
1400
|
properties: {
|
|
1401
|
-
type: { enum: [
|
|
1401
|
+
type: { enum: [i["line-length"]], type: "string" }
|
|
1402
1402
|
},
|
|
1403
1403
|
required: ["type"],
|
|
1404
1404
|
type: "object"
|
|
@@ -1423,31 +1423,31 @@ const Y = "sort-object-types", xe = O({
|
|
|
1423
1423
|
},
|
|
1424
1424
|
defaultOptions: [
|
|
1425
1425
|
{
|
|
1426
|
-
type:
|
|
1427
|
-
order:
|
|
1426
|
+
type: i.alphabetical,
|
|
1427
|
+
order: c.asc
|
|
1428
1428
|
}
|
|
1429
1429
|
],
|
|
1430
1430
|
create: (t) => {
|
|
1431
|
-
let
|
|
1431
|
+
let o = k(t.options.at(0), {
|
|
1432
1432
|
"newlines-between": "always",
|
|
1433
1433
|
"custom-groups": { type: {}, value: {} },
|
|
1434
1434
|
"internal-pattern": ["~/**"],
|
|
1435
|
-
type:
|
|
1436
|
-
order:
|
|
1435
|
+
type: i.alphabetical,
|
|
1436
|
+
order: c.asc,
|
|
1437
1437
|
"ignore-case": !1,
|
|
1438
1438
|
groups: []
|
|
1439
1439
|
}), s = !1;
|
|
1440
|
-
for (let
|
|
1441
|
-
if (Array.isArray(
|
|
1442
|
-
for (let u of
|
|
1440
|
+
for (let n of o.groups)
|
|
1441
|
+
if (Array.isArray(n))
|
|
1442
|
+
for (let u of n)
|
|
1443
1443
|
u === "unknown" && (s = !0);
|
|
1444
1444
|
else
|
|
1445
|
-
|
|
1446
|
-
s || (
|
|
1447
|
-
let l = [], r = (
|
|
1448
|
-
let u = (
|
|
1449
|
-
(
|
|
1450
|
-
), y = (
|
|
1445
|
+
n === "unknown" && (s = !0);
|
|
1446
|
+
s || (o.groups = [...o.groups, "unknown"]);
|
|
1447
|
+
let l = [], r = (n) => n.type === "ImportDeclaration" && n.specifiers.length === 0, e = (n) => {
|
|
1448
|
+
let u = (x) => [".less", ".scss", ".sass", ".styl", ".pcss", ".css", ".sss"].some(
|
|
1449
|
+
(S) => x.endsWith(S)
|
|
1450
|
+
), y = (x) => [
|
|
1451
1451
|
"./index.d.js",
|
|
1452
1452
|
"./index.d.ts",
|
|
1453
1453
|
"./index.js",
|
|
@@ -1455,12 +1455,12 @@ const Y = "sort-object-types", xe = O({
|
|
|
1455
1455
|
"./index",
|
|
1456
1456
|
"./",
|
|
1457
1457
|
"."
|
|
1458
|
-
].includes(
|
|
1459
|
-
(
|
|
1458
|
+
].includes(x), m = (x) => x.indexOf("..") === 0, f = (x) => x.indexOf("./") === 0, { getGroup: d, defineGroup: g, setCustomGroups: b } = M(o.groups), N = (x) => o["internal-pattern"].length && o["internal-pattern"].some(
|
|
1459
|
+
(S) => $(x.source.value, S, {
|
|
1460
1460
|
nocomment: !0
|
|
1461
1461
|
})
|
|
1462
|
-
), h = (
|
|
1463
|
-
let
|
|
1462
|
+
), h = (x) => {
|
|
1463
|
+
let S = [
|
|
1464
1464
|
"bun",
|
|
1465
1465
|
"bun:ffi",
|
|
1466
1466
|
"bun:jsc",
|
|
@@ -1471,71 +1471,71 @@ const Y = "sort-object-types", xe = O({
|
|
|
1471
1471
|
"undici",
|
|
1472
1472
|
"ws"
|
|
1473
1473
|
];
|
|
1474
|
-
return
|
|
1475
|
-
|
|
1476
|
-
) ||
|
|
1477
|
-
}, C = (
|
|
1478
|
-
return
|
|
1479
|
-
}, a = (
|
|
1474
|
+
return ce.includes(
|
|
1475
|
+
x.startsWith("node:") ? x.split("node:")[1] : x
|
|
1476
|
+
) || S.includes(x);
|
|
1477
|
+
}, C = (x) => !(x.startsWith(".") || x.startsWith("/"));
|
|
1478
|
+
return n.importKind === "type" && (n.type === "ImportDeclaration" && (b(o["custom-groups"].type, n.source.value), y(n.source.value) && g("index-type"), f(n.source.value) && g("sibling-type"), m(n.source.value) && g("parent-type"), N(n) && g("internal-type"), h(n.source.value) && g("builtin-type"), C(n.source.value) && g("external-type")), g("type")), n.type === "ImportDeclaration" && (b(o["custom-groups"].value, n.source.value), r(n) && u(n.source.value) && g("side-effect-style"), r(n) && g("side-effect"), u(n.source.value) && g("style"), y(n.source.value) && g("index"), f(n.source.value) && g("sibling"), m(n.source.value) && g("parent"), N(n) && g("internal"), h(n.source.value) && g("builtin"), C(n.source.value) && g("external")), d();
|
|
1479
|
+
}, a = (n) => n.specifiers.length > 1, p = (n) => {
|
|
1480
1480
|
let u;
|
|
1481
|
-
|
|
1482
|
-
size:
|
|
1483
|
-
group: e(
|
|
1481
|
+
n.type === "ImportDeclaration" ? u = n.source.value : n.moduleReference.type === "TSExternalModuleReference" && n.moduleReference.expression.type === "Literal" ? u = `${n.moduleReference.expression.value}` : u = t.sourceCode.text.slice(...n.moduleReference.range), l.push({
|
|
1482
|
+
size: O(n.range),
|
|
1483
|
+
group: e(n),
|
|
1484
1484
|
name: u,
|
|
1485
|
-
node:
|
|
1486
|
-
...
|
|
1485
|
+
node: n,
|
|
1486
|
+
...o.type === i["line-length"] && o["max-line-length"] && {
|
|
1487
1487
|
hasMultipleImportDeclarations: a(
|
|
1488
|
-
|
|
1488
|
+
n
|
|
1489
1489
|
)
|
|
1490
1490
|
}
|
|
1491
1491
|
});
|
|
1492
1492
|
};
|
|
1493
1493
|
return {
|
|
1494
|
-
TSImportEqualsDeclaration:
|
|
1495
|
-
ImportDeclaration:
|
|
1494
|
+
TSImportEqualsDeclaration: p,
|
|
1495
|
+
ImportDeclaration: p,
|
|
1496
1496
|
"Program:exit": () => {
|
|
1497
1497
|
var m;
|
|
1498
|
-
let
|
|
1499
|
-
|
|
1500
|
-
|
|
1498
|
+
let n = (f, d) => !!t.sourceCode.getTokensBetween(
|
|
1499
|
+
f.node,
|
|
1500
|
+
J(d.node, t.sourceCode) || d.node,
|
|
1501
1501
|
{
|
|
1502
1502
|
includeComments: !0
|
|
1503
1503
|
}
|
|
1504
|
-
).length, u = (
|
|
1505
|
-
let
|
|
1504
|
+
).length, u = (f, d) => {
|
|
1505
|
+
let g = [], b = {};
|
|
1506
1506
|
for (let h of d) {
|
|
1507
|
-
let C =
|
|
1507
|
+
let C = E(o.groups, h);
|
|
1508
1508
|
C in b ? b[C] = w(
|
|
1509
1509
|
[...b[C], h],
|
|
1510
|
-
|
|
1510
|
+
o
|
|
1511
1511
|
) : b[C] = [h];
|
|
1512
1512
|
}
|
|
1513
|
-
let
|
|
1513
|
+
let N = Object.keys(b).sort((h, C) => Number(h) - Number(C)).reduce(
|
|
1514
1514
|
(h, C) => [
|
|
1515
1515
|
...h,
|
|
1516
1516
|
...b[C]
|
|
1517
1517
|
],
|
|
1518
1518
|
[]
|
|
1519
1519
|
);
|
|
1520
|
-
for (let h = 0, C =
|
|
1521
|
-
let
|
|
1522
|
-
if (
|
|
1523
|
-
|
|
1520
|
+
for (let h = 0, C = N.length; h < C; h++) {
|
|
1521
|
+
let x = N.at(h);
|
|
1522
|
+
if (g.push(
|
|
1523
|
+
f.replaceTextRange(
|
|
1524
1524
|
T(d.at(h).node, t.sourceCode),
|
|
1525
1525
|
t.sourceCode.text.slice(
|
|
1526
|
-
...T(
|
|
1526
|
+
...T(x.node, t.sourceCode)
|
|
1527
1527
|
)
|
|
1528
1528
|
)
|
|
1529
|
-
),
|
|
1530
|
-
let
|
|
1531
|
-
if (
|
|
1532
|
-
let
|
|
1529
|
+
), o["newlines-between"] !== "ignore") {
|
|
1530
|
+
let S = N.at(h + 1);
|
|
1531
|
+
if (S) {
|
|
1532
|
+
let G = z(
|
|
1533
1533
|
t.sourceCode,
|
|
1534
1534
|
d.at(h),
|
|
1535
1535
|
d.at(h + 1)
|
|
1536
1536
|
);
|
|
1537
|
-
(
|
|
1538
|
-
|
|
1537
|
+
(o["newlines-between"] === "always" && E(o.groups, x) === E(o.groups, S) && G !== 0 || o["newlines-between"] === "never" && G > 0) && g.push(
|
|
1538
|
+
f.removeRange([
|
|
1539
1539
|
T(
|
|
1540
1540
|
d.at(h).node,
|
|
1541
1541
|
t.sourceCode
|
|
@@ -1545,8 +1545,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1545
1545
|
t.sourceCode
|
|
1546
1546
|
).at(0) - 1
|
|
1547
1547
|
])
|
|
1548
|
-
),
|
|
1549
|
-
|
|
1548
|
+
), o["newlines-between"] === "always" && E(o.groups, x) !== E(o.groups, S) && G > 1 && g.push(
|
|
1549
|
+
f.replaceTextRange(
|
|
1550
1550
|
[
|
|
1551
1551
|
T(
|
|
1552
1552
|
d.at(h).node,
|
|
@@ -1560,8 +1560,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1560
1560
|
`
|
|
1561
1561
|
`
|
|
1562
1562
|
)
|
|
1563
|
-
),
|
|
1564
|
-
|
|
1563
|
+
), o["newlines-between"] === "always" && E(o.groups, x) !== E(o.groups, S) && G === 0 && g.push(
|
|
1564
|
+
f.insertTextAfterRange(
|
|
1565
1565
|
T(d.at(h).node, t.sourceCode),
|
|
1566
1566
|
`
|
|
1567
1567
|
`
|
|
@@ -1570,58 +1570,58 @@ const Y = "sort-object-types", xe = O({
|
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
|
-
return
|
|
1573
|
+
return g;
|
|
1574
1574
|
}, y = [[]];
|
|
1575
|
-
for (let
|
|
1575
|
+
for (let f of l) {
|
|
1576
1576
|
let d = (m = y.at(-1)) == null ? void 0 : m.at(-1);
|
|
1577
|
-
d &&
|
|
1577
|
+
d && n(d, f) ? y.push([f]) : y.at(-1).push(f);
|
|
1578
1578
|
}
|
|
1579
|
-
for (let
|
|
1580
|
-
|
|
1581
|
-
let b =
|
|
1579
|
+
for (let f of y)
|
|
1580
|
+
P(f, (d, g) => {
|
|
1581
|
+
let b = E(o.groups, d), N = E(o.groups, g), h = z(
|
|
1582
1582
|
t.sourceCode,
|
|
1583
1583
|
d,
|
|
1584
|
-
|
|
1584
|
+
g
|
|
1585
1585
|
);
|
|
1586
|
-
!(r(d.node) && r(
|
|
1586
|
+
!(r(d.node) && r(g.node)) && !n(d, g) && (b > N || b === N && j(A(d, g, o))) && t.report({
|
|
1587
1587
|
messageId: "unexpectedImportsOrder",
|
|
1588
1588
|
data: {
|
|
1589
1589
|
left: d.name,
|
|
1590
|
-
right:
|
|
1590
|
+
right: g.name
|
|
1591
1591
|
},
|
|
1592
|
-
node:
|
|
1593
|
-
fix: (C) => u(C,
|
|
1594
|
-
}),
|
|
1592
|
+
node: g.node,
|
|
1593
|
+
fix: (C) => u(C, f)
|
|
1594
|
+
}), o["newlines-between"] === "never" && h > 0 && t.report({
|
|
1595
1595
|
messageId: "extraSpacingBetweenImports",
|
|
1596
1596
|
data: {
|
|
1597
1597
|
left: d.name,
|
|
1598
|
-
right:
|
|
1598
|
+
right: g.name
|
|
1599
1599
|
},
|
|
1600
|
-
node:
|
|
1601
|
-
fix: (C) => u(C,
|
|
1602
|
-
}),
|
|
1600
|
+
node: g.node,
|
|
1601
|
+
fix: (C) => u(C, f)
|
|
1602
|
+
}), o["newlines-between"] === "always" && (b < N && h === 0 ? t.report({
|
|
1603
1603
|
messageId: "missedSpacingBetweenImports",
|
|
1604
1604
|
data: {
|
|
1605
1605
|
left: d.name,
|
|
1606
|
-
right:
|
|
1606
|
+
right: g.name
|
|
1607
1607
|
},
|
|
1608
|
-
node:
|
|
1609
|
-
fix: (C) => u(C,
|
|
1610
|
-
}) : (h > 1 || b ===
|
|
1608
|
+
node: g.node,
|
|
1609
|
+
fix: (C) => u(C, f)
|
|
1610
|
+
}) : (h > 1 || b === N && h > 0) && t.report({
|
|
1611
1611
|
messageId: "extraSpacingBetweenImports",
|
|
1612
1612
|
data: {
|
|
1613
1613
|
left: d.name,
|
|
1614
|
-
right:
|
|
1614
|
+
right: g.name
|
|
1615
1615
|
},
|
|
1616
|
-
node:
|
|
1617
|
-
fix: (C) => u(C,
|
|
1616
|
+
node: g.node,
|
|
1617
|
+
fix: (C) => u(C, f)
|
|
1618
1618
|
}));
|
|
1619
1619
|
});
|
|
1620
1620
|
}
|
|
1621
1621
|
};
|
|
1622
1622
|
}
|
|
1623
|
-
}),
|
|
1624
|
-
name:
|
|
1623
|
+
}), ae = "sort-objects", Ie = v({
|
|
1624
|
+
name: ae,
|
|
1625
1625
|
meta: {
|
|
1626
1626
|
type: "suggestion",
|
|
1627
1627
|
docs: {
|
|
@@ -1649,22 +1649,28 @@ const Y = "sort-object-types", xe = O({
|
|
|
1649
1649
|
},
|
|
1650
1650
|
type: {
|
|
1651
1651
|
enum: [
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1652
|
+
i.alphabetical,
|
|
1653
|
+
i.natural,
|
|
1654
|
+
i["line-length"]
|
|
1655
1655
|
],
|
|
1656
|
-
default:
|
|
1656
|
+
default: i.alphabetical,
|
|
1657
1657
|
type: "string"
|
|
1658
1658
|
},
|
|
1659
1659
|
order: {
|
|
1660
|
-
enum: [
|
|
1661
|
-
default:
|
|
1660
|
+
enum: [c.asc, c.desc],
|
|
1661
|
+
default: c.asc,
|
|
1662
1662
|
type: "string"
|
|
1663
1663
|
},
|
|
1664
1664
|
"ignore-case": {
|
|
1665
1665
|
type: "boolean",
|
|
1666
1666
|
default: !1
|
|
1667
1667
|
},
|
|
1668
|
+
"ignore-pattern": {
|
|
1669
|
+
items: {
|
|
1670
|
+
type: "string"
|
|
1671
|
+
},
|
|
1672
|
+
type: "array"
|
|
1673
|
+
},
|
|
1668
1674
|
groups: {
|
|
1669
1675
|
type: "array"
|
|
1670
1676
|
}
|
|
@@ -1678,45 +1684,51 @@ const Y = "sort-object-types", xe = O({
|
|
|
1678
1684
|
},
|
|
1679
1685
|
defaultOptions: [
|
|
1680
1686
|
{
|
|
1681
|
-
type:
|
|
1682
|
-
order:
|
|
1687
|
+
type: i.alphabetical,
|
|
1688
|
+
order: c.asc
|
|
1683
1689
|
}
|
|
1684
1690
|
],
|
|
1685
1691
|
create: (t) => {
|
|
1686
|
-
let
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1692
|
+
let o = (s) => {
|
|
1693
|
+
let l = k(t.options.at(0), {
|
|
1694
|
+
"partition-by-new-line": !1,
|
|
1695
|
+
"partition-by-comment": !1,
|
|
1696
|
+
type: i.alphabetical,
|
|
1697
|
+
"styled-components": !0,
|
|
1698
|
+
"ignore-case": !1,
|
|
1699
|
+
"ignore-pattern": [],
|
|
1700
|
+
order: c.asc,
|
|
1701
|
+
"custom-groups": {},
|
|
1702
|
+
groups: []
|
|
1703
|
+
}), r = s.parent.type === "VariableDeclarator" && s.parent.id.type === "Identifier" ? s.parent.id.name : null;
|
|
1704
|
+
if (!(l["ignore-pattern"].length && typeof r == "string" ? l["ignore-pattern"].some(
|
|
1705
|
+
(a) => $(r, a, {
|
|
1706
|
+
nocomment: !0
|
|
1707
|
+
})
|
|
1708
|
+
) : !1) && s.properties.length > 1) {
|
|
1709
|
+
let a = (u) => u.type === "Identifier" && u.name === "styled", p = (u) => u !== void 0 && u.type === "CallExpression" && (u.callee.type === "MemberExpression" && a(u.callee.object) || u.callee.type === "CallExpression" && a(u.callee.callee));
|
|
1710
|
+
if (!l["styled-components"] && (p(s.parent) || s.parent.type === "ArrowFunctionExpression" && p(s.parent.parent)))
|
|
1699
1711
|
return;
|
|
1700
|
-
let
|
|
1701
|
-
(
|
|
1702
|
-
var
|
|
1703
|
-
if (
|
|
1704
|
-
return
|
|
1705
|
-
let
|
|
1706
|
-
l["partition-by-comment"] &&
|
|
1712
|
+
let n = (u) => u.reduce(
|
|
1713
|
+
(y, m) => {
|
|
1714
|
+
var G;
|
|
1715
|
+
if (m.type === "SpreadElement" || m.type === "RestElement")
|
|
1716
|
+
return y.push([]), y;
|
|
1717
|
+
let f = J(m, t.sourceCode), d = (G = y.at(-1)) == null ? void 0 : G.at(-1);
|
|
1718
|
+
l["partition-by-comment"] && f && pe(
|
|
1707
1719
|
l["partition-by-comment"],
|
|
1708
|
-
|
|
1709
|
-
) &&
|
|
1710
|
-
let
|
|
1711
|
-
|
|
1712
|
-
let
|
|
1713
|
-
size:
|
|
1714
|
-
node:
|
|
1715
|
-
name:
|
|
1720
|
+
f.value
|
|
1721
|
+
) && y.push([]);
|
|
1722
|
+
let g, b = "ignore", N = [], { getGroup: h, setCustomGroups: C } = M(l.groups);
|
|
1723
|
+
m.key.type === "Identifier" ? { name: g } = m.key : m.key.type === "Literal" ? g = `${m.key.value}` : g = t.sourceCode.text.slice(...m.key.range);
|
|
1724
|
+
let x = {
|
|
1725
|
+
size: O(m.range),
|
|
1726
|
+
node: m,
|
|
1727
|
+
name: g
|
|
1716
1728
|
};
|
|
1717
|
-
l["partition-by-new-line"] &&
|
|
1718
|
-
|
|
1719
|
-
let
|
|
1729
|
+
l["partition-by-new-line"] && d && z(t.sourceCode, d, x) && y.push([]), m.value.type === "AssignmentPattern" && ((B) => {
|
|
1730
|
+
B.right.type === "Identifier" && N.push(B.right.name);
|
|
1731
|
+
let ie = (R) => {
|
|
1720
1732
|
let D = [];
|
|
1721
1733
|
switch (R.type) {
|
|
1722
1734
|
case "ArrowFunctionExpression":
|
|
@@ -1734,51 +1746,51 @@ const Y = "sort-object-types", xe = O({
|
|
|
1734
1746
|
break;
|
|
1735
1747
|
}
|
|
1736
1748
|
D.forEach((U) => {
|
|
1737
|
-
U.type === "Identifier" &&
|
|
1749
|
+
U.type === "Identifier" && N.push(U.name), (U.type === "BinaryExpression" || U.type === "ConditionalExpression") && ie(U);
|
|
1738
1750
|
});
|
|
1739
1751
|
};
|
|
1740
|
-
switch (
|
|
1752
|
+
switch (B.right.type) {
|
|
1741
1753
|
case "ArrowFunctionExpression":
|
|
1742
1754
|
case "ConditionalExpression":
|
|
1743
1755
|
case "LogicalExpression":
|
|
1744
1756
|
case "BinaryExpression":
|
|
1745
1757
|
case "CallExpression":
|
|
1746
|
-
|
|
1758
|
+
ie(B.right);
|
|
1747
1759
|
break;
|
|
1748
1760
|
}
|
|
1749
|
-
})(
|
|
1750
|
-
let
|
|
1751
|
-
...
|
|
1752
|
-
group:
|
|
1753
|
-
dependencies:
|
|
1754
|
-
position:
|
|
1761
|
+
})(m.value), C(l["custom-groups"], g);
|
|
1762
|
+
let S = {
|
|
1763
|
+
...x,
|
|
1764
|
+
group: h(),
|
|
1765
|
+
dependencies: N,
|
|
1766
|
+
position: b
|
|
1755
1767
|
};
|
|
1756
|
-
return
|
|
1768
|
+
return y.at(-1).push(S), y;
|
|
1757
1769
|
},
|
|
1758
1770
|
[[]]
|
|
1759
1771
|
);
|
|
1760
|
-
for (let
|
|
1761
|
-
|
|
1762
|
-
let
|
|
1763
|
-
if (
|
|
1764
|
-
let
|
|
1765
|
-
let
|
|
1766
|
-
for (let
|
|
1767
|
-
let
|
|
1768
|
-
|
|
1769
|
-
[...
|
|
1772
|
+
for (let u of n(s.properties))
|
|
1773
|
+
P(u, (y, m) => {
|
|
1774
|
+
let f = E(l.groups, y), d = E(l.groups, m);
|
|
1775
|
+
if (f > d || f === d && j(A(y, m, l))) {
|
|
1776
|
+
let g = (b) => {
|
|
1777
|
+
let N = {};
|
|
1778
|
+
for (let C of u) {
|
|
1779
|
+
let x = E(l.groups, C);
|
|
1780
|
+
x in N ? N[x] = w(
|
|
1781
|
+
[...N[x], C],
|
|
1770
1782
|
l
|
|
1771
|
-
) :
|
|
1783
|
+
) : N[x] = [C];
|
|
1772
1784
|
}
|
|
1773
|
-
let
|
|
1774
|
-
for (let
|
|
1775
|
-
(
|
|
1785
|
+
let h = [];
|
|
1786
|
+
for (let C of Object.keys(N).sort(
|
|
1787
|
+
(x, S) => Number(x) - Number(S)
|
|
1776
1788
|
))
|
|
1777
|
-
|
|
1789
|
+
h.push(...w(N[C], l));
|
|
1778
1790
|
return L(
|
|
1779
|
-
d,
|
|
1780
|
-
i,
|
|
1781
1791
|
b,
|
|
1792
|
+
u,
|
|
1793
|
+
h,
|
|
1782
1794
|
t.sourceCode,
|
|
1783
1795
|
{
|
|
1784
1796
|
partitionComment: l["partition-by-comment"]
|
|
@@ -1788,23 +1800,23 @@ const Y = "sort-object-types", xe = O({
|
|
|
1788
1800
|
t.report({
|
|
1789
1801
|
messageId: "unexpectedObjectsOrder",
|
|
1790
1802
|
data: {
|
|
1791
|
-
left:
|
|
1792
|
-
right:
|
|
1803
|
+
left: I(y.name),
|
|
1804
|
+
right: I(m.name)
|
|
1793
1805
|
},
|
|
1794
|
-
node:
|
|
1795
|
-
fix:
|
|
1806
|
+
node: m.node,
|
|
1807
|
+
fix: g
|
|
1796
1808
|
});
|
|
1797
1809
|
}
|
|
1798
1810
|
});
|
|
1799
1811
|
}
|
|
1800
1812
|
};
|
|
1801
1813
|
return {
|
|
1802
|
-
ObjectExpression:
|
|
1803
|
-
ObjectPattern:
|
|
1814
|
+
ObjectExpression: o,
|
|
1815
|
+
ObjectPattern: o
|
|
1804
1816
|
};
|
|
1805
1817
|
}
|
|
1806
|
-
}),
|
|
1807
|
-
name:
|
|
1818
|
+
}), oe = "sort-classes", ve = v({
|
|
1819
|
+
name: oe,
|
|
1808
1820
|
meta: {
|
|
1809
1821
|
type: "suggestion",
|
|
1810
1822
|
docs: {
|
|
@@ -1817,11 +1829,11 @@ const Y = "sort-object-types", xe = O({
|
|
|
1817
1829
|
properties: {
|
|
1818
1830
|
type: {
|
|
1819
1831
|
enum: [
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1832
|
+
i.alphabetical,
|
|
1833
|
+
i.natural,
|
|
1834
|
+
i["line-length"]
|
|
1823
1835
|
],
|
|
1824
|
-
default:
|
|
1836
|
+
default: i.alphabetical,
|
|
1825
1837
|
type: "string"
|
|
1826
1838
|
},
|
|
1827
1839
|
"ignore-case": {
|
|
@@ -1829,8 +1841,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1829
1841
|
default: !1
|
|
1830
1842
|
},
|
|
1831
1843
|
order: {
|
|
1832
|
-
enum: [
|
|
1833
|
-
default:
|
|
1844
|
+
enum: [c.asc, c.desc],
|
|
1845
|
+
default: c.asc,
|
|
1834
1846
|
type: "string"
|
|
1835
1847
|
},
|
|
1836
1848
|
groups: {
|
|
@@ -1847,72 +1859,72 @@ const Y = "sort-object-types", xe = O({
|
|
|
1847
1859
|
},
|
|
1848
1860
|
defaultOptions: [
|
|
1849
1861
|
{
|
|
1850
|
-
type:
|
|
1851
|
-
order:
|
|
1862
|
+
type: i.alphabetical,
|
|
1863
|
+
order: c.asc
|
|
1852
1864
|
}
|
|
1853
1865
|
],
|
|
1854
1866
|
create: (t) => ({
|
|
1855
|
-
ClassBody: (
|
|
1856
|
-
if (
|
|
1857
|
-
let s =
|
|
1858
|
-
type:
|
|
1859
|
-
order:
|
|
1867
|
+
ClassBody: (o) => {
|
|
1868
|
+
if (o.body.length > 1) {
|
|
1869
|
+
let s = k(t.options.at(0), {
|
|
1870
|
+
type: i.alphabetical,
|
|
1871
|
+
order: c.asc,
|
|
1860
1872
|
"ignore-case": !1,
|
|
1861
1873
|
groups: ["property", "constructor", "method", "unknown"]
|
|
1862
|
-
}), l =
|
|
1874
|
+
}), l = o.body.map((r) => {
|
|
1863
1875
|
var u;
|
|
1864
|
-
let e, { getGroup: a, defineGroup:
|
|
1876
|
+
let e, { getGroup: a, defineGroup: p } = M(s.groups);
|
|
1865
1877
|
r.type === "StaticBlock" ? e = "static" : r.type === "TSIndexSignature" ? e = t.sourceCode.text.slice(
|
|
1866
1878
|
r.range.at(0),
|
|
1867
1879
|
((u = r.typeAnnotation) == null ? void 0 : u.range.at(0)) ?? r.range.at(1)
|
|
1868
1880
|
) : r.key.type === "Identifier" ? { name: e } = r.key : e = t.sourceCode.text.slice(...r.key.range);
|
|
1869
|
-
let
|
|
1881
|
+
let n = e.startsWith("_") || e.startsWith("#");
|
|
1870
1882
|
if (r.type === "MethodDefinition") {
|
|
1871
|
-
r.kind === "constructor" &&
|
|
1872
|
-
let y = r.accessibility === "private" ||
|
|
1873
|
-
y && m &&
|
|
1883
|
+
r.kind === "constructor" && p("constructor");
|
|
1884
|
+
let y = r.accessibility === "private" || n, m = r.static;
|
|
1885
|
+
y && m && p("static-private-method"), y && p("private-method"), m && p("static-method"), r.kind === "get" && p("get-method"), r.kind === "set" && p("set-method"), p("method");
|
|
1874
1886
|
} else
|
|
1875
|
-
r.type === "TSIndexSignature" ?
|
|
1887
|
+
r.type === "TSIndexSignature" ? p("index-signature") : r.type === "PropertyDefinition" && ((r.accessibility === "private" || n) && p("private-property"), r.static && p("static-property"), p("property"));
|
|
1876
1888
|
return {
|
|
1877
|
-
size:
|
|
1889
|
+
size: O(r.range),
|
|
1878
1890
|
group: a(),
|
|
1879
1891
|
node: r,
|
|
1880
1892
|
name: e
|
|
1881
1893
|
};
|
|
1882
1894
|
});
|
|
1883
|
-
|
|
1884
|
-
let a =
|
|
1885
|
-
r.name !== e.name && (a >
|
|
1895
|
+
P(l, (r, e) => {
|
|
1896
|
+
let a = E(s.groups, r), p = E(s.groups, e);
|
|
1897
|
+
r.name !== e.name && (a > p || a === p && j(A(r, e, s))) && t.report({
|
|
1886
1898
|
messageId: "unexpectedClassesOrder",
|
|
1887
1899
|
data: {
|
|
1888
|
-
left:
|
|
1889
|
-
right:
|
|
1900
|
+
left: I(r.name),
|
|
1901
|
+
right: I(e.name)
|
|
1890
1902
|
},
|
|
1891
1903
|
node: e.node,
|
|
1892
|
-
fix: (
|
|
1904
|
+
fix: (n) => {
|
|
1893
1905
|
let u = [], y = l.reduce(
|
|
1894
|
-
(
|
|
1895
|
-
let
|
|
1896
|
-
return
|
|
1897
|
-
[...
|
|
1906
|
+
(f, d) => {
|
|
1907
|
+
let g = E(s.groups, d);
|
|
1908
|
+
return g in f ? f[g] = w(
|
|
1909
|
+
[...f[g], d],
|
|
1898
1910
|
s
|
|
1899
|
-
) :
|
|
1911
|
+
) : f[g] = [d], f;
|
|
1900
1912
|
},
|
|
1901
1913
|
{}
|
|
1902
|
-
), m = Object.keys(y).sort((
|
|
1903
|
-
(
|
|
1904
|
-
...
|
|
1914
|
+
), m = Object.keys(y).sort((f, d) => Number(f) - Number(d)).reduce(
|
|
1915
|
+
(f, d) => [
|
|
1916
|
+
...f,
|
|
1905
1917
|
...y[d]
|
|
1906
1918
|
],
|
|
1907
1919
|
[]
|
|
1908
1920
|
);
|
|
1909
|
-
for (let
|
|
1921
|
+
for (let f = 0, d = m.length; f < d; f++)
|
|
1910
1922
|
u.push(
|
|
1911
|
-
|
|
1912
|
-
T(l.at(
|
|
1923
|
+
n.replaceTextRange(
|
|
1924
|
+
T(l.at(f).node, t.sourceCode),
|
|
1913
1925
|
t.sourceCode.text.slice(
|
|
1914
1926
|
...T(
|
|
1915
|
-
m.at(
|
|
1927
|
+
m.at(f).node,
|
|
1916
1928
|
t.sourceCode
|
|
1917
1929
|
)
|
|
1918
1930
|
)
|
|
@@ -1925,8 +1937,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1925
1937
|
}
|
|
1926
1938
|
}
|
|
1927
1939
|
})
|
|
1928
|
-
}),
|
|
1929
|
-
name:
|
|
1940
|
+
}), ne = "sort-enums", Oe = v({
|
|
1941
|
+
name: ne,
|
|
1930
1942
|
meta: {
|
|
1931
1943
|
type: "suggestion",
|
|
1932
1944
|
docs: {
|
|
@@ -1939,11 +1951,11 @@ const Y = "sort-object-types", xe = O({
|
|
|
1939
1951
|
properties: {
|
|
1940
1952
|
type: {
|
|
1941
1953
|
enum: [
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1954
|
+
i.alphabetical,
|
|
1955
|
+
i.natural,
|
|
1956
|
+
i["line-length"]
|
|
1945
1957
|
],
|
|
1946
|
-
default:
|
|
1958
|
+
default: i.alphabetical,
|
|
1947
1959
|
type: "string"
|
|
1948
1960
|
},
|
|
1949
1961
|
"ignore-case": {
|
|
@@ -1951,8 +1963,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
1951
1963
|
default: !1
|
|
1952
1964
|
},
|
|
1953
1965
|
order: {
|
|
1954
|
-
enum: [
|
|
1955
|
-
default:
|
|
1966
|
+
enum: [c.asc, c.desc],
|
|
1967
|
+
default: c.asc,
|
|
1956
1968
|
type: "string"
|
|
1957
1969
|
}
|
|
1958
1970
|
},
|
|
@@ -1965,28 +1977,28 @@ const Y = "sort-object-types", xe = O({
|
|
|
1965
1977
|
},
|
|
1966
1978
|
defaultOptions: [
|
|
1967
1979
|
{
|
|
1968
|
-
type:
|
|
1969
|
-
order:
|
|
1980
|
+
type: i.alphabetical,
|
|
1981
|
+
order: c.asc
|
|
1970
1982
|
}
|
|
1971
1983
|
],
|
|
1972
1984
|
create: (t) => ({
|
|
1973
|
-
TSEnumDeclaration: (
|
|
1974
|
-
if (
|
|
1975
|
-
let s =
|
|
1976
|
-
type:
|
|
1977
|
-
order:
|
|
1985
|
+
TSEnumDeclaration: (o) => {
|
|
1986
|
+
if (o.members.length > 1 && o.members.every(({ initializer: s }) => s)) {
|
|
1987
|
+
let s = k(t.options.at(0), {
|
|
1988
|
+
type: i.alphabetical,
|
|
1989
|
+
order: c.asc,
|
|
1978
1990
|
"ignore-case": !1
|
|
1979
|
-
}), l =
|
|
1991
|
+
}), l = o.members.map((r) => ({
|
|
1980
1992
|
name: r.id.type === "Literal" ? `${r.id.value}` : `${t.sourceCode.text.slice(...r.id.range)}`,
|
|
1981
|
-
size:
|
|
1993
|
+
size: O(r.range),
|
|
1982
1994
|
node: r
|
|
1983
1995
|
}));
|
|
1984
|
-
|
|
1985
|
-
|
|
1996
|
+
P(l, (r, e) => {
|
|
1997
|
+
j(A(r, e, s)) && t.report({
|
|
1986
1998
|
messageId: "unexpectedEnumsOrder",
|
|
1987
1999
|
data: {
|
|
1988
|
-
left:
|
|
1989
|
-
right:
|
|
2000
|
+
left: I(r.name),
|
|
2001
|
+
right: I(e.name)
|
|
1990
2002
|
},
|
|
1991
2003
|
node: e.node,
|
|
1992
2004
|
fix: (a) => L(
|
|
@@ -2000,8 +2012,8 @@ const Y = "sort-object-types", xe = O({
|
|
|
2000
2012
|
}
|
|
2001
2013
|
}
|
|
2002
2014
|
})
|
|
2003
|
-
}),
|
|
2004
|
-
name:
|
|
2015
|
+
}), le = "sort-maps", je = v({
|
|
2016
|
+
name: le,
|
|
2005
2017
|
meta: {
|
|
2006
2018
|
type: "suggestion",
|
|
2007
2019
|
docs: {
|
|
@@ -2014,16 +2026,16 @@ const Y = "sort-object-types", xe = O({
|
|
|
2014
2026
|
properties: {
|
|
2015
2027
|
type: {
|
|
2016
2028
|
enum: [
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2029
|
+
i.alphabetical,
|
|
2030
|
+
i.natural,
|
|
2031
|
+
i["line-length"]
|
|
2020
2032
|
],
|
|
2021
|
-
default:
|
|
2033
|
+
default: i.alphabetical,
|
|
2022
2034
|
type: "string"
|
|
2023
2035
|
},
|
|
2024
2036
|
order: {
|
|
2025
|
-
enum: [
|
|
2026
|
-
default:
|
|
2037
|
+
enum: [c.asc, c.desc],
|
|
2038
|
+
default: c.asc,
|
|
2027
2039
|
type: "string"
|
|
2028
2040
|
},
|
|
2029
2041
|
"ignore-case": {
|
|
@@ -2040,45 +2052,45 @@ const Y = "sort-object-types", xe = O({
|
|
|
2040
2052
|
},
|
|
2041
2053
|
defaultOptions: [
|
|
2042
2054
|
{
|
|
2043
|
-
type:
|
|
2044
|
-
order:
|
|
2055
|
+
type: i.alphabetical,
|
|
2056
|
+
order: c.asc
|
|
2045
2057
|
}
|
|
2046
2058
|
],
|
|
2047
2059
|
create: (t) => ({
|
|
2048
|
-
NewExpression: (
|
|
2049
|
-
if (
|
|
2050
|
-
let [{ elements: s }] =
|
|
2060
|
+
NewExpression: (o) => {
|
|
2061
|
+
if (o.callee.type === "Identifier" && o.callee.name === "Map" && o.arguments.length && o.arguments[0].type === "ArrayExpression") {
|
|
2062
|
+
let [{ elements: s }] = o.arguments;
|
|
2051
2063
|
if (s.length > 1) {
|
|
2052
|
-
let l =
|
|
2053
|
-
type:
|
|
2064
|
+
let l = k(t.options.at(0), {
|
|
2065
|
+
type: i.alphabetical,
|
|
2054
2066
|
"ignore-case": !1,
|
|
2055
|
-
order:
|
|
2067
|
+
order: c.asc
|
|
2056
2068
|
}), r = s.reduce(
|
|
2057
2069
|
(e, a) => (a === null || a.type === "SpreadElement" ? e.push([]) : e.at(-1).push(a), e),
|
|
2058
2070
|
[[]]
|
|
2059
2071
|
);
|
|
2060
2072
|
for (let e of r) {
|
|
2061
|
-
let a = e.map((
|
|
2062
|
-
let
|
|
2063
|
-
if (
|
|
2064
|
-
let [u] =
|
|
2065
|
-
u ? u.type === "Literal" ?
|
|
2073
|
+
let a = e.map((p) => {
|
|
2074
|
+
let n;
|
|
2075
|
+
if (p.type === "ArrayExpression") {
|
|
2076
|
+
let [u] = p.elements;
|
|
2077
|
+
u ? u.type === "Literal" ? n = u.raw : n = t.sourceCode.text.slice(...u.range) : n = `${u}`;
|
|
2066
2078
|
} else
|
|
2067
|
-
|
|
2079
|
+
n = t.sourceCode.text.slice(...p.range);
|
|
2068
2080
|
return {
|
|
2069
|
-
size:
|
|
2070
|
-
node:
|
|
2071
|
-
name:
|
|
2081
|
+
size: O(p.range),
|
|
2082
|
+
node: p,
|
|
2083
|
+
name: n
|
|
2072
2084
|
};
|
|
2073
2085
|
});
|
|
2074
|
-
|
|
2075
|
-
|
|
2086
|
+
P(a, (p, n) => {
|
|
2087
|
+
j(A(p, n, l)) && t.report({
|
|
2076
2088
|
messageId: "unexpectedMapElementsOrder",
|
|
2077
2089
|
data: {
|
|
2078
|
-
left:
|
|
2079
|
-
right:
|
|
2090
|
+
left: I(p.name),
|
|
2091
|
+
right: I(n.name)
|
|
2080
2092
|
},
|
|
2081
|
-
node:
|
|
2093
|
+
node: n.node,
|
|
2082
2094
|
fix: (u) => L(
|
|
2083
2095
|
u,
|
|
2084
2096
|
a,
|
|
@@ -2092,10 +2104,10 @@ const Y = "sort-object-types", xe = O({
|
|
|
2092
2104
|
}
|
|
2093
2105
|
}
|
|
2094
2106
|
})
|
|
2095
|
-
}),
|
|
2096
|
-
let
|
|
2097
|
-
let
|
|
2098
|
-
[
|
|
2107
|
+
}), ke = "eslint-plugin-perfectionist";
|
|
2108
|
+
let V = (t) => {
|
|
2109
|
+
let o = {
|
|
2110
|
+
[se]: [
|
|
2099
2111
|
"error",
|
|
2100
2112
|
{
|
|
2101
2113
|
groups: [
|
|
@@ -2116,7 +2128,7 @@ let W = (t) => {
|
|
|
2116
2128
|
"internal-pattern": ["~/**"]
|
|
2117
2129
|
}
|
|
2118
2130
|
],
|
|
2119
|
-
[
|
|
2131
|
+
[oe]: [
|
|
2120
2132
|
"error",
|
|
2121
2133
|
{
|
|
2122
2134
|
groups: [
|
|
@@ -2133,21 +2145,20 @@ let W = (t) => {
|
|
|
2133
2145
|
]
|
|
2134
2146
|
}
|
|
2135
2147
|
],
|
|
2136
|
-
[
|
|
2148
|
+
[ae]: [
|
|
2137
2149
|
"error",
|
|
2138
2150
|
{
|
|
2139
2151
|
"partition-by-comment": !1
|
|
2140
2152
|
}
|
|
2141
2153
|
],
|
|
2142
|
-
[
|
|
2154
|
+
[K]: [
|
|
2143
2155
|
"error",
|
|
2144
2156
|
{
|
|
2145
2157
|
"spread-last": !0
|
|
2146
2158
|
}
|
|
2147
2159
|
],
|
|
2148
|
-
[J]: ["error"],
|
|
2149
2160
|
[X]: ["error"],
|
|
2150
|
-
[
|
|
2161
|
+
[q]: ["error"],
|
|
2151
2162
|
[H]: ["error"],
|
|
2152
2163
|
[Q]: ["error"],
|
|
2153
2164
|
[Y]: ["error"],
|
|
@@ -2155,12 +2166,13 @@ let W = (t) => {
|
|
|
2155
2166
|
[F]: ["error"],
|
|
2156
2167
|
[ee]: ["error"],
|
|
2157
2168
|
[te]: ["error"],
|
|
2158
|
-
[
|
|
2159
|
-
[ne]: ["error"]
|
|
2169
|
+
[re]: ["error"],
|
|
2170
|
+
[ne]: ["error"],
|
|
2171
|
+
[le]: ["error"]
|
|
2160
2172
|
};
|
|
2161
2173
|
return {
|
|
2162
2174
|
rules: Object.fromEntries(
|
|
2163
|
-
Object.entries(
|
|
2175
|
+
Object.entries(o).map(([s, [l, r = {}]]) => [
|
|
2164
2176
|
`perfectionist/${s}`,
|
|
2165
2177
|
[l, Object.assign(r, t)]
|
|
2166
2178
|
])
|
|
@@ -2168,43 +2180,43 @@ let W = (t) => {
|
|
|
2168
2180
|
plugins: ["perfectionist"]
|
|
2169
2181
|
};
|
|
2170
2182
|
};
|
|
2171
|
-
const
|
|
2183
|
+
const $e = {
|
|
2172
2184
|
rules: {
|
|
2185
|
+
[K]: me,
|
|
2173
2186
|
[q]: ye,
|
|
2174
|
-
[X]: ge,
|
|
2175
|
-
[ae]: Oe,
|
|
2176
2187
|
[oe]: ve,
|
|
2177
|
-
[
|
|
2188
|
+
[ne]: Oe,
|
|
2178
2189
|
[re]: Se,
|
|
2179
|
-
[
|
|
2190
|
+
[se]: Ae,
|
|
2180
2191
|
[ee]: Ne,
|
|
2181
|
-
[
|
|
2182
|
-
[
|
|
2192
|
+
[te]: we,
|
|
2193
|
+
[le]: je,
|
|
2183
2194
|
[Q]: be,
|
|
2184
2195
|
[Y]: xe,
|
|
2185
|
-
[se]: Ae,
|
|
2186
|
-
[J]: fe,
|
|
2187
2196
|
[Z]: Ee,
|
|
2188
|
-
[
|
|
2197
|
+
[ae]: Ie,
|
|
2198
|
+
[X]: ge,
|
|
2199
|
+
[F]: Ce,
|
|
2200
|
+
[H]: he
|
|
2189
2201
|
},
|
|
2190
2202
|
configs: {
|
|
2191
|
-
"recommended-alphabetical":
|
|
2192
|
-
type:
|
|
2193
|
-
order:
|
|
2203
|
+
"recommended-alphabetical": V({
|
|
2204
|
+
type: i.alphabetical,
|
|
2205
|
+
order: c.asc,
|
|
2194
2206
|
"ignore-case": !1
|
|
2195
2207
|
}),
|
|
2196
|
-
"recommended-natural":
|
|
2197
|
-
type:
|
|
2198
|
-
order:
|
|
2208
|
+
"recommended-natural": V({
|
|
2209
|
+
type: i.natural,
|
|
2210
|
+
order: c.asc,
|
|
2199
2211
|
"ignore-case": !1
|
|
2200
2212
|
}),
|
|
2201
|
-
"recommended-line-length":
|
|
2202
|
-
type:
|
|
2203
|
-
order:
|
|
2213
|
+
"recommended-line-length": V({
|
|
2214
|
+
type: i["line-length"],
|
|
2215
|
+
order: c.desc
|
|
2204
2216
|
})
|
|
2205
2217
|
},
|
|
2206
|
-
name:
|
|
2218
|
+
name: ke
|
|
2207
2219
|
};
|
|
2208
2220
|
export {
|
|
2209
|
-
|
|
2221
|
+
$e as default
|
|
2210
2222
|
};
|