eslint-plugin-perfectionist 2.2.0 → 2.3.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 +916 -842
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,132 +1,139 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ESLintUtils as
|
|
3
|
-
import { minimatch as
|
|
4
|
-
import
|
|
5
|
-
import { builtinModules as
|
|
6
|
-
let
|
|
7
|
-
(
|
|
8
|
-
), x = (
|
|
9
|
-
for (let
|
|
10
|
-
let u = s
|
|
1
|
+
import _ from "node:path";
|
|
2
|
+
import { ESLintUtils as ue, ASTUtils as W } from "@typescript-eslint/utils";
|
|
3
|
+
import { minimatch as D } from "minimatch";
|
|
4
|
+
import ce from "natural-compare-lite";
|
|
5
|
+
import { builtinModules as de } from "node:module";
|
|
6
|
+
let j = ue.RuleCreator(
|
|
7
|
+
(r) => `https://eslint-plugin-perfectionist.azat.io/rules/${r}`
|
|
8
|
+
), x = (r, l) => {
|
|
9
|
+
for (let s = 0, t = r.length; s < t; s++) {
|
|
10
|
+
let u = r[s];
|
|
11
11
|
if (l.group === u || Array.isArray(u) && typeof l.group == "string" && u.includes(l.group))
|
|
12
|
-
return
|
|
12
|
+
return s;
|
|
13
13
|
}
|
|
14
|
-
return
|
|
15
|
-
}, v = (
|
|
16
|
-
let [l,
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
var
|
|
20
|
-
let
|
|
21
|
-
let l,
|
|
22
|
-
!l &&
|
|
14
|
+
return r.length;
|
|
15
|
+
}, v = (r) => {
|
|
16
|
+
let [l, s] = r;
|
|
17
|
+
return s - l;
|
|
18
|
+
}, k = (r) => r > 0;
|
|
19
|
+
var p = /* @__PURE__ */ ((r) => (r.alphabetical = "alphabetical", r["line-length"] = "line-length", r.natural = "natural", r))(p || {}), d = /* @__PURE__ */ ((r) => (r.desc = "desc", r.asc = "asc", r))(d || {});
|
|
20
|
+
let R = (r) => {
|
|
21
|
+
let l, s = (u) => {
|
|
22
|
+
!l && r.flat().includes(u) && (l = u);
|
|
23
23
|
};
|
|
24
24
|
return {
|
|
25
25
|
getGroup: () => l ?? "unknown",
|
|
26
|
-
setCustomGroups: (u,
|
|
26
|
+
setCustomGroups: (u, n) => {
|
|
27
27
|
if (u)
|
|
28
|
-
for (let [e,
|
|
29
|
-
Array.isArray(
|
|
30
|
-
(
|
|
28
|
+
for (let [e, a] of Object.entries(u))
|
|
29
|
+
Array.isArray(a) && a.some(
|
|
30
|
+
(i) => D(n, i, {
|
|
31
31
|
nocomment: !0
|
|
32
32
|
})
|
|
33
|
-
) &&
|
|
33
|
+
) && s(e), typeof a == "string" && D(n, a, {
|
|
34
34
|
nocomment: !0
|
|
35
|
-
}) &&
|
|
35
|
+
}) && s(e);
|
|
36
36
|
},
|
|
37
|
-
defineGroup:
|
|
37
|
+
defineGroup: s
|
|
38
38
|
};
|
|
39
|
-
},
|
|
40
|
-
var e,
|
|
41
|
-
if ((e = l.dependencies) != null && e.includes(
|
|
39
|
+
}, O = (r, l, s) => {
|
|
40
|
+
var e, a;
|
|
41
|
+
if ((e = l.dependencies) != null && e.includes(r.name))
|
|
42
42
|
return -1;
|
|
43
|
-
if ((
|
|
43
|
+
if ((a = r.dependencies) != null && a.includes(l.name))
|
|
44
44
|
return 1;
|
|
45
|
-
let
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
let t = s.order === "asc" ? 1 : -1, u, n = (i) => s["ignore-case"] ? i.toLowerCase() : i;
|
|
46
|
+
return s.type === p.alphabetical ? u = (i, o) => n(i.name).localeCompare(n(o.name)) : s.type === p.natural ? u = (i, o) => ce(n(i.name), n(o.name)) : u = (i, o) => {
|
|
47
|
+
let c = i.size, y = o.size, h = s["max-line-length"];
|
|
48
|
+
if (h) {
|
|
49
|
+
let f = (g, m) => g > h && m.hasMultipleImportDeclarations;
|
|
50
|
+
f(c, i) && (c = i.name.length + 10), f(y, o) && (y = o.name.length + 10);
|
|
51
|
+
}
|
|
52
|
+
return c - y;
|
|
53
|
+
}, t * u(r, l);
|
|
54
|
+
}, A = (r, l) => [...r].sort((s, t) => O(s, t, l)), fe = (r, l) => {
|
|
55
|
+
let s = l.getTokenAfter(r, {
|
|
56
|
+
filter: ({ value: t, type: u }) => !(u === "Punctuator" && [",", ";"].includes(t)),
|
|
50
57
|
includeComments: !0
|
|
51
58
|
});
|
|
52
|
-
return ((
|
|
53
|
-
},
|
|
54
|
-
(
|
|
59
|
+
return ((s == null ? void 0 : s.type) === "Block" || (s == null ? void 0 : s.type) === "Line") && r.loc.end.line === s.loc.end.line ? s : null;
|
|
60
|
+
}, pe = (r, l) => Array.isArray(r) && r.some(
|
|
61
|
+
(s) => D(l.trim(), s, {
|
|
55
62
|
nocomment: !0
|
|
56
63
|
})
|
|
57
|
-
) || typeof
|
|
64
|
+
) || typeof r == "string" && D(l.trim(), r, {
|
|
58
65
|
nocomment: !0
|
|
59
|
-
}) ||
|
|
60
|
-
let [
|
|
61
|
-
filter: ({ value: u, type:
|
|
66
|
+
}) || r === !0, J = (r, l) => {
|
|
67
|
+
let [s, t] = l.getTokensBefore(r, {
|
|
68
|
+
filter: ({ value: u, type: n }) => !(n === "Punctuator" && [",", ";"].includes(u)),
|
|
62
69
|
includeComments: !0,
|
|
63
70
|
count: 2
|
|
64
71
|
});
|
|
65
|
-
return ((
|
|
66
|
-
},
|
|
67
|
-
var
|
|
68
|
-
let
|
|
69
|
-
if (
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
),
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
return ((t == null ? void 0 : t.type) === "Block" || (t == null ? void 0 : t.type) === "Line") && r.loc.start.line - t.loc.end.line <= 1 && (s == null ? void 0 : s.loc.end.line) !== t.loc.start.line ? t : null;
|
|
73
|
+
}, M = (r, l, s) => {
|
|
74
|
+
var a;
|
|
75
|
+
let t = r.range.at(0), u = r.range.at(1), n = l.text.slice(t, u);
|
|
76
|
+
if (W.isParenthesized(r, l)) {
|
|
77
|
+
let i = l.getTokenBefore(
|
|
78
|
+
r,
|
|
79
|
+
W.isOpeningParenToken
|
|
80
|
+
), o = l.getTokenAfter(
|
|
81
|
+
r,
|
|
82
|
+
W.isClosingParenToken
|
|
76
83
|
);
|
|
77
|
-
|
|
84
|
+
t = i.range.at(0), u = o.range.at(1);
|
|
78
85
|
}
|
|
79
|
-
let e =
|
|
80
|
-
if (
|
|
81
|
-
let
|
|
86
|
+
let e = J(r, l);
|
|
87
|
+
if (n.endsWith(";") || n.endsWith(",")) {
|
|
88
|
+
let i = l.getTokensAfter(r, {
|
|
82
89
|
includeComments: !0,
|
|
83
90
|
count: 2
|
|
84
91
|
});
|
|
85
|
-
|
|
92
|
+
r.loc.start.line === ((a = i.at(1)) == null ? void 0 : a.loc.start.line) && (u -= 1);
|
|
86
93
|
}
|
|
87
|
-
return e && !
|
|
88
|
-
(
|
|
94
|
+
return e && !pe(
|
|
95
|
+
(s == null ? void 0 : s.partitionComment) ?? !1,
|
|
89
96
|
e.value
|
|
90
|
-
) && (
|
|
91
|
-
},
|
|
92
|
-
var
|
|
93
|
-
let
|
|
94
|
-
for (let
|
|
95
|
-
let { node: y } = l.at(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
...
|
|
97
|
+
) && (t = e.range.at(0)), [t, u];
|
|
98
|
+
}, T = (r, l, s, t, u) => {
|
|
99
|
+
var a, i;
|
|
100
|
+
let n = [], e = ((a = l.at(0)) == null ? void 0 : a.node.loc.start.line) === ((i = l.at(-1)) == null ? void 0 : i.node.loc.end.line);
|
|
101
|
+
for (let o = 0, c = l.length; o < c; o++) {
|
|
102
|
+
let { node: y } = l.at(o);
|
|
103
|
+
n.push(
|
|
104
|
+
r.replaceTextRange(
|
|
105
|
+
M(y, t, u),
|
|
106
|
+
t.text.slice(
|
|
107
|
+
...M(s.at(o).node, t, u)
|
|
101
108
|
)
|
|
102
109
|
)
|
|
103
110
|
);
|
|
104
|
-
let
|
|
105
|
-
if (
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
let h = fe(s.at(o).node, t);
|
|
112
|
+
if (h && !e) {
|
|
113
|
+
let g = [
|
|
114
|
+
t.getTokenBefore(h).range.at(1),
|
|
115
|
+
h.range.at(1)
|
|
109
116
|
];
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
(
|
|
115
|
-
|
|
117
|
+
n.push(r.replaceTextRange(g, ""));
|
|
118
|
+
let m = t.getTokenAfter(y);
|
|
119
|
+
n.push(
|
|
120
|
+
r.insertTextAfter(
|
|
121
|
+
(m == null ? void 0 : m.loc.end.line) === y.loc.end.line ? m : y,
|
|
122
|
+
t.text.slice(...g)
|
|
116
123
|
)
|
|
117
124
|
);
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
|
-
return
|
|
121
|
-
},
|
|
122
|
-
if (
|
|
123
|
-
for (let
|
|
124
|
-
let
|
|
125
|
-
|
|
127
|
+
return n;
|
|
128
|
+
}, C = (r = {}, l) => Object.assign(l, r), P = (r, l) => {
|
|
129
|
+
if (r.length > 1)
|
|
130
|
+
for (let s = 1; s < r.length; s++) {
|
|
131
|
+
let t = r.at(s - 1), u = r.at(s);
|
|
132
|
+
t && u && l(t, u, s - 1);
|
|
126
133
|
}
|
|
127
134
|
};
|
|
128
|
-
const
|
|
129
|
-
name:
|
|
135
|
+
const X = "sort-svelte-attributes", ge = j({
|
|
136
|
+
name: X,
|
|
130
137
|
meta: {
|
|
131
138
|
type: "suggestion",
|
|
132
139
|
docs: {
|
|
@@ -142,16 +149,16 @@ const W = "sort-svelte-attributes", ue = O({
|
|
|
142
149
|
},
|
|
143
150
|
type: {
|
|
144
151
|
enum: [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
p.alphabetical,
|
|
153
|
+
p.natural,
|
|
154
|
+
p["line-length"]
|
|
148
155
|
],
|
|
149
|
-
default:
|
|
156
|
+
default: p.alphabetical,
|
|
150
157
|
type: "string"
|
|
151
158
|
},
|
|
152
159
|
order: {
|
|
153
|
-
enum: [
|
|
154
|
-
default:
|
|
160
|
+
enum: [d.asc, d.desc],
|
|
161
|
+
default: d.asc,
|
|
155
162
|
type: "string"
|
|
156
163
|
},
|
|
157
164
|
"ignore-case": {
|
|
@@ -171,66 +178,66 @@ const W = "sort-svelte-attributes", ue = O({
|
|
|
171
178
|
},
|
|
172
179
|
defaultOptions: [
|
|
173
180
|
{
|
|
174
|
-
type:
|
|
175
|
-
order:
|
|
181
|
+
type: p.alphabetical,
|
|
182
|
+
order: d.asc
|
|
176
183
|
}
|
|
177
184
|
],
|
|
178
|
-
create: (
|
|
185
|
+
create: (r) => _.extname(r.getFilename()) !== ".svelte" ? {} : {
|
|
179
186
|
SvelteStartTag: (l) => {
|
|
180
187
|
if (l.attributes.length > 1) {
|
|
181
|
-
let
|
|
182
|
-
type:
|
|
183
|
-
order:
|
|
188
|
+
let s = C(r.options.at(0), {
|
|
189
|
+
type: p.alphabetical,
|
|
190
|
+
order: d.asc,
|
|
184
191
|
"ignore-case": !1,
|
|
185
192
|
"custom-groups": {},
|
|
186
193
|
groups: []
|
|
187
|
-
}),
|
|
188
|
-
(
|
|
194
|
+
}), t = r.getSourceCode(), u = l.attributes.reduce(
|
|
195
|
+
(n, e) => {
|
|
189
196
|
if (e.type === "SvelteSpreadAttribute")
|
|
190
|
-
return
|
|
191
|
-
let
|
|
192
|
-
|
|
197
|
+
return n.push([]), n;
|
|
198
|
+
let a, { getGroup: i, defineGroup: o, setCustomGroups: c } = R(
|
|
199
|
+
s.groups
|
|
193
200
|
);
|
|
194
|
-
return e.key.type === "SvelteSpecialDirectiveKey" ?
|
|
201
|
+
return e.key.type === "SvelteSpecialDirectiveKey" ? a = t.text.slice(...e.key.range) : typeof e.key.name == "string" ? { name: a } = e.key : a = t.text.slice(...e.key.range), c(s["custom-groups"], a), e.type === "SvelteShorthandAttribute" && (o("svelte-shorthand"), o("shorthand")), (!("value" in e) || Array.isArray(e.value) && !e.value.at(0)) && o("shorthand"), e.loc.start.line !== e.loc.end.line && o("multiline"), n.at(-1).push({
|
|
195
202
|
size: v(e.range),
|
|
196
203
|
node: e,
|
|
197
|
-
group:
|
|
198
|
-
name:
|
|
199
|
-
}),
|
|
204
|
+
group: i(),
|
|
205
|
+
name: a
|
|
206
|
+
}), n;
|
|
200
207
|
},
|
|
201
208
|
[[]]
|
|
202
209
|
);
|
|
203
|
-
for (let
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
(
|
|
210
|
+
for (let n of u)
|
|
211
|
+
P(n, (e, a) => {
|
|
212
|
+
let i = x(s.groups, e), o = x(s.groups, a);
|
|
213
|
+
(i > o || i === o && k(O(e, a, s))) && r.report({
|
|
207
214
|
messageId: "unexpectedSvelteAttributesOrder",
|
|
208
215
|
data: {
|
|
209
216
|
left: e.name,
|
|
210
|
-
right:
|
|
217
|
+
right: a.name
|
|
211
218
|
},
|
|
212
|
-
node:
|
|
213
|
-
fix: (
|
|
219
|
+
node: a.node,
|
|
220
|
+
fix: (c) => {
|
|
214
221
|
let y = {};
|
|
215
|
-
for (let
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
[...y[
|
|
219
|
-
|
|
220
|
-
) : y[
|
|
222
|
+
for (let f of n) {
|
|
223
|
+
let g = x(s.groups, f);
|
|
224
|
+
g in y ? y[g] = A(
|
|
225
|
+
[...y[g], f],
|
|
226
|
+
s
|
|
227
|
+
) : y[g] = [f];
|
|
221
228
|
}
|
|
222
|
-
let
|
|
223
|
-
for (let
|
|
224
|
-
|
|
225
|
-
return
|
|
229
|
+
let h = [];
|
|
230
|
+
for (let f of Object.keys(y).sort())
|
|
231
|
+
h.push(...A(y[f], s));
|
|
232
|
+
return T(c, n, h, t);
|
|
226
233
|
}
|
|
227
234
|
});
|
|
228
235
|
});
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
238
|
}
|
|
232
|
-
}),
|
|
233
|
-
name:
|
|
239
|
+
}), q = "sort-astro-attributes", ye = j({
|
|
240
|
+
name: q,
|
|
234
241
|
meta: {
|
|
235
242
|
type: "suggestion",
|
|
236
243
|
docs: {
|
|
@@ -246,16 +253,16 @@ const W = "sort-svelte-attributes", ue = O({
|
|
|
246
253
|
},
|
|
247
254
|
type: {
|
|
248
255
|
enum: [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
256
|
+
p.alphabetical,
|
|
257
|
+
p.natural,
|
|
258
|
+
p["line-length"]
|
|
252
259
|
],
|
|
253
|
-
default:
|
|
260
|
+
default: p.alphabetical,
|
|
254
261
|
type: "string"
|
|
255
262
|
},
|
|
256
263
|
order: {
|
|
257
|
-
enum: [
|
|
258
|
-
default:
|
|
264
|
+
enum: [d.asc, d.desc],
|
|
265
|
+
default: d.asc,
|
|
259
266
|
type: "string"
|
|
260
267
|
},
|
|
261
268
|
"ignore-case": {
|
|
@@ -275,60 +282,60 @@ const W = "sort-svelte-attributes", ue = O({
|
|
|
275
282
|
},
|
|
276
283
|
defaultOptions: [
|
|
277
284
|
{
|
|
278
|
-
type:
|
|
279
|
-
order:
|
|
285
|
+
type: p.alphabetical,
|
|
286
|
+
order: d.asc
|
|
280
287
|
}
|
|
281
288
|
],
|
|
282
289
|
// @ts-ignore
|
|
283
|
-
create: (
|
|
290
|
+
create: (r) => _.extname(r.getFilename()) !== ".astro" ? {} : {
|
|
284
291
|
JSXElement: (l) => {
|
|
285
|
-
let { attributes:
|
|
286
|
-
if (
|
|
287
|
-
let
|
|
288
|
-
type:
|
|
289
|
-
order:
|
|
292
|
+
let { attributes: s } = l.openingElement;
|
|
293
|
+
if (s.length > 1) {
|
|
294
|
+
let t = C(r.options.at(0), {
|
|
295
|
+
type: p.alphabetical,
|
|
296
|
+
order: d.asc,
|
|
290
297
|
"ignore-case": !1,
|
|
291
298
|
"custom-groups": {},
|
|
292
299
|
groups: []
|
|
293
|
-
}), u =
|
|
294
|
-
(e,
|
|
295
|
-
if (
|
|
300
|
+
}), u = r.getSourceCode(), n = s.reduce(
|
|
301
|
+
(e, a) => {
|
|
302
|
+
if (a.type === "JSXSpreadAttribute")
|
|
296
303
|
return e.push([]), e;
|
|
297
|
-
let
|
|
298
|
-
|
|
304
|
+
let i = typeof a.name.name == "string" ? a.name.name : u.text.slice(...a.name.range), { getGroup: o, defineGroup: c, setCustomGroups: y } = R(
|
|
305
|
+
t.groups
|
|
299
306
|
);
|
|
300
|
-
return y(
|
|
301
|
-
size: v(
|
|
302
|
-
node:
|
|
303
|
-
group:
|
|
304
|
-
name:
|
|
307
|
+
return y(t["custom-groups"], i), a.type === "AstroShorthandAttribute" && (c("astro-shorthand"), c("shorthand")), a.value === null && c("shorthand"), a.loc.start.line !== a.loc.end.line && c("multiline"), e.at(-1).push({
|
|
308
|
+
size: v(a.range),
|
|
309
|
+
node: a,
|
|
310
|
+
group: o(),
|
|
311
|
+
name: i
|
|
305
312
|
}), e;
|
|
306
313
|
},
|
|
307
314
|
[[]]
|
|
308
315
|
);
|
|
309
|
-
for (let e of
|
|
310
|
-
|
|
311
|
-
let
|
|
312
|
-
(
|
|
316
|
+
for (let e of n)
|
|
317
|
+
P(e, (a, i) => {
|
|
318
|
+
let o = x(t.groups, a), c = x(t.groups, i);
|
|
319
|
+
(o > c || o === c && k(O(a, i, t))) && r.report({
|
|
313
320
|
messageId: "unexpectedAstroAttributesOrder",
|
|
314
321
|
data: {
|
|
315
|
-
left:
|
|
316
|
-
right:
|
|
322
|
+
left: a.name,
|
|
323
|
+
right: i.name
|
|
317
324
|
},
|
|
318
|
-
node:
|
|
325
|
+
node: i.node,
|
|
319
326
|
fix: (y) => {
|
|
320
|
-
let
|
|
321
|
-
for (let
|
|
322
|
-
let
|
|
323
|
-
|
|
324
|
-
[...m
|
|
325
|
-
|
|
326
|
-
) : m
|
|
327
|
+
let h = {};
|
|
328
|
+
for (let g of e) {
|
|
329
|
+
let m = x(t.groups, g);
|
|
330
|
+
m in h ? h[m] = A(
|
|
331
|
+
[...h[m], g],
|
|
332
|
+
t
|
|
333
|
+
) : h[m] = [g];
|
|
327
334
|
}
|
|
328
|
-
let
|
|
329
|
-
for (let
|
|
330
|
-
|
|
331
|
-
return
|
|
335
|
+
let f = [];
|
|
336
|
+
for (let g of Object.keys(h).sort())
|
|
337
|
+
f.push(...A(h[g], t));
|
|
338
|
+
return T(y, e, f, u);
|
|
332
339
|
}
|
|
333
340
|
});
|
|
334
341
|
});
|
|
@@ -336,9 +343,9 @@ const W = "sort-svelte-attributes", ue = O({
|
|
|
336
343
|
}
|
|
337
344
|
}
|
|
338
345
|
});
|
|
339
|
-
let I = (
|
|
340
|
-
const
|
|
341
|
-
name:
|
|
346
|
+
let I = (r) => r.replaceAll(/\s\s+/g, " ").trim();
|
|
347
|
+
const K = "sort-array-includes", me = j({
|
|
348
|
+
name: K,
|
|
342
349
|
meta: {
|
|
343
350
|
type: "suggestion",
|
|
344
351
|
docs: {
|
|
@@ -351,16 +358,16 @@ const J = "sort-array-includes", de = O({
|
|
|
351
358
|
properties: {
|
|
352
359
|
type: {
|
|
353
360
|
enum: [
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
361
|
+
p.alphabetical,
|
|
362
|
+
p.natural,
|
|
363
|
+
p["line-length"]
|
|
357
364
|
],
|
|
358
|
-
default:
|
|
365
|
+
default: p.alphabetical,
|
|
359
366
|
type: "string"
|
|
360
367
|
},
|
|
361
368
|
order: {
|
|
362
|
-
enum: [
|
|
363
|
-
default:
|
|
369
|
+
enum: [d.asc, d.desc],
|
|
370
|
+
default: d.asc,
|
|
364
371
|
type: "string"
|
|
365
372
|
},
|
|
366
373
|
"ignore-case": {
|
|
@@ -381,44 +388,44 @@ const J = "sort-array-includes", de = O({
|
|
|
381
388
|
},
|
|
382
389
|
defaultOptions: [
|
|
383
390
|
{
|
|
384
|
-
type:
|
|
385
|
-
order:
|
|
391
|
+
type: p.alphabetical,
|
|
392
|
+
order: d.asc
|
|
386
393
|
}
|
|
387
394
|
],
|
|
388
|
-
create: (
|
|
395
|
+
create: (r) => ({
|
|
389
396
|
MemberExpression: (l) => {
|
|
390
397
|
if ((l.object.type === "ArrayExpression" || l.object.type === "NewExpression") && l.property.type === "Identifier" && l.property.name === "includes") {
|
|
391
|
-
let
|
|
392
|
-
if (
|
|
393
|
-
let
|
|
394
|
-
type:
|
|
395
|
-
order:
|
|
398
|
+
let s = l.object.type === "ArrayExpression" ? l.object.elements : l.object.arguments;
|
|
399
|
+
if (s.length > 1) {
|
|
400
|
+
let t = C(r.options.at(0), {
|
|
401
|
+
type: p.alphabetical,
|
|
402
|
+
order: d.asc,
|
|
396
403
|
"ignore-case": !1,
|
|
397
404
|
"spread-last": !1
|
|
398
|
-
}), u =
|
|
399
|
-
(e,
|
|
400
|
-
name:
|
|
401
|
-
size: v(
|
|
402
|
-
type:
|
|
403
|
-
node:
|
|
405
|
+
}), u = r.getSourceCode(), n = s.reduce(
|
|
406
|
+
(e, a) => (a !== null && e.at(0).push({
|
|
407
|
+
name: a.type === "Literal" ? `${a.value}` : u.text.slice(...a.range),
|
|
408
|
+
size: v(a.range),
|
|
409
|
+
type: a.type,
|
|
410
|
+
node: a
|
|
404
411
|
}), e),
|
|
405
412
|
[[], []]
|
|
406
413
|
).flat();
|
|
407
|
-
|
|
408
|
-
let
|
|
409
|
-
|
|
414
|
+
P(n, (e, a) => {
|
|
415
|
+
let i;
|
|
416
|
+
t["spread-last"] && e.node.type === "Literal" && a.node.type === "SpreadElement" ? i = !1 : t["spread-last"] && e.node.type === "SpreadElement" && a.node.type === "Literal" ? i = !0 : i = k(O(e, a, t)), i && r.report({
|
|
410
417
|
messageId: "unexpectedArrayIncludesOrder",
|
|
411
418
|
data: {
|
|
412
419
|
left: I(e.name),
|
|
413
|
-
right: I(
|
|
420
|
+
right: I(a.name)
|
|
414
421
|
},
|
|
415
|
-
node:
|
|
416
|
-
fix: (
|
|
417
|
-
let
|
|
418
|
-
if (
|
|
419
|
-
for (let y = 0,
|
|
420
|
-
|
|
421
|
-
return
|
|
422
|
+
node: a.node,
|
|
423
|
+
fix: (o) => {
|
|
424
|
+
let c = A(n, t);
|
|
425
|
+
if (t["spread-last"])
|
|
426
|
+
for (let y = 0, h = c.length; y < h; y++)
|
|
427
|
+
c.at(y).node.type === "SpreadElement" && c.push(c.splice(y, 1).at(0));
|
|
428
|
+
return T(o, n, c, u);
|
|
422
429
|
}
|
|
423
430
|
});
|
|
424
431
|
});
|
|
@@ -426,8 +433,8 @@ const J = "sort-array-includes", de = O({
|
|
|
426
433
|
}
|
|
427
434
|
}
|
|
428
435
|
})
|
|
429
|
-
}),
|
|
430
|
-
name:
|
|
436
|
+
}), F = "sort-vue-attributes", he = j({
|
|
437
|
+
name: F,
|
|
431
438
|
meta: {
|
|
432
439
|
type: "suggestion",
|
|
433
440
|
docs: {
|
|
@@ -443,16 +450,16 @@ const J = "sort-array-includes", de = O({
|
|
|
443
450
|
},
|
|
444
451
|
type: {
|
|
445
452
|
enum: [
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
453
|
+
p.alphabetical,
|
|
454
|
+
p.natural,
|
|
455
|
+
p["line-length"]
|
|
449
456
|
],
|
|
450
|
-
default:
|
|
457
|
+
default: p.alphabetical,
|
|
451
458
|
type: "string"
|
|
452
459
|
},
|
|
453
460
|
order: {
|
|
454
|
-
enum: [
|
|
455
|
-
default:
|
|
461
|
+
enum: [d.asc, d.desc],
|
|
462
|
+
default: d.asc,
|
|
456
463
|
type: "string"
|
|
457
464
|
},
|
|
458
465
|
"ignore-case": {
|
|
@@ -473,64 +480,64 @@ const J = "sort-array-includes", de = O({
|
|
|
473
480
|
},
|
|
474
481
|
defaultOptions: [
|
|
475
482
|
{
|
|
476
|
-
type:
|
|
477
|
-
order:
|
|
483
|
+
type: p.alphabetical,
|
|
484
|
+
order: d.asc
|
|
478
485
|
}
|
|
479
486
|
],
|
|
480
|
-
create: (
|
|
481
|
-
if (
|
|
487
|
+
create: (r) => {
|
|
488
|
+
if (_.extname(r.getFilename()) !== ".vue")
|
|
482
489
|
return {};
|
|
483
|
-
if (!("defineTemplateBodyVisitor" in
|
|
490
|
+
if (!("defineTemplateBodyVisitor" in r.parserServices))
|
|
484
491
|
return {};
|
|
485
|
-
let { defineTemplateBodyVisitor: l } =
|
|
492
|
+
let { defineTemplateBodyVisitor: l } = r.parserServices;
|
|
486
493
|
return l({
|
|
487
|
-
VStartTag: (
|
|
488
|
-
if (
|
|
489
|
-
let
|
|
490
|
-
type:
|
|
491
|
-
order:
|
|
494
|
+
VStartTag: (s) => {
|
|
495
|
+
if (s.attributes.length > 1) {
|
|
496
|
+
let t = C(r.options.at(0), {
|
|
497
|
+
type: p.alphabetical,
|
|
498
|
+
order: d.asc,
|
|
492
499
|
"ignore-case": !1,
|
|
493
500
|
"custom-groups": {},
|
|
494
501
|
groups: []
|
|
495
|
-
}), u =
|
|
496
|
-
(e,
|
|
497
|
-
if (
|
|
502
|
+
}), u = r.getSourceCode(), n = s.attributes.reduce(
|
|
503
|
+
(e, a) => {
|
|
504
|
+
if (a.key.type === "VDirectiveKey" && a.key.name.rawName === "bind")
|
|
498
505
|
return e.push([]), e;
|
|
499
|
-
let
|
|
500
|
-
|
|
506
|
+
let i, { getGroup: o, defineGroup: c, setCustomGroups: y } = R(
|
|
507
|
+
t.groups
|
|
501
508
|
);
|
|
502
|
-
return typeof
|
|
503
|
-
size: v(
|
|
504
|
-
node:
|
|
505
|
-
group:
|
|
506
|
-
name:
|
|
509
|
+
return typeof a.key.name == "string" && a.key.type !== "VDirectiveKey" ? i = a.key.rawName : i = u.text.slice(...a.key.range), y(t["custom-groups"], i), a.value === null && c("shorthand"), a.loc.start.line !== a.loc.end.line && c("multiline"), e.at(-1).push({
|
|
510
|
+
size: v(a.range),
|
|
511
|
+
node: a,
|
|
512
|
+
group: o(),
|
|
513
|
+
name: i
|
|
507
514
|
}), e;
|
|
508
515
|
},
|
|
509
516
|
[[]]
|
|
510
517
|
);
|
|
511
|
-
for (let e of
|
|
512
|
-
|
|
513
|
-
let
|
|
514
|
-
(
|
|
518
|
+
for (let e of n)
|
|
519
|
+
P(e, (a, i) => {
|
|
520
|
+
let o = x(t.groups, a), c = x(t.groups, i);
|
|
521
|
+
(o > c || o === c && k(O(a, i, t))) && r.report({
|
|
515
522
|
messageId: "unexpectedVueAttributesOrder",
|
|
516
523
|
data: {
|
|
517
|
-
left:
|
|
518
|
-
right:
|
|
524
|
+
left: a.name,
|
|
525
|
+
right: i.name
|
|
519
526
|
},
|
|
520
|
-
node:
|
|
527
|
+
node: i.node,
|
|
521
528
|
fix: (y) => {
|
|
522
|
-
let
|
|
523
|
-
for (let
|
|
524
|
-
let
|
|
525
|
-
|
|
526
|
-
[...m
|
|
527
|
-
|
|
528
|
-
) : m
|
|
529
|
+
let h = {};
|
|
530
|
+
for (let g of e) {
|
|
531
|
+
let m = x(t.groups, g);
|
|
532
|
+
m in h ? h[m] = A(
|
|
533
|
+
[...h[m], g],
|
|
534
|
+
t
|
|
535
|
+
) : h[m] = [g];
|
|
529
536
|
}
|
|
530
|
-
let
|
|
531
|
-
for (let
|
|
532
|
-
|
|
533
|
-
return
|
|
537
|
+
let f = [];
|
|
538
|
+
for (let g of Object.keys(h).sort())
|
|
539
|
+
f.push(...A(h[g], t));
|
|
540
|
+
return T(y, e, f, u);
|
|
534
541
|
}
|
|
535
542
|
});
|
|
536
543
|
});
|
|
@@ -538,8 +545,8 @@ const J = "sort-array-includes", de = O({
|
|
|
538
545
|
}
|
|
539
546
|
});
|
|
540
547
|
}
|
|
541
|
-
}),
|
|
542
|
-
name:
|
|
548
|
+
}), H = "sort-named-exports", be = j({
|
|
549
|
+
name: H,
|
|
543
550
|
meta: {
|
|
544
551
|
type: "suggestion",
|
|
545
552
|
docs: {
|
|
@@ -552,16 +559,16 @@ const J = "sort-array-includes", de = O({
|
|
|
552
559
|
properties: {
|
|
553
560
|
type: {
|
|
554
561
|
enum: [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
562
|
+
p.alphabetical,
|
|
563
|
+
p.natural,
|
|
564
|
+
p["line-length"]
|
|
558
565
|
],
|
|
559
|
-
default:
|
|
566
|
+
default: p.alphabetical,
|
|
560
567
|
type: "string"
|
|
561
568
|
},
|
|
562
569
|
order: {
|
|
563
|
-
enum: [
|
|
564
|
-
default:
|
|
570
|
+
enum: [d.asc, d.desc],
|
|
571
|
+
default: d.asc,
|
|
565
572
|
type: "string"
|
|
566
573
|
},
|
|
567
574
|
"ignore-case": {
|
|
@@ -578,38 +585,38 @@ const J = "sort-array-includes", de = O({
|
|
|
578
585
|
},
|
|
579
586
|
defaultOptions: [
|
|
580
587
|
{
|
|
581
|
-
type:
|
|
582
|
-
order:
|
|
588
|
+
type: p.alphabetical,
|
|
589
|
+
order: d.asc
|
|
583
590
|
}
|
|
584
591
|
],
|
|
585
|
-
create: (
|
|
592
|
+
create: (r) => ({
|
|
586
593
|
ExportNamedDeclaration: (l) => {
|
|
587
594
|
if (l.specifiers.length > 1) {
|
|
588
|
-
let
|
|
589
|
-
type:
|
|
595
|
+
let s = C(r.options.at(0), {
|
|
596
|
+
type: p.alphabetical,
|
|
590
597
|
"ignore-case": !1,
|
|
591
|
-
order:
|
|
592
|
-
}),
|
|
593
|
-
size: v(
|
|
594
|
-
name:
|
|
595
|
-
node:
|
|
598
|
+
order: d.asc
|
|
599
|
+
}), t = r.getSourceCode(), u = l.specifiers.map((n) => ({
|
|
600
|
+
size: v(n.range),
|
|
601
|
+
name: n.local.name,
|
|
602
|
+
node: n
|
|
596
603
|
}));
|
|
597
|
-
|
|
598
|
-
|
|
604
|
+
P(u, (n, e) => {
|
|
605
|
+
k(O(n, e, s)) && r.report({
|
|
599
606
|
messageId: "unexpectedNamedExportsOrder",
|
|
600
607
|
data: {
|
|
601
|
-
left:
|
|
608
|
+
left: n.name,
|
|
602
609
|
right: e.name
|
|
603
610
|
},
|
|
604
611
|
node: e.node,
|
|
605
|
-
fix: (
|
|
612
|
+
fix: (a) => T(a, u, A(u, s), t)
|
|
606
613
|
});
|
|
607
614
|
});
|
|
608
615
|
}
|
|
609
616
|
}
|
|
610
617
|
})
|
|
611
|
-
}),
|
|
612
|
-
name:
|
|
618
|
+
}), Q = "sort-named-imports", xe = j({
|
|
619
|
+
name: Q,
|
|
613
620
|
meta: {
|
|
614
621
|
type: "suggestion",
|
|
615
622
|
docs: {
|
|
@@ -622,16 +629,16 @@ const J = "sort-array-includes", de = O({
|
|
|
622
629
|
properties: {
|
|
623
630
|
type: {
|
|
624
631
|
enum: [
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
632
|
+
p.alphabetical,
|
|
633
|
+
p.natural,
|
|
634
|
+
p["line-length"]
|
|
628
635
|
],
|
|
629
|
-
default:
|
|
636
|
+
default: p.alphabetical,
|
|
630
637
|
type: "string"
|
|
631
638
|
},
|
|
632
639
|
order: {
|
|
633
|
-
enum: [
|
|
634
|
-
default:
|
|
640
|
+
enum: [d.asc, d.desc],
|
|
641
|
+
default: d.asc,
|
|
635
642
|
type: "string"
|
|
636
643
|
},
|
|
637
644
|
"ignore-case": {
|
|
@@ -652,45 +659,50 @@ const J = "sort-array-includes", de = O({
|
|
|
652
659
|
},
|
|
653
660
|
defaultOptions: [
|
|
654
661
|
{
|
|
655
|
-
type:
|
|
656
|
-
order:
|
|
662
|
+
type: p.alphabetical,
|
|
663
|
+
order: d.asc
|
|
657
664
|
}
|
|
658
665
|
],
|
|
659
|
-
create: (
|
|
666
|
+
create: (r) => ({
|
|
660
667
|
ImportDeclaration: (l) => {
|
|
661
|
-
let
|
|
662
|
-
({ type:
|
|
668
|
+
let s = l.specifiers.filter(
|
|
669
|
+
({ type: t }) => t === "ImportSpecifier"
|
|
663
670
|
);
|
|
664
|
-
if (
|
|
665
|
-
let
|
|
666
|
-
type:
|
|
671
|
+
if (s.length > 1) {
|
|
672
|
+
let t = C(r.options.at(0), {
|
|
673
|
+
type: p.alphabetical,
|
|
667
674
|
"ignore-alias": !0,
|
|
668
675
|
"ignore-case": !1,
|
|
669
|
-
order:
|
|
670
|
-
}), u =
|
|
671
|
-
let { name:
|
|
672
|
-
return
|
|
676
|
+
order: d.asc
|
|
677
|
+
}), u = r.getSourceCode(), n = s.map((e) => {
|
|
678
|
+
let { name: a } = e.local;
|
|
679
|
+
return t["ignore-alias"] && e.type === "ImportSpecifier" && ({ name: a } = e.imported), {
|
|
673
680
|
size: v(e.range),
|
|
674
681
|
node: e,
|
|
675
|
-
name:
|
|
682
|
+
name: a
|
|
676
683
|
};
|
|
677
684
|
});
|
|
678
|
-
|
|
679
|
-
|
|
685
|
+
P(n, (e, a) => {
|
|
686
|
+
k(O(e, a, t)) && r.report({
|
|
680
687
|
messageId: "unexpectedNamedImportsOrder",
|
|
681
688
|
data: {
|
|
682
689
|
left: e.name,
|
|
683
|
-
right:
|
|
690
|
+
right: a.name
|
|
684
691
|
},
|
|
685
|
-
node:
|
|
686
|
-
fix: (
|
|
692
|
+
node: a.node,
|
|
693
|
+
fix: (i) => T(i, n, A(n, t), u)
|
|
687
694
|
});
|
|
688
695
|
});
|
|
689
696
|
}
|
|
690
697
|
}
|
|
691
698
|
})
|
|
692
|
-
})
|
|
693
|
-
|
|
699
|
+
});
|
|
700
|
+
let B = (r, l, s) => r.lines.slice(
|
|
701
|
+
l.node.loc.end.line,
|
|
702
|
+
s.node.loc.start.line - 1
|
|
703
|
+
).filter((u) => !u.trim().length).length;
|
|
704
|
+
const Y = "sort-object-types", Ee = j({
|
|
705
|
+
name: Y,
|
|
694
706
|
meta: {
|
|
695
707
|
type: "suggestion",
|
|
696
708
|
docs: {
|
|
@@ -706,16 +718,16 @@ const J = "sort-array-includes", de = O({
|
|
|
706
718
|
},
|
|
707
719
|
type: {
|
|
708
720
|
enum: [
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
721
|
+
p.alphabetical,
|
|
722
|
+
p.natural,
|
|
723
|
+
p["line-length"]
|
|
712
724
|
],
|
|
713
|
-
default:
|
|
725
|
+
default: p.alphabetical,
|
|
714
726
|
type: "string"
|
|
715
727
|
},
|
|
716
728
|
order: {
|
|
717
|
-
enum: [
|
|
718
|
-
default:
|
|
729
|
+
enum: [d.asc, d.desc],
|
|
730
|
+
default: d.asc,
|
|
719
731
|
type: "string"
|
|
720
732
|
},
|
|
721
733
|
"ignore-case": {
|
|
@@ -725,6 +737,10 @@ const J = "sort-array-includes", de = O({
|
|
|
725
737
|
groups: {
|
|
726
738
|
type: "array",
|
|
727
739
|
default: []
|
|
740
|
+
},
|
|
741
|
+
"partition-by-new-line": {
|
|
742
|
+
type: "boolean",
|
|
743
|
+
default: !1
|
|
728
744
|
}
|
|
729
745
|
},
|
|
730
746
|
additionalProperties: !1
|
|
@@ -736,75 +752,82 @@ const J = "sort-array-includes", de = O({
|
|
|
736
752
|
},
|
|
737
753
|
defaultOptions: [
|
|
738
754
|
{
|
|
739
|
-
type:
|
|
740
|
-
order:
|
|
755
|
+
type: p.alphabetical,
|
|
756
|
+
order: d.asc
|
|
741
757
|
}
|
|
742
758
|
],
|
|
743
|
-
create: (
|
|
759
|
+
create: (r) => ({
|
|
744
760
|
TSTypeLiteral: (l) => {
|
|
745
761
|
if (l.members.length > 1) {
|
|
746
|
-
let
|
|
747
|
-
|
|
762
|
+
let s = C(r.options.at(0), {
|
|
763
|
+
"partition-by-new-line": !1,
|
|
764
|
+
type: p.alphabetical,
|
|
748
765
|
"ignore-case": !1,
|
|
749
|
-
order:
|
|
766
|
+
order: d.asc,
|
|
750
767
|
"custom-groups": {},
|
|
751
768
|
groups: []
|
|
752
|
-
}),
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
n.
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
t.
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
a
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
769
|
+
}), t = r.getSourceCode(), u = l.members.reduce(
|
|
770
|
+
(n, e) => {
|
|
771
|
+
var E, b, N, S;
|
|
772
|
+
let a, i = t.text.slice(e.range.at(0), e.range.at(1)), o = (E = n.at(-1)) == null ? void 0 : E.at(-1), { getGroup: c, defineGroup: y, setCustomGroups: h } = R(
|
|
773
|
+
s.groups
|
|
774
|
+
), f = (L) => L.replace(/(,|;)$/, "");
|
|
775
|
+
if (e.type === "TSPropertySignature")
|
|
776
|
+
e.key.type === "Identifier" ? { name: a } = e.key : e.key.type === "Literal" ? a = `${e.key.value}` : a = t.text.slice(
|
|
777
|
+
e.range.at(0),
|
|
778
|
+
(b = e.typeAnnotation) == null ? void 0 : b.range.at(0)
|
|
779
|
+
);
|
|
780
|
+
else if (e.type === "TSIndexSignature") {
|
|
781
|
+
let L = ((N = e.typeAnnotation) == null ? void 0 : N.range.at(0)) ?? e.range.at(1);
|
|
782
|
+
a = f(t.text.slice(e.range.at(0), L));
|
|
783
|
+
} else
|
|
784
|
+
a = f(
|
|
785
|
+
t.text.slice(e.range.at(0), e.range.at(1))
|
|
786
|
+
);
|
|
787
|
+
h(s["custom-groups"], a), e.loc.start.line !== e.loc.end.line && y("multiline");
|
|
788
|
+
let m = i.endsWith(";") || i.endsWith(",") ? 1 : 0, w = {
|
|
789
|
+
size: v(e.range) - m,
|
|
790
|
+
node: e,
|
|
791
|
+
name: a
|
|
792
|
+
};
|
|
793
|
+
return s["partition-by-new-line"] && o && B(t, o, w) && n.push([]), (S = n.at(-1)) == null || S.push({
|
|
794
|
+
...w,
|
|
795
|
+
group: c()
|
|
796
|
+
}), n;
|
|
797
|
+
},
|
|
798
|
+
[[]]
|
|
799
|
+
);
|
|
800
|
+
for (let n of u)
|
|
801
|
+
P(n, (e, a) => {
|
|
802
|
+
let i = x(s.groups, e), o = x(s.groups, a);
|
|
803
|
+
(i > o || i === o && k(O(e, a, s))) && r.report({
|
|
804
|
+
messageId: "unexpectedObjectTypesOrder",
|
|
805
|
+
data: {
|
|
806
|
+
left: I(e.name),
|
|
807
|
+
right: I(a.name)
|
|
808
|
+
},
|
|
809
|
+
node: a.node,
|
|
810
|
+
fix: (c) => {
|
|
811
|
+
let y = {};
|
|
812
|
+
for (let f of n) {
|
|
813
|
+
let g = x(s.groups, f);
|
|
814
|
+
g in y ? y[g] = A(
|
|
815
|
+
[...y[g], f],
|
|
816
|
+
s
|
|
817
|
+
) : y[g] = [f];
|
|
818
|
+
}
|
|
819
|
+
let h = [];
|
|
820
|
+
for (let f of Object.keys(y).sort())
|
|
821
|
+
h.push(...A(y[f], s));
|
|
822
|
+
return T(c, n, h, t);
|
|
795
823
|
}
|
|
796
|
-
|
|
797
|
-
for (let m of Object.keys(d).sort())
|
|
798
|
-
y.push(...A(d[m], n));
|
|
799
|
-
return P(c, u, y, a);
|
|
800
|
-
}
|
|
824
|
+
});
|
|
801
825
|
});
|
|
802
|
-
});
|
|
803
826
|
}
|
|
804
827
|
}
|
|
805
828
|
})
|
|
806
|
-
}),
|
|
807
|
-
name:
|
|
829
|
+
}), Z = "sort-union-types", Se = j({
|
|
830
|
+
name: Z,
|
|
808
831
|
meta: {
|
|
809
832
|
type: "suggestion",
|
|
810
833
|
docs: {
|
|
@@ -817,16 +840,16 @@ const J = "sort-array-includes", de = O({
|
|
|
817
840
|
properties: {
|
|
818
841
|
type: {
|
|
819
842
|
enum: [
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
843
|
+
p.alphabetical,
|
|
844
|
+
p.natural,
|
|
845
|
+
p["line-length"]
|
|
823
846
|
],
|
|
824
|
-
default:
|
|
847
|
+
default: p.alphabetical,
|
|
825
848
|
type: "string"
|
|
826
849
|
},
|
|
827
850
|
order: {
|
|
828
|
-
enum: [
|
|
829
|
-
default:
|
|
851
|
+
enum: [d.asc, d.desc],
|
|
852
|
+
default: d.asc,
|
|
830
853
|
type: "string"
|
|
831
854
|
},
|
|
832
855
|
"ignore-case": {
|
|
@@ -847,50 +870,50 @@ const J = "sort-array-includes", de = O({
|
|
|
847
870
|
},
|
|
848
871
|
defaultOptions: [
|
|
849
872
|
{
|
|
850
|
-
type:
|
|
851
|
-
order:
|
|
873
|
+
type: p.alphabetical,
|
|
874
|
+
order: d.asc
|
|
852
875
|
}
|
|
853
876
|
],
|
|
854
|
-
create: (
|
|
877
|
+
create: (r) => ({
|
|
855
878
|
TSUnionType: (l) => {
|
|
856
|
-
let
|
|
857
|
-
type:
|
|
879
|
+
let s = r.getSourceCode(), t = C(r.options.at(0), {
|
|
880
|
+
type: p.alphabetical,
|
|
858
881
|
"nullable-last": !1,
|
|
859
882
|
"ignore-case": !1,
|
|
860
|
-
order:
|
|
861
|
-
}), u = l.types.map((
|
|
862
|
-
group:
|
|
863
|
-
name:
|
|
864
|
-
size: v(
|
|
865
|
-
node:
|
|
883
|
+
order: d.asc
|
|
884
|
+
}), u = l.types.map((n) => ({
|
|
885
|
+
group: n.type === "TSNullKeyword" || n.type === "TSUndefinedKeyword" ? "nullable" : "unknown",
|
|
886
|
+
name: s.text.slice(...n.range),
|
|
887
|
+
size: v(n.range),
|
|
888
|
+
node: n
|
|
866
889
|
}));
|
|
867
|
-
|
|
868
|
-
let
|
|
869
|
-
|
|
890
|
+
P(u, (n, e) => {
|
|
891
|
+
let a = k(O(n, e, t));
|
|
892
|
+
t["nullable-last"] && (n.group === "nullable" && e.group === "unknown" ? a = !0 : n.group === "unknown" && e.group === "nullable" && (a = !1)), a && r.report({
|
|
870
893
|
messageId: "unexpectedUnionTypesOrder",
|
|
871
894
|
data: {
|
|
872
|
-
left: I(
|
|
895
|
+
left: I(n.name),
|
|
873
896
|
right: I(e.name)
|
|
874
897
|
},
|
|
875
898
|
node: e.node,
|
|
876
|
-
fix: (
|
|
877
|
-
let
|
|
878
|
-
if (
|
|
879
|
-
let
|
|
880
|
-
|
|
881
|
-
...A(y,
|
|
882
|
-
...A(
|
|
899
|
+
fix: (i) => {
|
|
900
|
+
let o = [];
|
|
901
|
+
if (t["nullable-last"]) {
|
|
902
|
+
let c = [], y = u.filter((h) => h.group === "nullable" ? (c.push(h), !1) : !0);
|
|
903
|
+
o = [
|
|
904
|
+
...A(y, t),
|
|
905
|
+
...A(c, t)
|
|
883
906
|
];
|
|
884
907
|
} else
|
|
885
|
-
|
|
886
|
-
return
|
|
908
|
+
o = A(u, t);
|
|
909
|
+
return T(i, u, o, s);
|
|
887
910
|
}
|
|
888
911
|
});
|
|
889
912
|
});
|
|
890
913
|
}
|
|
891
914
|
})
|
|
892
|
-
}),
|
|
893
|
-
name:
|
|
915
|
+
}), ee = "sort-interfaces", we = j({
|
|
916
|
+
name: ee,
|
|
894
917
|
meta: {
|
|
895
918
|
type: "suggestion",
|
|
896
919
|
docs: {
|
|
@@ -906,16 +929,16 @@ const J = "sort-array-includes", de = O({
|
|
|
906
929
|
},
|
|
907
930
|
type: {
|
|
908
931
|
enum: [
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
932
|
+
p.alphabetical,
|
|
933
|
+
p.natural,
|
|
934
|
+
p["line-length"]
|
|
912
935
|
],
|
|
913
|
-
default:
|
|
936
|
+
default: p.alphabetical,
|
|
914
937
|
type: "string"
|
|
915
938
|
},
|
|
916
939
|
order: {
|
|
917
|
-
enum: [
|
|
918
|
-
default:
|
|
940
|
+
enum: [d.asc, d.desc],
|
|
941
|
+
default: d.asc,
|
|
919
942
|
type: "string"
|
|
920
943
|
},
|
|
921
944
|
"ignore-case": {
|
|
@@ -931,6 +954,10 @@ const J = "sort-array-includes", de = O({
|
|
|
931
954
|
groups: {
|
|
932
955
|
type: "array",
|
|
933
956
|
default: []
|
|
957
|
+
},
|
|
958
|
+
"partition-by-new-line": {
|
|
959
|
+
type: "boolean",
|
|
960
|
+
default: !1
|
|
934
961
|
}
|
|
935
962
|
},
|
|
936
963
|
additionalProperties: !1
|
|
@@ -942,82 +969,86 @@ const J = "sort-array-includes", de = O({
|
|
|
942
969
|
},
|
|
943
970
|
defaultOptions: [
|
|
944
971
|
{
|
|
945
|
-
type:
|
|
946
|
-
order:
|
|
972
|
+
type: p.alphabetical,
|
|
973
|
+
order: d.asc
|
|
947
974
|
}
|
|
948
975
|
],
|
|
949
|
-
create: (
|
|
976
|
+
create: (r) => ({
|
|
950
977
|
TSInterfaceDeclaration: (l) => {
|
|
951
978
|
if (l.body.body.length > 1) {
|
|
952
|
-
let
|
|
953
|
-
|
|
979
|
+
let s = C(r.options.at(0), {
|
|
980
|
+
"partition-by-new-line": !1,
|
|
981
|
+
type: p.alphabetical,
|
|
954
982
|
"ignore-case": !1,
|
|
955
|
-
order:
|
|
983
|
+
order: d.asc,
|
|
956
984
|
"ignore-pattern": [],
|
|
957
985
|
"custom-groups": {},
|
|
958
986
|
groups: []
|
|
959
987
|
});
|
|
960
|
-
if (!
|
|
961
|
-
(
|
|
988
|
+
if (!s["ignore-pattern"].some(
|
|
989
|
+
(t) => D(l.id.name, t, {
|
|
962
990
|
nocomment: !0
|
|
963
991
|
})
|
|
964
992
|
)) {
|
|
965
|
-
let
|
|
966
|
-
(
|
|
967
|
-
var
|
|
993
|
+
let t = r.getSourceCode(), u = l.body.body.reduce(
|
|
994
|
+
(n, e) => {
|
|
995
|
+
var f, g, m, w;
|
|
968
996
|
if (e.type === "TSCallSignatureDeclaration")
|
|
969
|
-
return
|
|
970
|
-
let
|
|
971
|
-
|
|
997
|
+
return n.push([]), n;
|
|
998
|
+
let a = (f = n.at(-1)) == null ? void 0 : f.at(-1), i, { getGroup: o, defineGroup: c, setCustomGroups: y } = R(
|
|
999
|
+
s.groups
|
|
972
1000
|
);
|
|
973
1001
|
if (e.type === "TSPropertySignature")
|
|
974
1002
|
if (e.key.type === "Identifier")
|
|
975
|
-
({ name:
|
|
1003
|
+
({ name: i } = e.key);
|
|
976
1004
|
else if (e.key.type === "Literal")
|
|
977
|
-
|
|
1005
|
+
i = `${e.key.value}`;
|
|
978
1006
|
else {
|
|
979
|
-
let
|
|
980
|
-
|
|
1007
|
+
let E = ((g = e.typeAnnotation) == null ? void 0 : g.range.at(0)) ?? e.range.at(1) - (e.optional ? 1 : 0);
|
|
1008
|
+
i = t.text.slice(e.range.at(0), E);
|
|
981
1009
|
}
|
|
982
1010
|
else if (e.type === "TSIndexSignature") {
|
|
983
|
-
let
|
|
984
|
-
|
|
1011
|
+
let E = ((m = e.typeAnnotation) == null ? void 0 : m.range.at(0)) ?? e.range.at(1);
|
|
1012
|
+
i = t.text.slice(e.range.at(0), E);
|
|
985
1013
|
} else {
|
|
986
|
-
let
|
|
987
|
-
|
|
1014
|
+
let E = ((w = e.returnType) == null ? void 0 : w.range.at(0)) ?? e.range.at(1);
|
|
1015
|
+
i = t.text.slice(e.range.at(0), E);
|
|
988
1016
|
}
|
|
989
|
-
|
|
1017
|
+
let h = {
|
|
990
1018
|
size: v(e.range),
|
|
991
|
-
group: r(),
|
|
992
1019
|
node: e,
|
|
993
|
-
name:
|
|
994
|
-
}
|
|
1020
|
+
name: i
|
|
1021
|
+
};
|
|
1022
|
+
return s["partition-by-new-line"] && a && B(t, a, h) && n.push([]), y(s["custom-groups"], i), e.loc.start.line !== e.loc.end.line && c("multiline"), n.at(-1).push({
|
|
1023
|
+
...h,
|
|
1024
|
+
group: o()
|
|
1025
|
+
}), n;
|
|
995
1026
|
},
|
|
996
1027
|
[[]]
|
|
997
1028
|
);
|
|
998
|
-
for (let
|
|
999
|
-
|
|
1000
|
-
let
|
|
1001
|
-
(
|
|
1029
|
+
for (let n of u)
|
|
1030
|
+
P(n, (e, a) => {
|
|
1031
|
+
let i = x(s.groups, e), o = x(s.groups, a);
|
|
1032
|
+
(i > o || i === o && k(O(e, a, s))) && r.report({
|
|
1002
1033
|
messageId: "unexpectedInterfacePropertiesOrder",
|
|
1003
1034
|
data: {
|
|
1004
1035
|
left: I(e.name),
|
|
1005
|
-
right: I(
|
|
1036
|
+
right: I(a.name)
|
|
1006
1037
|
},
|
|
1007
|
-
node:
|
|
1008
|
-
fix: (
|
|
1038
|
+
node: a.node,
|
|
1039
|
+
fix: (c) => {
|
|
1009
1040
|
let y = {};
|
|
1010
|
-
for (let
|
|
1011
|
-
let
|
|
1012
|
-
|
|
1013
|
-
[...y[
|
|
1014
|
-
|
|
1015
|
-
) : y[
|
|
1041
|
+
for (let f of n) {
|
|
1042
|
+
let g = x(s.groups, f);
|
|
1043
|
+
g in y ? y[g] = A(
|
|
1044
|
+
[...y[g], f],
|
|
1045
|
+
s
|
|
1046
|
+
) : y[g] = [f];
|
|
1016
1047
|
}
|
|
1017
|
-
let
|
|
1018
|
-
for (let
|
|
1019
|
-
|
|
1020
|
-
return
|
|
1048
|
+
let h = [];
|
|
1049
|
+
for (let f of Object.keys(y).sort())
|
|
1050
|
+
h.push(...A(y[f], s));
|
|
1051
|
+
return T(c, n, h, t);
|
|
1021
1052
|
}
|
|
1022
1053
|
});
|
|
1023
1054
|
});
|
|
@@ -1025,8 +1056,8 @@ const J = "sort-array-includes", de = O({
|
|
|
1025
1056
|
}
|
|
1026
1057
|
}
|
|
1027
1058
|
})
|
|
1028
|
-
}),
|
|
1029
|
-
name:
|
|
1059
|
+
}), te = "sort-jsx-props", Ae = j({
|
|
1060
|
+
name: te,
|
|
1030
1061
|
meta: {
|
|
1031
1062
|
type: "suggestion",
|
|
1032
1063
|
docs: {
|
|
@@ -1042,16 +1073,16 @@ const J = "sort-array-includes", de = O({
|
|
|
1042
1073
|
},
|
|
1043
1074
|
type: {
|
|
1044
1075
|
enum: [
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1076
|
+
p.alphabetical,
|
|
1077
|
+
p.natural,
|
|
1078
|
+
p["line-length"]
|
|
1048
1079
|
],
|
|
1049
|
-
default:
|
|
1080
|
+
default: p.alphabetical,
|
|
1050
1081
|
type: "string"
|
|
1051
1082
|
},
|
|
1052
1083
|
order: {
|
|
1053
|
-
enum: [
|
|
1054
|
-
default:
|
|
1084
|
+
enum: [d.asc, d.desc],
|
|
1085
|
+
default: d.asc,
|
|
1055
1086
|
type: "string"
|
|
1056
1087
|
},
|
|
1057
1088
|
groups: {
|
|
@@ -1071,70 +1102,70 @@ const J = "sort-array-includes", de = O({
|
|
|
1071
1102
|
},
|
|
1072
1103
|
defaultOptions: [
|
|
1073
1104
|
{
|
|
1074
|
-
type:
|
|
1075
|
-
order:
|
|
1105
|
+
type: p.alphabetical,
|
|
1106
|
+
order: d.asc
|
|
1076
1107
|
}
|
|
1077
1108
|
],
|
|
1078
|
-
create: (
|
|
1079
|
-
|
|
1109
|
+
create: (r) => [".svelte", ".astro", ".vue"].includes(
|
|
1110
|
+
_.extname(r.getFilename())
|
|
1080
1111
|
) ? {} : {
|
|
1081
1112
|
JSXElement: (l) => {
|
|
1082
1113
|
if (l.openingElement.attributes.length > 1) {
|
|
1083
|
-
let
|
|
1084
|
-
type:
|
|
1114
|
+
let s = C(r.options.at(0), {
|
|
1115
|
+
type: p.alphabetical,
|
|
1085
1116
|
"ignore-case": !1,
|
|
1086
|
-
order:
|
|
1117
|
+
order: d.asc,
|
|
1087
1118
|
"custom-groups": {},
|
|
1088
1119
|
groups: []
|
|
1089
|
-
}),
|
|
1090
|
-
(
|
|
1120
|
+
}), t = r.getSourceCode(), u = l.openingElement.attributes.reduce(
|
|
1121
|
+
(n, e) => {
|
|
1091
1122
|
if (e.type === "JSXSpreadAttribute")
|
|
1092
|
-
return
|
|
1093
|
-
let
|
|
1094
|
-
|
|
1123
|
+
return n.push([]), n;
|
|
1124
|
+
let a = e.name.type === "JSXNamespacedName" ? `${e.name.namespace.name}:${e.name.name.name}` : e.name.name, { getGroup: i, defineGroup: o, setCustomGroups: c } = R(
|
|
1125
|
+
s.groups
|
|
1095
1126
|
);
|
|
1096
|
-
|
|
1127
|
+
c(s["custom-groups"], a), e.value === null && o("shorthand"), e.loc.start.line !== e.loc.end.line && o("multiline");
|
|
1097
1128
|
let y = {
|
|
1098
1129
|
size: v(e.range),
|
|
1099
|
-
group:
|
|
1130
|
+
group: i(),
|
|
1100
1131
|
node: e,
|
|
1101
|
-
name:
|
|
1132
|
+
name: a
|
|
1102
1133
|
};
|
|
1103
|
-
return
|
|
1134
|
+
return n.at(-1).push(y), n;
|
|
1104
1135
|
},
|
|
1105
1136
|
[[]]
|
|
1106
1137
|
);
|
|
1107
|
-
for (let
|
|
1108
|
-
|
|
1109
|
-
let
|
|
1110
|
-
(
|
|
1138
|
+
for (let n of u)
|
|
1139
|
+
P(n, (e, a) => {
|
|
1140
|
+
let i = x(s.groups, e), o = x(s.groups, a);
|
|
1141
|
+
(i > o || i === o && k(O(e, a, s))) && r.report({
|
|
1111
1142
|
messageId: "unexpectedJSXPropsOrder",
|
|
1112
1143
|
data: {
|
|
1113
1144
|
left: e.name,
|
|
1114
|
-
right:
|
|
1145
|
+
right: a.name
|
|
1115
1146
|
},
|
|
1116
|
-
node:
|
|
1117
|
-
fix: (
|
|
1147
|
+
node: a.node,
|
|
1148
|
+
fix: (c) => {
|
|
1118
1149
|
let y = {};
|
|
1119
|
-
for (let
|
|
1120
|
-
let
|
|
1121
|
-
|
|
1122
|
-
[...y[
|
|
1123
|
-
|
|
1124
|
-
) : y[
|
|
1150
|
+
for (let f of n) {
|
|
1151
|
+
let g = x(s.groups, f);
|
|
1152
|
+
g in y ? y[g] = A(
|
|
1153
|
+
[...y[g], f],
|
|
1154
|
+
s
|
|
1155
|
+
) : y[g] = [f];
|
|
1125
1156
|
}
|
|
1126
|
-
let
|
|
1127
|
-
for (let
|
|
1128
|
-
|
|
1129
|
-
return
|
|
1157
|
+
let h = [];
|
|
1158
|
+
for (let f of Object.keys(y).sort())
|
|
1159
|
+
h.push(...A(y[f], s));
|
|
1160
|
+
return T(c, n, h, t);
|
|
1130
1161
|
}
|
|
1131
1162
|
});
|
|
1132
1163
|
});
|
|
1133
1164
|
}
|
|
1134
1165
|
}
|
|
1135
1166
|
}
|
|
1136
|
-
}),
|
|
1137
|
-
name:
|
|
1167
|
+
}), re = "sort-exports", Ne = j({
|
|
1168
|
+
name: re,
|
|
1138
1169
|
meta: {
|
|
1139
1170
|
type: "suggestion",
|
|
1140
1171
|
docs: {
|
|
@@ -1147,16 +1178,16 @@ const J = "sort-array-includes", de = O({
|
|
|
1147
1178
|
properties: {
|
|
1148
1179
|
type: {
|
|
1149
1180
|
enum: [
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1181
|
+
p.alphabetical,
|
|
1182
|
+
p.natural,
|
|
1183
|
+
p["line-length"]
|
|
1153
1184
|
],
|
|
1154
|
-
default:
|
|
1185
|
+
default: p.alphabetical,
|
|
1155
1186
|
type: "string"
|
|
1156
1187
|
},
|
|
1157
1188
|
order: {
|
|
1158
|
-
enum: [
|
|
1159
|
-
default:
|
|
1189
|
+
enum: [d.asc, d.desc],
|
|
1190
|
+
default: d.asc,
|
|
1160
1191
|
type: "string"
|
|
1161
1192
|
},
|
|
1162
1193
|
"ignore-case": {
|
|
@@ -1173,46 +1204,46 @@ const J = "sort-array-includes", de = O({
|
|
|
1173
1204
|
},
|
|
1174
1205
|
defaultOptions: [
|
|
1175
1206
|
{
|
|
1176
|
-
type:
|
|
1177
|
-
order:
|
|
1207
|
+
type: p.alphabetical,
|
|
1208
|
+
order: d.asc
|
|
1178
1209
|
}
|
|
1179
1210
|
],
|
|
1180
|
-
create: (
|
|
1181
|
-
let l =
|
|
1182
|
-
type:
|
|
1183
|
-
order:
|
|
1211
|
+
create: (r) => {
|
|
1212
|
+
let l = C(r.options.at(0), {
|
|
1213
|
+
type: p.alphabetical,
|
|
1214
|
+
order: d.asc,
|
|
1184
1215
|
"ignore-case": !1
|
|
1185
|
-
}),
|
|
1186
|
-
u.type === "ExportAllDeclaration" && u.exported === null ?
|
|
1216
|
+
}), s = [[]], t = (u) => {
|
|
1217
|
+
u.type === "ExportAllDeclaration" && u.exported === null ? s.push([]) : s.at(-1).push({
|
|
1187
1218
|
size: v(u.range),
|
|
1188
1219
|
name: u.source.value,
|
|
1189
1220
|
node: u
|
|
1190
1221
|
});
|
|
1191
1222
|
};
|
|
1192
1223
|
return {
|
|
1193
|
-
ExportAllDeclaration:
|
|
1224
|
+
ExportAllDeclaration: t,
|
|
1194
1225
|
ExportNamedDeclaration: (u) => {
|
|
1195
|
-
u.source !== null &&
|
|
1226
|
+
u.source !== null && t(u);
|
|
1196
1227
|
},
|
|
1197
1228
|
"Program:exit": () => {
|
|
1198
|
-
let u =
|
|
1199
|
-
for (let
|
|
1200
|
-
|
|
1201
|
-
|
|
1229
|
+
let u = r.getSourceCode();
|
|
1230
|
+
for (let n of s)
|
|
1231
|
+
P(n, (e, a) => {
|
|
1232
|
+
k(O(e, a, l)) && r.report({
|
|
1202
1233
|
messageId: "unexpectedExportsOrder",
|
|
1203
1234
|
data: {
|
|
1204
1235
|
left: e.name,
|
|
1205
|
-
right:
|
|
1236
|
+
right: a.name
|
|
1206
1237
|
},
|
|
1207
|
-
node:
|
|
1208
|
-
fix: (
|
|
1238
|
+
node: a.node,
|
|
1239
|
+
fix: (i) => T(i, n, A(n, l), u)
|
|
1209
1240
|
});
|
|
1210
1241
|
});
|
|
1211
1242
|
}
|
|
1212
1243
|
};
|
|
1213
1244
|
}
|
|
1214
|
-
}),
|
|
1215
|
-
name:
|
|
1245
|
+
}), se = "sort-imports", Oe = j({
|
|
1246
|
+
name: se,
|
|
1216
1247
|
meta: {
|
|
1217
1248
|
type: "suggestion",
|
|
1218
1249
|
docs: {
|
|
@@ -1221,6 +1252,7 @@ const J = "sort-array-includes", de = O({
|
|
|
1221
1252
|
fixable: "code",
|
|
1222
1253
|
schema: [
|
|
1223
1254
|
{
|
|
1255
|
+
id: "sort-imports",
|
|
1224
1256
|
type: "object",
|
|
1225
1257
|
properties: {
|
|
1226
1258
|
"custom-groups": {
|
|
@@ -1237,16 +1269,16 @@ const J = "sort-array-includes", de = O({
|
|
|
1237
1269
|
},
|
|
1238
1270
|
type: {
|
|
1239
1271
|
enum: [
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1272
|
+
p.alphabetical,
|
|
1273
|
+
p.natural,
|
|
1274
|
+
p["line-length"]
|
|
1243
1275
|
],
|
|
1244
|
-
default:
|
|
1276
|
+
default: p.alphabetical,
|
|
1245
1277
|
type: "string"
|
|
1246
1278
|
},
|
|
1247
1279
|
order: {
|
|
1248
|
-
enum: [
|
|
1249
|
-
default:
|
|
1280
|
+
enum: [d.asc, d.desc],
|
|
1281
|
+
default: d.asc,
|
|
1250
1282
|
type: "string"
|
|
1251
1283
|
},
|
|
1252
1284
|
"ignore-case": {
|
|
@@ -1272,9 +1304,38 @@ const J = "sort-array-includes", de = O({
|
|
|
1272
1304
|
],
|
|
1273
1305
|
default: "always",
|
|
1274
1306
|
type: "string"
|
|
1307
|
+
},
|
|
1308
|
+
"max-line-length": {
|
|
1309
|
+
type: "integer",
|
|
1310
|
+
minimum: 0,
|
|
1311
|
+
exclusiveMinimum: !0
|
|
1275
1312
|
}
|
|
1276
1313
|
},
|
|
1277
|
-
|
|
1314
|
+
allOf: [
|
|
1315
|
+
{ $ref: "#/definitions/max-line-length-requires-line-length-type" }
|
|
1316
|
+
],
|
|
1317
|
+
additionalProperties: !1,
|
|
1318
|
+
dependencies: {
|
|
1319
|
+
"max-line-length": ["type"]
|
|
1320
|
+
},
|
|
1321
|
+
definitions: {
|
|
1322
|
+
"is-line-length": {
|
|
1323
|
+
properties: {
|
|
1324
|
+
type: { enum: [p["line-length"]], type: "string" }
|
|
1325
|
+
},
|
|
1326
|
+
required: ["type"],
|
|
1327
|
+
type: "object"
|
|
1328
|
+
},
|
|
1329
|
+
"max-line-length-requires-line-length-type": {
|
|
1330
|
+
anyOf: [
|
|
1331
|
+
{
|
|
1332
|
+
not: { required: ["max-line-length"], type: "object" },
|
|
1333
|
+
type: "object"
|
|
1334
|
+
},
|
|
1335
|
+
{ $ref: "#/definitions/is-line-length" }
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1278
1339
|
}
|
|
1279
1340
|
],
|
|
1280
1341
|
messages: {
|
|
@@ -1285,31 +1346,31 @@ const J = "sort-array-includes", de = O({
|
|
|
1285
1346
|
},
|
|
1286
1347
|
defaultOptions: [
|
|
1287
1348
|
{
|
|
1288
|
-
type:
|
|
1289
|
-
order:
|
|
1349
|
+
type: p.alphabetical,
|
|
1350
|
+
order: d.asc
|
|
1290
1351
|
}
|
|
1291
1352
|
],
|
|
1292
|
-
create: (
|
|
1293
|
-
let l =
|
|
1353
|
+
create: (r) => {
|
|
1354
|
+
let l = C(r.options.at(0), {
|
|
1294
1355
|
"newlines-between": "always",
|
|
1295
1356
|
"custom-groups": { type: {}, value: {} },
|
|
1296
1357
|
"internal-pattern": ["~/**"],
|
|
1297
|
-
type:
|
|
1298
|
-
order:
|
|
1358
|
+
type: p.alphabetical,
|
|
1359
|
+
order: d.asc,
|
|
1299
1360
|
"ignore-case": !1,
|
|
1300
1361
|
groups: []
|
|
1301
|
-
}),
|
|
1302
|
-
for (let
|
|
1303
|
-
if (Array.isArray(
|
|
1304
|
-
for (let c of
|
|
1305
|
-
c === "unknown" && (
|
|
1362
|
+
}), s = !1;
|
|
1363
|
+
for (let o of l.groups)
|
|
1364
|
+
if (Array.isArray(o))
|
|
1365
|
+
for (let c of o)
|
|
1366
|
+
c === "unknown" && (s = !0);
|
|
1306
1367
|
else
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
let
|
|
1310
|
-
let c = (
|
|
1311
|
-
(
|
|
1312
|
-
),
|
|
1368
|
+
o === "unknown" && (s = !0);
|
|
1369
|
+
s || (l.groups = [...l.groups, "unknown"]);
|
|
1370
|
+
let t = r.getSourceCode(), u = [], n = (o) => o.type === "ImportDeclaration" && o.specifiers.length === 0, e = (o) => {
|
|
1371
|
+
let c = (S) => [".less", ".scss", ".sass", ".styl", ".pcss", ".css", ".sss"].some(
|
|
1372
|
+
(L) => S.endsWith(L)
|
|
1373
|
+
), y = (S) => [
|
|
1313
1374
|
"./index.d.js",
|
|
1314
1375
|
"./index.d.ts",
|
|
1315
1376
|
"./index.js",
|
|
@@ -1317,12 +1378,12 @@ const J = "sort-array-includes", de = O({
|
|
|
1317
1378
|
"./index",
|
|
1318
1379
|
"./",
|
|
1319
1380
|
"."
|
|
1320
|
-
].includes(
|
|
1321
|
-
(
|
|
1381
|
+
].includes(S), h = (S) => S.indexOf("..") === 0, f = (S) => S.indexOf("./") === 0, { getGroup: g, defineGroup: m, setCustomGroups: w } = R(l.groups), E = (S) => l["internal-pattern"].length && l["internal-pattern"].some(
|
|
1382
|
+
(L) => D(S.source.value, L, {
|
|
1322
1383
|
nocomment: !0
|
|
1323
1384
|
})
|
|
1324
|
-
),
|
|
1325
|
-
let
|
|
1385
|
+
), b = (S) => {
|
|
1386
|
+
let L = [
|
|
1326
1387
|
"bun",
|
|
1327
1388
|
"bun:ffi",
|
|
1328
1389
|
"bun:jsc",
|
|
@@ -1333,83 +1394,86 @@ const J = "sort-array-includes", de = O({
|
|
|
1333
1394
|
"undici",
|
|
1334
1395
|
"ws"
|
|
1335
1396
|
];
|
|
1336
|
-
return
|
|
1337
|
-
|
|
1338
|
-
) ||
|
|
1339
|
-
},
|
|
1340
|
-
return
|
|
1341
|
-
}, o = (
|
|
1397
|
+
return de.includes(
|
|
1398
|
+
S.startsWith("node:") ? S.split("node:")[1] : S
|
|
1399
|
+
) || L.includes(S);
|
|
1400
|
+
}, N = (S) => !(S.startsWith(".") || S.startsWith("/"));
|
|
1401
|
+
return o.importKind === "type" && (o.type === "ImportDeclaration" && (w(l["custom-groups"].type, o.source.value), y(o.source.value) && m("index-type"), f(o.source.value) && m("sibling-type"), h(o.source.value) && m("parent-type"), E(o) && m("internal-type"), b(o.source.value) && m("builtin-type"), N(o.source.value) && m("external-type")), m("type")), o.type === "ImportDeclaration" && (w(l["custom-groups"].value, o.source.value), n(o) && m("side-effect"), c(o.source.value) && m("style"), y(o.source.value) && m("index"), f(o.source.value) && m("sibling"), h(o.source.value) && m("parent"), E(o) && m("internal"), b(o.source.value) && m("builtin"), N(o.source.value) && m("external")), g();
|
|
1402
|
+
}, a = (o) => o.specifiers.length > 1, i = (o) => {
|
|
1342
1403
|
let c;
|
|
1343
|
-
|
|
1344
|
-
size: v(
|
|
1345
|
-
group: e(
|
|
1404
|
+
o.type === "ImportDeclaration" ? c = o.source.value : o.moduleReference.type === "TSExternalModuleReference" && o.moduleReference.expression.type === "Literal" ? c = `${o.moduleReference.expression.value}` : c = t.text.slice(...o.moduleReference.range), u.push({
|
|
1405
|
+
size: v(o.range),
|
|
1406
|
+
group: e(o),
|
|
1346
1407
|
name: c,
|
|
1347
|
-
node:
|
|
1408
|
+
node: o,
|
|
1409
|
+
...l.type === p["line-length"] && l["max-line-length"] && {
|
|
1410
|
+
hasMultipleImportDeclarations: a(
|
|
1411
|
+
o
|
|
1412
|
+
)
|
|
1413
|
+
}
|
|
1348
1414
|
});
|
|
1349
1415
|
};
|
|
1350
1416
|
return {
|
|
1351
|
-
TSImportEqualsDeclaration:
|
|
1352
|
-
ImportDeclaration:
|
|
1417
|
+
TSImportEqualsDeclaration: i,
|
|
1418
|
+
ImportDeclaration: i,
|
|
1353
1419
|
"Program:exit": () => {
|
|
1354
|
-
var
|
|
1355
|
-
let
|
|
1356
|
-
|
|
1357
|
-
|
|
1420
|
+
var h;
|
|
1421
|
+
let o = (f, g) => !!t.getTokensBetween(
|
|
1422
|
+
f.node,
|
|
1423
|
+
J(g.node, t) || g.node,
|
|
1358
1424
|
{
|
|
1359
1425
|
includeComments: !0
|
|
1360
1426
|
}
|
|
1361
|
-
).length, c = (
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
let b = x(l.groups, E);
|
|
1368
|
-
b in S ? S[b] = A(
|
|
1369
|
-
[...S[b], E],
|
|
1427
|
+
).length, c = (f, g) => {
|
|
1428
|
+
let m = [], w = {};
|
|
1429
|
+
for (let b of g) {
|
|
1430
|
+
let N = x(l.groups, b);
|
|
1431
|
+
N in w ? w[N] = A(
|
|
1432
|
+
[...w[N], b],
|
|
1370
1433
|
l
|
|
1371
|
-
) :
|
|
1434
|
+
) : w[N] = [b];
|
|
1372
1435
|
}
|
|
1373
|
-
let
|
|
1374
|
-
(
|
|
1375
|
-
...
|
|
1376
|
-
...
|
|
1436
|
+
let E = Object.keys(w).sort().reduce(
|
|
1437
|
+
(b, N) => [
|
|
1438
|
+
...b,
|
|
1439
|
+
...w[N]
|
|
1377
1440
|
],
|
|
1378
1441
|
[]
|
|
1379
1442
|
);
|
|
1380
|
-
for (let
|
|
1381
|
-
let
|
|
1382
|
-
if (
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1443
|
+
for (let b = 0, N = E.length; b < N; b++) {
|
|
1444
|
+
let S = E.at(b);
|
|
1445
|
+
if (m.push(
|
|
1446
|
+
f.replaceTextRange(
|
|
1447
|
+
M(g.at(b).node, t),
|
|
1448
|
+
t.text.slice(...M(S.node, t))
|
|
1386
1449
|
)
|
|
1387
1450
|
), l["newlines-between"] !== "ignore") {
|
|
1388
|
-
let L =
|
|
1451
|
+
let L = E.at(b + 1);
|
|
1389
1452
|
if (L) {
|
|
1390
|
-
let
|
|
1391
|
-
|
|
1392
|
-
|
|
1453
|
+
let G = B(
|
|
1454
|
+
t,
|
|
1455
|
+
g.at(b),
|
|
1456
|
+
g.at(b + 1)
|
|
1393
1457
|
);
|
|
1394
|
-
(l["newlines-between"] === "always" && x(l.groups,
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1458
|
+
(l["newlines-between"] === "always" && x(l.groups, S) === x(l.groups, L) && G !== 0 || l["newlines-between"] === "never" && G > 0) && m.push(
|
|
1459
|
+
f.removeRange([
|
|
1460
|
+
M(g.at(b).node, t).at(1),
|
|
1461
|
+
M(g.at(b + 1).node, t).at(0) - 1
|
|
1398
1462
|
])
|
|
1399
|
-
), l["newlines-between"] === "always" && x(l.groups,
|
|
1400
|
-
|
|
1463
|
+
), l["newlines-between"] === "always" && x(l.groups, S) !== x(l.groups, L) && G > 1 && m.push(
|
|
1464
|
+
f.replaceTextRange(
|
|
1401
1465
|
[
|
|
1402
|
-
|
|
1403
|
-
|
|
1466
|
+
M(g.at(b).node, t).at(1),
|
|
1467
|
+
M(g.at(b + 1).node, t).at(
|
|
1404
1468
|
0
|
|
1405
1469
|
) - 1
|
|
1406
1470
|
],
|
|
1407
1471
|
`
|
|
1408
1472
|
`
|
|
1409
1473
|
)
|
|
1410
|
-
), l["newlines-between"] === "always" && x(l.groups,
|
|
1411
|
-
|
|
1412
|
-
|
|
1474
|
+
), l["newlines-between"] === "always" && x(l.groups, S) !== x(l.groups, L) && G === 0 && m.push(
|
|
1475
|
+
f.insertTextAfterRange(
|
|
1476
|
+
M(g.at(b).node, t),
|
|
1413
1477
|
`
|
|
1414
1478
|
`
|
|
1415
1479
|
)
|
|
@@ -1417,54 +1481,54 @@ const J = "sort-array-includes", de = O({
|
|
|
1417
1481
|
}
|
|
1418
1482
|
}
|
|
1419
1483
|
}
|
|
1420
|
-
return
|
|
1484
|
+
return m;
|
|
1421
1485
|
}, y = [[]];
|
|
1422
|
-
for (let
|
|
1423
|
-
let
|
|
1424
|
-
|
|
1486
|
+
for (let f of u) {
|
|
1487
|
+
let g = (h = y.at(-1)) == null ? void 0 : h.at(-1);
|
|
1488
|
+
g && o(g, f) ? y.push([f]) : y.at(-1).push(f);
|
|
1425
1489
|
}
|
|
1426
|
-
for (let
|
|
1427
|
-
|
|
1428
|
-
let
|
|
1429
|
-
!(
|
|
1490
|
+
for (let f of y)
|
|
1491
|
+
P(f, (g, m) => {
|
|
1492
|
+
let w = x(l.groups, g), E = x(l.groups, m), b = B(t, g, m);
|
|
1493
|
+
!(n(g.node) && n(m.node)) && !o(g, m) && (w > E || w === E && k(O(g, m, l))) && r.report({
|
|
1430
1494
|
messageId: "unexpectedImportsOrder",
|
|
1431
1495
|
data: {
|
|
1432
|
-
left:
|
|
1433
|
-
right:
|
|
1496
|
+
left: g.name,
|
|
1497
|
+
right: m.name
|
|
1434
1498
|
},
|
|
1435
|
-
node:
|
|
1436
|
-
fix: (
|
|
1437
|
-
}), l["newlines-between"] === "never" &&
|
|
1499
|
+
node: m.node,
|
|
1500
|
+
fix: (N) => c(N, f)
|
|
1501
|
+
}), l["newlines-between"] === "never" && b > 0 && r.report({
|
|
1438
1502
|
messageId: "extraSpacingBetweenImports",
|
|
1439
1503
|
data: {
|
|
1440
|
-
left:
|
|
1441
|
-
right:
|
|
1504
|
+
left: g.name,
|
|
1505
|
+
right: m.name
|
|
1442
1506
|
},
|
|
1443
|
-
node:
|
|
1444
|
-
fix: (
|
|
1445
|
-
}), l["newlines-between"] === "always" && (
|
|
1507
|
+
node: m.node,
|
|
1508
|
+
fix: (N) => c(N, f)
|
|
1509
|
+
}), l["newlines-between"] === "always" && (w < E && b === 0 ? r.report({
|
|
1446
1510
|
messageId: "missedSpacingBetweenImports",
|
|
1447
1511
|
data: {
|
|
1448
|
-
left:
|
|
1449
|
-
right:
|
|
1512
|
+
left: g.name,
|
|
1513
|
+
right: m.name
|
|
1450
1514
|
},
|
|
1451
|
-
node:
|
|
1452
|
-
fix: (
|
|
1453
|
-
}) : (
|
|
1515
|
+
node: m.node,
|
|
1516
|
+
fix: (N) => c(N, f)
|
|
1517
|
+
}) : (b > 1 || w === E && b > 0) && r.report({
|
|
1454
1518
|
messageId: "extraSpacingBetweenImports",
|
|
1455
1519
|
data: {
|
|
1456
|
-
left:
|
|
1457
|
-
right:
|
|
1520
|
+
left: g.name,
|
|
1521
|
+
right: m.name
|
|
1458
1522
|
},
|
|
1459
|
-
node:
|
|
1460
|
-
fix: (
|
|
1523
|
+
node: m.node,
|
|
1524
|
+
fix: (N) => c(N, f)
|
|
1461
1525
|
}));
|
|
1462
1526
|
});
|
|
1463
1527
|
}
|
|
1464
1528
|
};
|
|
1465
1529
|
}
|
|
1466
|
-
}),
|
|
1467
|
-
name:
|
|
1530
|
+
}), ae = "sort-objects", Ie = j({
|
|
1531
|
+
name: ae,
|
|
1468
1532
|
meta: {
|
|
1469
1533
|
type: "suggestion",
|
|
1470
1534
|
docs: {
|
|
@@ -1482,22 +1546,26 @@ const J = "sort-array-includes", de = O({
|
|
|
1482
1546
|
type: ["boolean", "string", "array"],
|
|
1483
1547
|
default: !1
|
|
1484
1548
|
},
|
|
1549
|
+
"partition-by-new-line": {
|
|
1550
|
+
type: "boolean",
|
|
1551
|
+
default: !1
|
|
1552
|
+
},
|
|
1485
1553
|
"styled-components": {
|
|
1486
1554
|
type: "boolean",
|
|
1487
1555
|
default: !0
|
|
1488
1556
|
},
|
|
1489
1557
|
type: {
|
|
1490
1558
|
enum: [
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1559
|
+
p.alphabetical,
|
|
1560
|
+
p.natural,
|
|
1561
|
+
p["line-length"]
|
|
1494
1562
|
],
|
|
1495
|
-
default:
|
|
1563
|
+
default: p.alphabetical,
|
|
1496
1564
|
type: "string"
|
|
1497
1565
|
},
|
|
1498
1566
|
order: {
|
|
1499
|
-
enum: [
|
|
1500
|
-
default:
|
|
1567
|
+
enum: [d.asc, d.desc],
|
|
1568
|
+
default: d.asc,
|
|
1501
1569
|
type: "string"
|
|
1502
1570
|
},
|
|
1503
1571
|
"ignore-case": {
|
|
@@ -1517,107 +1585,113 @@ const J = "sort-array-includes", de = O({
|
|
|
1517
1585
|
},
|
|
1518
1586
|
defaultOptions: [
|
|
1519
1587
|
{
|
|
1520
|
-
type:
|
|
1521
|
-
order:
|
|
1588
|
+
type: p.alphabetical,
|
|
1589
|
+
order: d.asc
|
|
1522
1590
|
}
|
|
1523
1591
|
],
|
|
1524
|
-
create: (
|
|
1525
|
-
let l = (
|
|
1526
|
-
if (
|
|
1527
|
-
let
|
|
1592
|
+
create: (r) => {
|
|
1593
|
+
let l = (s) => {
|
|
1594
|
+
if (s.properties.length > 1) {
|
|
1595
|
+
let t = C(r.options.at(0), {
|
|
1596
|
+
"partition-by-new-line": !1,
|
|
1528
1597
|
"partition-by-comment": !1,
|
|
1529
|
-
type:
|
|
1598
|
+
type: p.alphabetical,
|
|
1530
1599
|
"styled-components": !0,
|
|
1531
1600
|
"ignore-case": !1,
|
|
1532
|
-
order:
|
|
1601
|
+
order: d.asc,
|
|
1533
1602
|
"custom-groups": {},
|
|
1534
1603
|
groups: []
|
|
1535
|
-
}), u = (
|
|
1536
|
-
if (!
|
|
1604
|
+
}), u = (i) => i.type === "Identifier" && i.name === "styled", n = (i) => i !== void 0 && i.type === "CallExpression" && (i.callee.type === "MemberExpression" && u(i.callee.object) || i.callee.type === "CallExpression" && u(i.callee.callee));
|
|
1605
|
+
if (!t["styled-components"] && (n(s.parent) || s.parent.type === "ArrowFunctionExpression" && n(s.parent.parent)))
|
|
1537
1606
|
return;
|
|
1538
|
-
let e =
|
|
1539
|
-
(
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1607
|
+
let e = r.getSourceCode(), a = (i) => i.reduce(
|
|
1608
|
+
(o, c) => {
|
|
1609
|
+
var S;
|
|
1610
|
+
if (c.type === "SpreadElement" || c.type === "RestElement")
|
|
1611
|
+
return o.push([]), o;
|
|
1612
|
+
let y = J(c, e), h = (S = o.at(-1)) == null ? void 0 : S.at(-1);
|
|
1613
|
+
t["partition-by-comment"] && y && pe(
|
|
1614
|
+
t["partition-by-comment"],
|
|
1545
1615
|
y.value
|
|
1546
|
-
) &&
|
|
1547
|
-
let
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1616
|
+
) && o.push([]);
|
|
1617
|
+
let f, g = "ignore", m = [], { getGroup: w, setCustomGroups: E } = R(t.groups);
|
|
1618
|
+
c.key.type === "Identifier" ? { name: f } = c.key : c.key.type === "Literal" ? f = `${c.key.value}` : f = e.text.slice(...c.key.range);
|
|
1619
|
+
let b = {
|
|
1620
|
+
size: v(c.range),
|
|
1621
|
+
node: c,
|
|
1622
|
+
name: f
|
|
1623
|
+
};
|
|
1624
|
+
t["partition-by-new-line"] && h && B(e, h, b) && o.push([]), c.value.type === "AssignmentPattern" && ((G) => {
|
|
1625
|
+
G.right.type === "Identifier" && m.push(G.right.name);
|
|
1626
|
+
let ie = ($) => {
|
|
1627
|
+
let U = [];
|
|
1628
|
+
switch ($.type) {
|
|
1553
1629
|
case "ArrowFunctionExpression":
|
|
1554
|
-
|
|
1630
|
+
U.push($.body);
|
|
1555
1631
|
break;
|
|
1556
1632
|
case "ConditionalExpression":
|
|
1557
|
-
|
|
1633
|
+
U.push($.consequent, $.alternate);
|
|
1558
1634
|
break;
|
|
1559
1635
|
case "LogicalExpression":
|
|
1560
1636
|
case "BinaryExpression":
|
|
1561
|
-
|
|
1637
|
+
U.push($.left, $.right);
|
|
1562
1638
|
break;
|
|
1563
1639
|
case "CallExpression":
|
|
1564
|
-
|
|
1640
|
+
U.push(...$.arguments);
|
|
1565
1641
|
break;
|
|
1566
1642
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1643
|
+
U.forEach((z) => {
|
|
1644
|
+
z.type === "Identifier" && m.push(z.name), (z.type === "BinaryExpression" || z.type === "ConditionalExpression") && ie(z);
|
|
1569
1645
|
});
|
|
1570
1646
|
};
|
|
1571
|
-
switch (
|
|
1647
|
+
switch (G.right.type) {
|
|
1572
1648
|
case "ArrowFunctionExpression":
|
|
1573
1649
|
case "ConditionalExpression":
|
|
1574
1650
|
case "LogicalExpression":
|
|
1575
1651
|
case "BinaryExpression":
|
|
1576
1652
|
case "CallExpression":
|
|
1577
|
-
|
|
1653
|
+
ie(G.right);
|
|
1578
1654
|
break;
|
|
1579
1655
|
}
|
|
1580
|
-
})(
|
|
1656
|
+
})(c.value), E(t["custom-groups"], f);
|
|
1581
1657
|
let N = {
|
|
1582
|
-
|
|
1583
|
-
group:
|
|
1584
|
-
dependencies:
|
|
1585
|
-
|
|
1586
|
-
position: g,
|
|
1587
|
-
name: m
|
|
1658
|
+
...b,
|
|
1659
|
+
group: w(),
|
|
1660
|
+
dependencies: m,
|
|
1661
|
+
position: g
|
|
1588
1662
|
};
|
|
1589
|
-
return
|
|
1663
|
+
return o.at(-1).push(N), o;
|
|
1590
1664
|
},
|
|
1591
1665
|
[[]]
|
|
1592
1666
|
);
|
|
1593
|
-
for (let
|
|
1594
|
-
|
|
1595
|
-
let y = x(
|
|
1596
|
-
if (y >
|
|
1597
|
-
let
|
|
1598
|
-
let
|
|
1599
|
-
for (let
|
|
1600
|
-
let
|
|
1601
|
-
|
|
1602
|
-
[...
|
|
1603
|
-
|
|
1604
|
-
) :
|
|
1667
|
+
for (let i of a(s.properties))
|
|
1668
|
+
P(i, (o, c) => {
|
|
1669
|
+
let y = x(t.groups, o), h = x(t.groups, c);
|
|
1670
|
+
if (y > h || y === h && k(O(o, c, t))) {
|
|
1671
|
+
let f = (g) => {
|
|
1672
|
+
let m = {};
|
|
1673
|
+
for (let E of i) {
|
|
1674
|
+
let b = x(t.groups, E);
|
|
1675
|
+
b in m ? m[b] = A(
|
|
1676
|
+
[...m[b], E],
|
|
1677
|
+
t
|
|
1678
|
+
) : m[b] = [E];
|
|
1605
1679
|
}
|
|
1606
|
-
let
|
|
1607
|
-
for (let
|
|
1608
|
-
|
|
1609
|
-
return
|
|
1610
|
-
partitionComment:
|
|
1680
|
+
let w = [];
|
|
1681
|
+
for (let E of Object.keys(m).sort())
|
|
1682
|
+
w.push(...A(m[E], t));
|
|
1683
|
+
return T(g, i, w, e, {
|
|
1684
|
+
partitionComment: t["partition-by-comment"]
|
|
1611
1685
|
});
|
|
1612
1686
|
};
|
|
1613
|
-
|
|
1687
|
+
r.report({
|
|
1614
1688
|
messageId: "unexpectedObjectsOrder",
|
|
1615
1689
|
data: {
|
|
1616
|
-
left: I(
|
|
1617
|
-
right: I(
|
|
1690
|
+
left: I(o.name),
|
|
1691
|
+
right: I(c.name)
|
|
1618
1692
|
},
|
|
1619
|
-
node:
|
|
1620
|
-
fix:
|
|
1693
|
+
node: c.node,
|
|
1694
|
+
fix: f
|
|
1621
1695
|
});
|
|
1622
1696
|
}
|
|
1623
1697
|
});
|
|
@@ -1628,8 +1702,8 @@ const J = "sort-array-includes", de = O({
|
|
|
1628
1702
|
ObjectPattern: l
|
|
1629
1703
|
};
|
|
1630
1704
|
}
|
|
1631
|
-
}),
|
|
1632
|
-
name:
|
|
1705
|
+
}), ne = "sort-classes", je = j({
|
|
1706
|
+
name: ne,
|
|
1633
1707
|
meta: {
|
|
1634
1708
|
type: "suggestion",
|
|
1635
1709
|
docs: {
|
|
@@ -1642,11 +1716,11 @@ const J = "sort-array-includes", de = O({
|
|
|
1642
1716
|
properties: {
|
|
1643
1717
|
type: {
|
|
1644
1718
|
enum: [
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1719
|
+
p.alphabetical,
|
|
1720
|
+
p.natural,
|
|
1721
|
+
p["line-length"]
|
|
1648
1722
|
],
|
|
1649
|
-
default:
|
|
1723
|
+
default: p.alphabetical,
|
|
1650
1724
|
type: "string"
|
|
1651
1725
|
},
|
|
1652
1726
|
"ignore-case": {
|
|
@@ -1654,8 +1728,8 @@ const J = "sort-array-includes", de = O({
|
|
|
1654
1728
|
default: !1
|
|
1655
1729
|
},
|
|
1656
1730
|
order: {
|
|
1657
|
-
enum: [
|
|
1658
|
-
default:
|
|
1731
|
+
enum: [d.asc, d.desc],
|
|
1732
|
+
default: d.asc,
|
|
1659
1733
|
type: "string"
|
|
1660
1734
|
},
|
|
1661
1735
|
groups: {
|
|
@@ -1672,83 +1746,83 @@ const J = "sort-array-includes", de = O({
|
|
|
1672
1746
|
},
|
|
1673
1747
|
defaultOptions: [
|
|
1674
1748
|
{
|
|
1675
|
-
type:
|
|
1676
|
-
order:
|
|
1749
|
+
type: p.alphabetical,
|
|
1750
|
+
order: d.asc
|
|
1677
1751
|
}
|
|
1678
1752
|
],
|
|
1679
|
-
create: (
|
|
1753
|
+
create: (r) => ({
|
|
1680
1754
|
ClassBody: (l) => {
|
|
1681
1755
|
if (l.body.length > 1) {
|
|
1682
|
-
let
|
|
1683
|
-
type:
|
|
1684
|
-
order:
|
|
1756
|
+
let s = C(r.options.at(0), {
|
|
1757
|
+
type: p.alphabetical,
|
|
1758
|
+
order: d.asc,
|
|
1685
1759
|
"ignore-case": !1,
|
|
1686
1760
|
groups: ["property", "constructor", "method", "unknown"]
|
|
1687
|
-
}),
|
|
1688
|
-
var
|
|
1689
|
-
let e, { getGroup:
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
((
|
|
1693
|
-
) :
|
|
1694
|
-
let
|
|
1695
|
-
if (
|
|
1696
|
-
|
|
1697
|
-
let y =
|
|
1698
|
-
y &&
|
|
1761
|
+
}), t = r.getSourceCode(), u = l.body.map((n) => {
|
|
1762
|
+
var c;
|
|
1763
|
+
let e, { getGroup: a, defineGroup: i } = R(s.groups);
|
|
1764
|
+
n.type === "StaticBlock" ? e = "static" : n.type === "TSIndexSignature" ? e = t.text.slice(
|
|
1765
|
+
n.range.at(0),
|
|
1766
|
+
((c = n.typeAnnotation) == null ? void 0 : c.range.at(0)) ?? n.range.at(1)
|
|
1767
|
+
) : n.key.type === "Identifier" ? { name: e } = n.key : e = t.text.slice(...n.key.range);
|
|
1768
|
+
let o = e.startsWith("_") || e.startsWith("#");
|
|
1769
|
+
if (n.type === "MethodDefinition") {
|
|
1770
|
+
n.kind === "constructor" && i("constructor");
|
|
1771
|
+
let y = n.accessibility === "private" || o, h = n.static;
|
|
1772
|
+
y && h && i("static-private-method"), y && i("private-method"), h && i("static-method"), n.kind === "get" && i("get-method"), n.kind === "set" && i("set-method"), i("method");
|
|
1699
1773
|
} else
|
|
1700
|
-
|
|
1774
|
+
n.type === "TSIndexSignature" ? i("index-signature") : n.type === "PropertyDefinition" && ((n.accessibility === "private" || o) && i("private-property"), n.static && i("static-property"), i("property"));
|
|
1701
1775
|
return {
|
|
1702
|
-
size: v(
|
|
1703
|
-
group:
|
|
1704
|
-
node:
|
|
1776
|
+
size: v(n.range),
|
|
1777
|
+
group: a(),
|
|
1778
|
+
node: n,
|
|
1705
1779
|
name: e
|
|
1706
1780
|
};
|
|
1707
1781
|
});
|
|
1708
|
-
|
|
1709
|
-
let
|
|
1710
|
-
|
|
1782
|
+
P(u, (n, e) => {
|
|
1783
|
+
let a = x(s.groups, n), i = x(s.groups, e);
|
|
1784
|
+
n.name !== e.name && (a > i || a === i && k(O(n, e, s))) && r.report({
|
|
1711
1785
|
messageId: "unexpectedClassesOrder",
|
|
1712
1786
|
data: {
|
|
1713
|
-
left: I(
|
|
1787
|
+
left: I(n.name),
|
|
1714
1788
|
right: I(e.name)
|
|
1715
1789
|
},
|
|
1716
1790
|
node: e.node,
|
|
1717
|
-
fix: (
|
|
1718
|
-
let
|
|
1719
|
-
(
|
|
1720
|
-
let
|
|
1721
|
-
return
|
|
1722
|
-
[...
|
|
1723
|
-
|
|
1724
|
-
) :
|
|
1791
|
+
fix: (o) => {
|
|
1792
|
+
let c = [], y = u.reduce(
|
|
1793
|
+
(f, g) => {
|
|
1794
|
+
let m = x(s.groups, g);
|
|
1795
|
+
return m in f ? f[m] = A(
|
|
1796
|
+
[...f[m], g],
|
|
1797
|
+
s
|
|
1798
|
+
) : f[m] = [g], f;
|
|
1725
1799
|
},
|
|
1726
1800
|
{}
|
|
1727
|
-
),
|
|
1728
|
-
(
|
|
1729
|
-
...
|
|
1730
|
-
...y[
|
|
1801
|
+
), h = Object.keys(y).sort().reduce(
|
|
1802
|
+
(f, g) => [
|
|
1803
|
+
...f,
|
|
1804
|
+
...y[g]
|
|
1731
1805
|
],
|
|
1732
1806
|
[]
|
|
1733
1807
|
);
|
|
1734
|
-
for (let
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
...
|
|
1808
|
+
for (let f = 0, g = h.length; f < g; f++)
|
|
1809
|
+
c.push(
|
|
1810
|
+
o.replaceTextRange(
|
|
1811
|
+
M(u.at(f).node, t),
|
|
1812
|
+
t.text.slice(
|
|
1813
|
+
...M(h.at(f).node, t)
|
|
1740
1814
|
)
|
|
1741
1815
|
)
|
|
1742
1816
|
);
|
|
1743
|
-
return
|
|
1817
|
+
return c;
|
|
1744
1818
|
}
|
|
1745
1819
|
});
|
|
1746
1820
|
});
|
|
1747
1821
|
}
|
|
1748
1822
|
}
|
|
1749
1823
|
})
|
|
1750
|
-
}),
|
|
1751
|
-
name:
|
|
1824
|
+
}), oe = "sort-enums", ve = j({
|
|
1825
|
+
name: oe,
|
|
1752
1826
|
meta: {
|
|
1753
1827
|
type: "suggestion",
|
|
1754
1828
|
docs: {
|
|
@@ -1761,11 +1835,11 @@ const J = "sort-array-includes", de = O({
|
|
|
1761
1835
|
properties: {
|
|
1762
1836
|
type: {
|
|
1763
1837
|
enum: [
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1838
|
+
p.alphabetical,
|
|
1839
|
+
p.natural,
|
|
1840
|
+
p["line-length"]
|
|
1767
1841
|
],
|
|
1768
|
-
default:
|
|
1842
|
+
default: p.alphabetical,
|
|
1769
1843
|
type: "string"
|
|
1770
1844
|
},
|
|
1771
1845
|
"ignore-case": {
|
|
@@ -1773,8 +1847,8 @@ const J = "sort-array-includes", de = O({
|
|
|
1773
1847
|
default: !1
|
|
1774
1848
|
},
|
|
1775
1849
|
order: {
|
|
1776
|
-
enum: [
|
|
1777
|
-
default:
|
|
1850
|
+
enum: [d.asc, d.desc],
|
|
1851
|
+
default: d.asc,
|
|
1778
1852
|
type: "string"
|
|
1779
1853
|
}
|
|
1780
1854
|
},
|
|
@@ -1787,38 +1861,38 @@ const J = "sort-array-includes", de = O({
|
|
|
1787
1861
|
},
|
|
1788
1862
|
defaultOptions: [
|
|
1789
1863
|
{
|
|
1790
|
-
type:
|
|
1791
|
-
order:
|
|
1864
|
+
type: p.alphabetical,
|
|
1865
|
+
order: d.asc
|
|
1792
1866
|
}
|
|
1793
1867
|
],
|
|
1794
|
-
create: (
|
|
1868
|
+
create: (r) => ({
|
|
1795
1869
|
TSEnumDeclaration: (l) => {
|
|
1796
|
-
if (l.members.length > 1 && l.members.every(({ initializer:
|
|
1797
|
-
let
|
|
1798
|
-
type:
|
|
1799
|
-
order:
|
|
1870
|
+
if (l.members.length > 1 && l.members.every(({ initializer: s }) => s)) {
|
|
1871
|
+
let s = C(r.options.at(0), {
|
|
1872
|
+
type: p.alphabetical,
|
|
1873
|
+
order: d.asc,
|
|
1800
1874
|
"ignore-case": !1
|
|
1801
|
-
}),
|
|
1802
|
-
name:
|
|
1803
|
-
size: v(
|
|
1804
|
-
node:
|
|
1875
|
+
}), t = r.getSourceCode(), u = l.members.map((n) => ({
|
|
1876
|
+
name: n.id.type === "Literal" ? `${n.id.value}` : `${t.text.slice(...n.id.range)}`,
|
|
1877
|
+
size: v(n.range),
|
|
1878
|
+
node: n
|
|
1805
1879
|
}));
|
|
1806
|
-
|
|
1807
|
-
|
|
1880
|
+
P(u, (n, e) => {
|
|
1881
|
+
k(O(n, e, s)) && r.report({
|
|
1808
1882
|
messageId: "unexpectedEnumsOrder",
|
|
1809
1883
|
data: {
|
|
1810
|
-
left: I(
|
|
1884
|
+
left: I(n.name),
|
|
1811
1885
|
right: I(e.name)
|
|
1812
1886
|
},
|
|
1813
1887
|
node: e.node,
|
|
1814
|
-
fix: (
|
|
1888
|
+
fix: (a) => T(a, u, A(u, s), t)
|
|
1815
1889
|
});
|
|
1816
1890
|
});
|
|
1817
1891
|
}
|
|
1818
1892
|
}
|
|
1819
1893
|
})
|
|
1820
|
-
}),
|
|
1821
|
-
name:
|
|
1894
|
+
}), le = "sort-maps", ke = j({
|
|
1895
|
+
name: le,
|
|
1822
1896
|
meta: {
|
|
1823
1897
|
type: "suggestion",
|
|
1824
1898
|
docs: {
|
|
@@ -1831,16 +1905,16 @@ const J = "sort-array-includes", de = O({
|
|
|
1831
1905
|
properties: {
|
|
1832
1906
|
type: {
|
|
1833
1907
|
enum: [
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1908
|
+
p.alphabetical,
|
|
1909
|
+
p.natural,
|
|
1910
|
+
p["line-length"]
|
|
1837
1911
|
],
|
|
1838
|
-
default:
|
|
1912
|
+
default: p.alphabetical,
|
|
1839
1913
|
type: "string"
|
|
1840
1914
|
},
|
|
1841
1915
|
order: {
|
|
1842
|
-
enum: [
|
|
1843
|
-
default:
|
|
1916
|
+
enum: [d.asc, d.desc],
|
|
1917
|
+
default: d.asc,
|
|
1844
1918
|
type: "string"
|
|
1845
1919
|
},
|
|
1846
1920
|
"ignore-case": {
|
|
@@ -1857,46 +1931,46 @@ const J = "sort-array-includes", de = O({
|
|
|
1857
1931
|
},
|
|
1858
1932
|
defaultOptions: [
|
|
1859
1933
|
{
|
|
1860
|
-
type:
|
|
1861
|
-
order:
|
|
1934
|
+
type: p.alphabetical,
|
|
1935
|
+
order: d.asc
|
|
1862
1936
|
}
|
|
1863
1937
|
],
|
|
1864
|
-
create: (
|
|
1938
|
+
create: (r) => ({
|
|
1865
1939
|
NewExpression: (l) => {
|
|
1866
1940
|
if (l.callee.type === "Identifier" && l.callee.name === "Map" && l.arguments.length && l.arguments[0].type === "ArrayExpression") {
|
|
1867
|
-
let [{ elements:
|
|
1868
|
-
if (
|
|
1869
|
-
let
|
|
1870
|
-
type:
|
|
1941
|
+
let [{ elements: s }] = l.arguments;
|
|
1942
|
+
if (s.length > 1) {
|
|
1943
|
+
let t = C(r.options.at(0), {
|
|
1944
|
+
type: p.alphabetical,
|
|
1871
1945
|
"ignore-case": !1,
|
|
1872
|
-
order:
|
|
1873
|
-
}), u =
|
|
1874
|
-
(e,
|
|
1946
|
+
order: d.asc
|
|
1947
|
+
}), u = r.getSourceCode(), n = s.reduce(
|
|
1948
|
+
(e, a) => (a === null || a.type === "SpreadElement" ? e.push([]) : e.at(-1).push(a), e),
|
|
1875
1949
|
[[]]
|
|
1876
1950
|
);
|
|
1877
|
-
for (let e of
|
|
1878
|
-
let
|
|
1879
|
-
let
|
|
1880
|
-
if (
|
|
1881
|
-
let [
|
|
1882
|
-
|
|
1951
|
+
for (let e of n) {
|
|
1952
|
+
let a = e.map((i) => {
|
|
1953
|
+
let o;
|
|
1954
|
+
if (i.type === "ArrayExpression") {
|
|
1955
|
+
let [c] = i.elements;
|
|
1956
|
+
c ? c.type === "Literal" ? o = c.raw : o = u.text.slice(...c.range) : o = `${c}`;
|
|
1883
1957
|
} else
|
|
1884
|
-
|
|
1958
|
+
o = u.text.slice(...i.range);
|
|
1885
1959
|
return {
|
|
1886
|
-
size: v(
|
|
1887
|
-
node:
|
|
1888
|
-
name:
|
|
1960
|
+
size: v(i.range),
|
|
1961
|
+
node: i,
|
|
1962
|
+
name: o
|
|
1889
1963
|
};
|
|
1890
1964
|
});
|
|
1891
|
-
|
|
1892
|
-
|
|
1965
|
+
P(a, (i, o) => {
|
|
1966
|
+
k(O(i, o, t)) && r.report({
|
|
1893
1967
|
messageId: "unexpectedMapElementsOrder",
|
|
1894
1968
|
data: {
|
|
1895
|
-
left: I(
|
|
1896
|
-
right: I(
|
|
1969
|
+
left: I(i.name),
|
|
1970
|
+
right: I(o.name)
|
|
1897
1971
|
},
|
|
1898
|
-
node:
|
|
1899
|
-
fix: (
|
|
1972
|
+
node: o.node,
|
|
1973
|
+
fix: (c) => T(c, a, A(a, t), u)
|
|
1900
1974
|
});
|
|
1901
1975
|
});
|
|
1902
1976
|
}
|
|
@@ -1904,10 +1978,10 @@ const J = "sort-array-includes", de = O({
|
|
|
1904
1978
|
}
|
|
1905
1979
|
}
|
|
1906
1980
|
})
|
|
1907
|
-
}),
|
|
1908
|
-
let
|
|
1981
|
+
}), Ce = "eslint-plugin-perfectionist";
|
|
1982
|
+
let V = (r) => {
|
|
1909
1983
|
let l = {
|
|
1910
|
-
[
|
|
1984
|
+
[se]: [
|
|
1911
1985
|
"error",
|
|
1912
1986
|
{
|
|
1913
1987
|
groups: [
|
|
@@ -1928,7 +2002,7 @@ let z = (s) => {
|
|
|
1928
2002
|
"internal-pattern": ["~/**"]
|
|
1929
2003
|
}
|
|
1930
2004
|
],
|
|
1931
|
-
[
|
|
2005
|
+
[ne]: [
|
|
1932
2006
|
"error",
|
|
1933
2007
|
{
|
|
1934
2008
|
groups: [
|
|
@@ -1945,78 +2019,78 @@ let z = (s) => {
|
|
|
1945
2019
|
]
|
|
1946
2020
|
}
|
|
1947
2021
|
],
|
|
1948
|
-
[
|
|
2022
|
+
[ae]: [
|
|
1949
2023
|
"error",
|
|
1950
2024
|
{
|
|
1951
2025
|
"partition-by-comment": !1
|
|
1952
2026
|
}
|
|
1953
2027
|
],
|
|
1954
|
-
[
|
|
2028
|
+
[K]: [
|
|
1955
2029
|
"error",
|
|
1956
2030
|
{
|
|
1957
2031
|
"spread-last": !0
|
|
1958
2032
|
}
|
|
1959
2033
|
],
|
|
1960
|
-
[W]: ["error"],
|
|
1961
|
-
[V]: ["error"],
|
|
1962
2034
|
[X]: ["error"],
|
|
1963
|
-
[K]: ["error"],
|
|
1964
2035
|
[q]: ["error"],
|
|
1965
2036
|
[F]: ["error"],
|
|
1966
2037
|
[H]: ["error"],
|
|
1967
2038
|
[Q]: ["error"],
|
|
1968
2039
|
[Y]: ["error"],
|
|
1969
2040
|
[Z]: ["error"],
|
|
1970
|
-
[
|
|
1971
|
-
[
|
|
2041
|
+
[ee]: ["error"],
|
|
2042
|
+
[te]: ["error"],
|
|
2043
|
+
[re]: ["error"],
|
|
2044
|
+
[oe]: ["error"],
|
|
2045
|
+
[le]: ["error"]
|
|
1972
2046
|
};
|
|
1973
2047
|
return {
|
|
1974
2048
|
rules: Object.fromEntries(
|
|
1975
|
-
Object.entries(l).map(([
|
|
1976
|
-
`perfectionist/${
|
|
1977
|
-
[
|
|
2049
|
+
Object.entries(l).map(([s, [t, u = {}]]) => [
|
|
2050
|
+
`perfectionist/${s}`,
|
|
2051
|
+
[t, Object.assign(u, r)]
|
|
1978
2052
|
])
|
|
1979
2053
|
),
|
|
1980
2054
|
plugins: ["perfectionist"]
|
|
1981
2055
|
};
|
|
1982
2056
|
};
|
|
1983
|
-
const
|
|
2057
|
+
const Re = {
|
|
1984
2058
|
rules: {
|
|
1985
|
-
[
|
|
1986
|
-
[V]: ce,
|
|
1987
|
-
[re]: Ne,
|
|
1988
|
-
[se]: we,
|
|
1989
|
-
[Z]: Ee,
|
|
1990
|
-
[ee]: Se,
|
|
1991
|
-
[Q]: be,
|
|
1992
|
-
[Y]: xe,
|
|
1993
|
-
[ae]: Ie,
|
|
1994
|
-
[K]: ge,
|
|
2059
|
+
[K]: me,
|
|
1995
2060
|
[q]: ye,
|
|
1996
|
-
[
|
|
2061
|
+
[ne]: je,
|
|
2062
|
+
[oe]: ve,
|
|
2063
|
+
[re]: Ne,
|
|
2064
|
+
[se]: Oe,
|
|
2065
|
+
[ee]: we,
|
|
1997
2066
|
[te]: Ae,
|
|
1998
|
-
[
|
|
1999
|
-
[H]:
|
|
2000
|
-
[
|
|
2067
|
+
[le]: ke,
|
|
2068
|
+
[H]: be,
|
|
2069
|
+
[Q]: xe,
|
|
2070
|
+
[Y]: Ee,
|
|
2071
|
+
[ae]: Ie,
|
|
2072
|
+
[X]: ge,
|
|
2073
|
+
[Z]: Se,
|
|
2074
|
+
[F]: he
|
|
2001
2075
|
},
|
|
2002
2076
|
configs: {
|
|
2003
|
-
"recommended-alphabetical":
|
|
2004
|
-
type:
|
|
2005
|
-
order:
|
|
2077
|
+
"recommended-alphabetical": V({
|
|
2078
|
+
type: p.alphabetical,
|
|
2079
|
+
order: d.asc,
|
|
2006
2080
|
"ignore-case": !1
|
|
2007
2081
|
}),
|
|
2008
|
-
"recommended-natural":
|
|
2009
|
-
type:
|
|
2010
|
-
order:
|
|
2082
|
+
"recommended-natural": V({
|
|
2083
|
+
type: p.natural,
|
|
2084
|
+
order: d.asc,
|
|
2011
2085
|
"ignore-case": !1
|
|
2012
2086
|
}),
|
|
2013
|
-
"recommended-line-length":
|
|
2014
|
-
type:
|
|
2015
|
-
order:
|
|
2087
|
+
"recommended-line-length": V({
|
|
2088
|
+
type: p["line-length"],
|
|
2089
|
+
order: d.desc
|
|
2016
2090
|
})
|
|
2017
2091
|
},
|
|
2018
|
-
name:
|
|
2092
|
+
name: Ce
|
|
2019
2093
|
};
|
|
2020
2094
|
export {
|
|
2021
|
-
|
|
2095
|
+
Re as default
|
|
2022
2096
|
};
|