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