eslint-plugin-perfectionist 2.7.0 → 2.8.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,139 +1,140 @@
1
- import W from "node:path";
2
- import { ESLintUtils as de, ASTUtils as K } from "@typescript-eslint/utils";
3
- import { minimatch as D } from "minimatch";
4
- import ce from "natural-compare-lite";
5
- import { builtinModules as fe } from "node:module";
6
- let A = de.RuleCreator(
1
+ import q from "node:path";
2
+ import { ESLintUtils as ge, ASTUtils as J } from "@typescript-eslint/utils";
3
+ import { minimatch as U } from "minimatch";
4
+ import ye from "natural-compare-lite";
5
+ import { AST_NODE_TYPES as fe } from "@typescript-eslint/types";
6
+ import { builtinModules as me } from "node:module";
7
+ let A = ge.RuleCreator(
7
8
  (e) => `https://eslint-plugin-perfectionist.azat.io/rules/${e}`
8
- ), h = (e, i) => {
9
- for (let s = 0, l = e.length; s < l; s++) {
10
- let r = e[s];
11
- if (i.group === r || Array.isArray(r) && typeof i.group == "string" && r.includes(i.group))
12
- return s;
9
+ ), E = (e, i) => {
10
+ for (let a = 0, l = e.length; a < l; a++) {
11
+ let s = e[a];
12
+ if (i.group === s || Array.isArray(s) && typeof i.group == "string" && s.includes(i.group))
13
+ return a;
13
14
  }
14
15
  return e.length;
15
16
  }, I = (e) => {
16
- let [i, s] = e;
17
- return s - i;
17
+ let [i, a] = e;
18
+ return a - i;
18
19
  }, O = (e) => e > 0;
19
- var u = /* @__PURE__ */ ((e) => (e.alphabetical = "alphabetical", e["line-length"] = "line-length", e.natural = "natural", e))(u || {}), g = /* @__PURE__ */ ((e) => (e.desc = "desc", e.asc = "asc", e))(g || {}), L = /* @__PURE__ */ ((e) => (e["values-first"] = "values-first", e["types-first"] = "types-first", e.mixed = "mixed", e))(L || {});
20
- let G = (e) => {
21
- let i, s = (r) => {
22
- !i && e.flat().includes(r) && (i = r);
20
+ var u = /* @__PURE__ */ ((e) => (e.alphabetical = "alphabetical", e["line-length"] = "line-length", e.natural = "natural", e))(u || {}), m = /* @__PURE__ */ ((e) => (e.desc = "desc", e.asc = "asc", e))(m || {}), T = /* @__PURE__ */ ((e) => (e["values-first"] = "values-first", e["types-first"] = "types-first", e.mixed = "mixed", e))(T || {}), G = /* @__PURE__ */ ((e) => (e["optional-first"] = "optional-first", e["required-first"] = "required-first", e.ignore = "ignore", e))(G || {});
21
+ let R = (e) => {
22
+ let i, a = (s) => {
23
+ !i && e.flat().includes(s) && (i = s);
23
24
  };
24
25
  return {
25
26
  getGroup: () => i ?? "unknown",
26
- setCustomGroups: (r, t) => {
27
- if (r)
28
- for (let [a, n] of Object.entries(r))
29
- Array.isArray(n) && n.some(
30
- (o) => D(t, o, {
27
+ setCustomGroups: (s, r) => {
28
+ if (s)
29
+ for (let [n, p] of Object.entries(s))
30
+ Array.isArray(p) && p.some(
31
+ (t) => U(r, t, {
31
32
  nocomment: !0
32
33
  })
33
- ) && s(a), typeof n == "string" && D(t, n, {
34
+ ) && a(n), typeof p == "string" && U(r, p, {
34
35
  nocomment: !0
35
- }) && s(a);
36
+ }) && a(n);
36
37
  },
37
- defineGroup: s
38
+ defineGroup: a
38
39
  };
39
- }, S = (e, i, s) => {
40
- var a, n;
41
- if ((a = i.dependencies) != null && a.includes(e.name))
40
+ }, w = (e, i, a) => {
41
+ var n, p;
42
+ if ((n = i.dependencies) != null && n.includes(e.name))
42
43
  return -1;
43
- if ((n = e.dependencies) != null && n.includes(i.name))
44
+ if ((p = e.dependencies) != null && p.includes(i.name))
44
45
  return 1;
45
- let l = s.order === "asc" ? 1 : -1, r, t = (o) => s["ignore-case"] ? o.toLowerCase() : o;
46
- return s.type === u.alphabetical ? r = (o, p) => t(o.name).localeCompare(t(p.name)) : s.type === u.natural ? r = (o, p) => ce(t(o.name), t(p.name)) : r = (o, p) => {
47
- let f = o.size, y = p.size, d = s["max-line-length"];
46
+ let l = a.order === "asc" ? 1 : -1, s, r = (t) => a["ignore-case"] ? t.toLowerCase() : t;
47
+ return a.type === u.alphabetical ? s = (t, o) => r(t.name).localeCompare(r(o.name)) : a.type === u.natural ? s = (t, o) => ye(r(t.name), r(o.name)) : s = (t, o) => {
48
+ let f = t.size, c = o.size, d = a["max-line-length"];
48
49
  if (d) {
49
- let c = (m, x) => m > d && x.hasMultipleImportDeclarations;
50
- c(f, o) && (f = o.name.length + 10), c(y, p) && (y = p.name.length + 10);
50
+ let g = (y, b) => y > d && b.hasMultipleImportDeclarations;
51
+ g(f, t) && (f = t.name.length + 10), g(c, o) && (c = o.name.length + 10);
51
52
  }
52
- return f - y;
53
- }, l * r(e, i);
54
- }, v = (e, i) => [...e].sort((s, l) => S(s, l, i)), ge = (e, i) => {
55
- let s = i.getTokenAfter(e, {
56
- filter: ({ value: l, type: r }) => !(r === "Punctuator" && [",", ";"].includes(l)),
53
+ return f - c;
54
+ }, l * s(e, i);
55
+ }, v = (e, i) => [...e].sort((a, l) => w(a, l, i)), he = (e, i) => {
56
+ let a = i.getTokenAfter(e, {
57
+ filter: ({ value: l, type: s }) => !(s === "Punctuator" && [",", ";"].includes(l)),
57
58
  includeComments: !0
58
59
  });
59
- return ((s == null ? void 0 : s.type) === "Block" || (s == null ? void 0 : s.type) === "Line") && e.loc.end.line === s.loc.end.line ? s : null;
60
- }, X = (e, i) => Array.isArray(e) && e.some(
61
- (s) => D(i.trim(), s, {
60
+ return ((a == null ? void 0 : a.type) === "Block" || (a == null ? void 0 : a.type) === "Line") && e.loc.end.line === a.loc.end.line ? a : null;
61
+ }, Y = (e, i) => Array.isArray(e) && e.some(
62
+ (a) => U(i.trim(), a, {
62
63
  nocomment: !0
63
64
  })
64
- ) || typeof e == "string" && D(i.trim(), e, {
65
+ ) || typeof e == "string" && U(i.trim(), e, {
65
66
  nocomment: !0
66
- }) || e === !0, V = (e, i) => {
67
- let [s, l] = i.getTokensBefore(e, {
68
- filter: ({ value: r, type: t }) => !(t === "Punctuator" && [",", ";"].includes(r)),
67
+ }) || e === !0, K = (e, i) => {
68
+ let [a, l] = i.getTokensBefore(e, {
69
+ filter: ({ value: s, type: r }) => !(r === "Punctuator" && [",", ";"].includes(s)),
69
70
  includeComments: !0,
70
71
  count: 2
71
72
  });
72
- return ((l == null ? void 0 : l.type) === "Block" || (l == null ? void 0 : l.type) === "Line") && e.loc.start.line - l.loc.end.line <= 1 && (s == null ? void 0 : s.loc.end.line) !== l.loc.start.line ? l : null;
73
- }, T = (e, i, s) => {
74
- var n;
75
- let l = e.range.at(0), r = e.range.at(1), t = i.text.slice(l, r);
76
- if (K.isParenthesized(e, i)) {
77
- let o = i.getTokenBefore(
73
+ return ((l == null ? void 0 : l.type) === "Block" || (l == null ? void 0 : l.type) === "Line") && e.loc.start.line - l.loc.end.line <= 1 && (a == null ? void 0 : a.loc.end.line) !== l.loc.start.line ? l : null;
74
+ }, L = (e, i, a) => {
75
+ var p;
76
+ let l = e.range.at(0), s = e.range.at(1), r = i.text.slice(l, s);
77
+ if (J.isParenthesized(e, i)) {
78
+ let t = i.getTokenBefore(
78
79
  e,
79
- K.isOpeningParenToken
80
- ), p = i.getTokenAfter(
80
+ J.isOpeningParenToken
81
+ ), o = i.getTokenAfter(
81
82
  e,
82
- K.isClosingParenToken
83
+ J.isClosingParenToken
83
84
  );
84
- l = o.range.at(0), r = p.range.at(1);
85
+ l = t.range.at(0), s = o.range.at(1);
85
86
  }
86
- let a = V(e, i);
87
- if (t.endsWith(";") || t.endsWith(",")) {
88
- let o = i.getTokensAfter(e, {
87
+ let n = K(e, i);
88
+ if (r.endsWith(";") || r.endsWith(",")) {
89
+ let t = i.getTokensAfter(e, {
89
90
  includeComments: !0,
90
91
  count: 2
91
92
  });
92
- e.loc.start.line === ((n = o.at(1)) == null ? void 0 : n.loc.start.line) && (r -= 1);
93
+ e.loc.start.line === ((p = t.at(1)) == null ? void 0 : p.loc.start.line) && (s -= 1);
93
94
  }
94
- return a && !X(
95
- (s == null ? void 0 : s.partitionComment) ?? !1,
96
- a.value
97
- ) && (l = a.range.at(0)), [l, r];
98
- }, M = (e, i, s, l, r) => {
99
- var n, o;
100
- let t = [], a = ((n = i.at(0)) == null ? void 0 : n.node.loc.start.line) === ((o = i.at(-1)) == null ? void 0 : o.node.loc.end.line);
101
- for (let p = 0, f = i.length; p < f; p++) {
102
- let { node: y } = i.at(p);
103
- t.push(
95
+ return n && !Y(
96
+ (a == null ? void 0 : a.partitionComment) ?? !1,
97
+ n.value
98
+ ) && (l = n.range.at(0)), [l, s];
99
+ }, M = (e, i, a, l, s) => {
100
+ var p, t;
101
+ let r = [], n = ((p = i.at(0)) == null ? void 0 : p.node.loc.start.line) === ((t = i.at(-1)) == null ? void 0 : t.node.loc.end.line);
102
+ for (let o = 0, f = i.length; o < f; o++) {
103
+ let { node: c } = i.at(o);
104
+ r.push(
104
105
  e.replaceTextRange(
105
- T(y, l, r),
106
+ L(c, l, s),
106
107
  l.text.slice(
107
- ...T(s.at(p).node, l, r)
108
+ ...L(a.at(o).node, l, s)
108
109
  )
109
110
  )
110
111
  );
111
- let d = ge(s.at(p).node, l);
112
- if (d && !a) {
113
- let m = [
112
+ let d = he(a.at(o).node, l);
113
+ if (d && !n) {
114
+ let y = [
114
115
  l.getTokenBefore(d).range.at(1),
115
116
  d.range.at(1)
116
117
  ];
117
- t.push(e.replaceTextRange(m, ""));
118
- let x = l.getTokenAfter(y);
119
- t.push(
118
+ r.push(e.replaceTextRange(y, ""));
119
+ let b = l.getTokenAfter(c);
120
+ r.push(
120
121
  e.insertTextAfter(
121
- (x == null ? void 0 : x.loc.end.line) === y.loc.end.line ? x : y,
122
- l.text.slice(...m)
122
+ (b == null ? void 0 : b.loc.end.line) === c.loc.end.line ? b : c,
123
+ l.text.slice(...y)
123
124
  )
124
125
  );
125
126
  }
126
127
  }
127
- return t;
128
+ return r;
128
129
  }, j = (e = {}, i) => Object.assign(i, e), P = (e, i) => {
129
130
  if (e.length > 1)
130
- for (let s = 1; s < e.length; s++) {
131
- let l = e.at(s - 1), r = e.at(s);
132
- l && r && i(l, r, s - 1);
131
+ for (let a = 1; a < e.length; a++) {
132
+ let l = e.at(a - 1), s = e.at(a);
133
+ l && s && i(l, s, a - 1);
133
134
  }
134
135
  };
135
- const q = "sort-svelte-attributes", ye = A({
136
- name: q,
136
+ const H = "sort-svelte-attributes", be = A({
137
+ name: H,
137
138
  meta: {
138
139
  type: "suggestion",
139
140
  docs: {
@@ -157,8 +158,8 @@ const q = "sort-svelte-attributes", ye = A({
157
158
  type: "string"
158
159
  },
159
160
  order: {
160
- enum: [g.asc, g.desc],
161
- default: g.asc,
161
+ enum: [m.asc, m.desc],
162
+ default: m.asc,
162
163
  type: "string"
163
164
  },
164
165
  "ignore-case": {
@@ -179,62 +180,62 @@ const q = "sort-svelte-attributes", ye = A({
179
180
  defaultOptions: [
180
181
  {
181
182
  type: u.alphabetical,
182
- order: g.asc
183
+ order: m.asc
183
184
  }
184
185
  ],
185
- create: (e) => W.extname(e.filename) !== ".svelte" ? {} : {
186
+ create: (e) => q.extname(e.filename) !== ".svelte" ? {} : {
186
187
  SvelteStartTag: (i) => {
187
188
  if (i.attributes.length > 1) {
188
- let s = j(e.options.at(0), {
189
+ let a = j(e.options.at(0), {
189
190
  type: u.alphabetical,
190
- order: g.asc,
191
+ order: m.asc,
191
192
  "ignore-case": !1,
192
193
  "custom-groups": {},
193
194
  groups: []
194
195
  }), l = i.attributes.reduce(
195
- (r, t) => {
196
- if (t.type === "SvelteSpreadAttribute")
197
- return r.push([]), r;
198
- let a, { getGroup: n, defineGroup: o, setCustomGroups: p } = G(
199
- s.groups
196
+ (s, r) => {
197
+ if (r.type === "SvelteSpreadAttribute")
198
+ return s.push([]), s;
199
+ let n, { getGroup: p, defineGroup: t, setCustomGroups: o } = R(
200
+ a.groups
200
201
  );
201
- return t.key.type === "SvelteSpecialDirectiveKey" ? a = e.sourceCode.text.slice(...t.key.range) : typeof t.key.name == "string" ? { name: a } = t.key : a = e.sourceCode.text.slice(...t.key.range), p(s["custom-groups"], a), t.type === "SvelteShorthandAttribute" && (o("svelte-shorthand"), o("shorthand")), (!("value" in t) || Array.isArray(t.value) && !t.value.at(0)) && o("shorthand"), t.loc.start.line !== t.loc.end.line && o("multiline"), r.at(-1).push({
202
- size: I(t.range),
203
- node: t,
204
- group: n(),
205
- name: a
206
- }), r;
202
+ return r.key.type === "SvelteSpecialDirectiveKey" ? n = e.sourceCode.text.slice(...r.key.range) : typeof r.key.name == "string" ? { name: n } = r.key : n = e.sourceCode.text.slice(...r.key.range), o(a["custom-groups"], n), r.type === "SvelteShorthandAttribute" && (t("svelte-shorthand"), t("shorthand")), (!("value" in r) || Array.isArray(r.value) && !r.value.at(0)) && t("shorthand"), r.loc.start.line !== r.loc.end.line && t("multiline"), s.at(-1).push({
203
+ size: I(r.range),
204
+ node: r,
205
+ group: p(),
206
+ name: n
207
+ }), s;
207
208
  },
208
209
  [[]]
209
210
  );
210
- for (let r of l)
211
- P(r, (t, a) => {
212
- let n = h(s.groups, t), o = h(s.groups, a);
213
- (n > o || n === o && O(S(t, a, s))) && e.report({
211
+ for (let s of l)
212
+ P(s, (r, n) => {
213
+ let p = E(a.groups, r), t = E(a.groups, n);
214
+ (p > t || p === t && O(w(r, n, a))) && e.report({
214
215
  messageId: "unexpectedSvelteAttributesOrder",
215
216
  data: {
216
- left: t.name,
217
- right: a.name
217
+ left: r.name,
218
+ right: n.name
218
219
  },
219
- node: a.node,
220
- fix: (p) => {
220
+ node: n.node,
221
+ fix: (o) => {
221
222
  let f = {};
222
- for (let d of r) {
223
- let c = h(s.groups, d);
224
- c in f ? f[c] = v(
225
- [...f[c], d],
226
- s
227
- ) : f[c] = [d];
223
+ for (let d of s) {
224
+ let g = E(a.groups, d);
225
+ g in f ? f[g] = v(
226
+ [...f[g], d],
227
+ a
228
+ ) : f[g] = [d];
228
229
  }
229
- let y = [];
230
+ let c = [];
230
231
  for (let d of Object.keys(f).sort(
231
- (c, m) => Number(c) - Number(m)
232
+ (g, y) => Number(g) - Number(y)
232
233
  ))
233
- y.push(...v(f[d], s));
234
+ c.push(...v(f[d], a));
234
235
  return M(
235
- p,
236
- r,
237
- y,
236
+ o,
237
+ s,
238
+ c,
238
239
  e.sourceCode
239
240
  );
240
241
  }
@@ -243,8 +244,8 @@ const q = "sort-svelte-attributes", ye = A({
243
244
  }
244
245
  }
245
246
  }
246
- }), H = "sort-astro-attributes", me = A({
247
- name: H,
247
+ }), Q = "sort-astro-attributes", xe = A({
248
+ name: Q,
248
249
  meta: {
249
250
  type: "suggestion",
250
251
  docs: {
@@ -268,8 +269,8 @@ const q = "sort-svelte-attributes", ye = A({
268
269
  type: "string"
269
270
  },
270
271
  order: {
271
- enum: [g.asc, g.desc],
272
- default: g.asc,
272
+ enum: [m.asc, m.desc],
273
+ default: m.asc,
273
274
  type: "string"
274
275
  },
275
276
  "ignore-case": {
@@ -290,63 +291,63 @@ const q = "sort-svelte-attributes", ye = A({
290
291
  defaultOptions: [
291
292
  {
292
293
  type: u.alphabetical,
293
- order: g.asc
294
+ order: m.asc
294
295
  }
295
296
  ],
296
297
  // @ts-ignore
297
- create: (e) => W.extname(e.filename) !== ".astro" ? {} : {
298
+ create: (e) => q.extname(e.filename) !== ".astro" ? {} : {
298
299
  JSXElement: (i) => {
299
- let { attributes: s } = i.openingElement;
300
- if (s.length > 1) {
300
+ let { attributes: a } = i.openingElement;
301
+ if (a.length > 1) {
301
302
  let l = j(e.options.at(0), {
302
303
  type: u.alphabetical,
303
- order: g.asc,
304
+ order: m.asc,
304
305
  "ignore-case": !1,
305
306
  "custom-groups": {},
306
307
  groups: []
307
- }), r = s.reduce(
308
- (t, a) => {
309
- if (a.type === "JSXSpreadAttribute")
310
- return t.push([]), t;
311
- let n = typeof a.name.name == "string" ? a.name.name : e.sourceCode.text.slice(...a.name.range), { getGroup: o, defineGroup: p, setCustomGroups: f } = G(
308
+ }), s = a.reduce(
309
+ (r, n) => {
310
+ if (n.type === "JSXSpreadAttribute")
311
+ return r.push([]), r;
312
+ let p = typeof n.name.name == "string" ? n.name.name : e.sourceCode.text.slice(...n.name.range), { getGroup: t, defineGroup: o, setCustomGroups: f } = R(
312
313
  l.groups
313
314
  );
314
- return f(l["custom-groups"], n), a.type === "AstroShorthandAttribute" && (p("astro-shorthand"), p("shorthand")), a.value === null && p("shorthand"), a.loc.start.line !== a.loc.end.line && p("multiline"), t.at(-1).push({
315
- size: I(a.range),
316
- node: a,
317
- group: o(),
318
- name: n
319
- }), t;
315
+ return f(l["custom-groups"], p), n.type === "AstroShorthandAttribute" && (o("astro-shorthand"), o("shorthand")), n.value === null && o("shorthand"), n.loc.start.line !== n.loc.end.line && o("multiline"), r.at(-1).push({
316
+ size: I(n.range),
317
+ node: n,
318
+ group: t(),
319
+ name: p
320
+ }), r;
320
321
  },
321
322
  [[]]
322
323
  );
323
- for (let t of r)
324
- P(t, (a, n) => {
325
- let o = h(l.groups, a), p = h(l.groups, n);
326
- (o > p || o === p && O(S(a, n, l))) && e.report({
324
+ for (let r of s)
325
+ P(r, (n, p) => {
326
+ let t = E(l.groups, n), o = E(l.groups, p);
327
+ (t > o || t === o && O(w(n, p, l))) && e.report({
327
328
  messageId: "unexpectedAstroAttributesOrder",
328
329
  data: {
329
- left: a.name,
330
- right: n.name
330
+ left: n.name,
331
+ right: p.name
331
332
  },
332
- node: n.node,
333
+ node: p.node,
333
334
  fix: (f) => {
334
- let y = {};
335
- for (let c of t) {
336
- let m = h(l.groups, c);
337
- m in y ? y[m] = v(
338
- [...y[m], c],
335
+ let c = {};
336
+ for (let g of r) {
337
+ let y = E(l.groups, g);
338
+ y in c ? c[y] = v(
339
+ [...c[y], g],
339
340
  l
340
- ) : y[m] = [c];
341
+ ) : c[y] = [g];
341
342
  }
342
343
  let d = [];
343
- for (let c of Object.keys(y).sort(
344
- (m, x) => Number(m) - Number(x)
344
+ for (let g of Object.keys(c).sort(
345
+ (y, b) => Number(y) - Number(b)
345
346
  ))
346
- d.push(...v(y[c], l));
347
+ d.push(...v(c[g], l));
347
348
  return M(
348
349
  f,
349
- t,
350
+ r,
350
351
  d,
351
352
  e.sourceCode
352
353
  );
@@ -358,8 +359,8 @@ const q = "sort-svelte-attributes", ye = A({
358
359
  }
359
360
  });
360
361
  let k = (e) => e.replaceAll(/\s\s+/g, " ").trim();
361
- const Q = "sort-array-includes", he = A({
362
- name: Q,
362
+ const Z = "sort-array-includes", Ee = A({
363
+ name: Z,
363
364
  meta: {
364
365
  type: "suggestion",
365
366
  docs: {
@@ -380,8 +381,8 @@ const Q = "sort-array-includes", he = A({
380
381
  type: "string"
381
382
  },
382
383
  order: {
383
- enum: [g.asc, g.desc],
384
- default: g.asc,
384
+ enum: [m.asc, m.desc],
385
+ default: m.asc,
385
386
  type: "string"
386
387
  },
387
388
  "ignore-case": {
@@ -403,46 +404,46 @@ const Q = "sort-array-includes", he = A({
403
404
  defaultOptions: [
404
405
  {
405
406
  type: u.alphabetical,
406
- order: g.asc
407
+ order: m.asc
407
408
  }
408
409
  ],
409
410
  create: (e) => ({
410
411
  MemberExpression: (i) => {
411
412
  if ((i.object.type === "ArrayExpression" || i.object.type === "NewExpression") && i.property.type === "Identifier" && i.property.name === "includes") {
412
- let s = i.object.type === "ArrayExpression" ? i.object.elements : i.object.arguments;
413
- if (s.length > 1) {
413
+ let a = i.object.type === "ArrayExpression" ? i.object.elements : i.object.arguments;
414
+ if (a.length > 1) {
414
415
  let l = j(e.options.at(0), {
415
416
  type: u.alphabetical,
416
- order: g.asc,
417
+ order: m.asc,
417
418
  "ignore-case": !1,
418
419
  "spread-last": !1
419
- }), r = s.reduce(
420
- (t, a) => (a !== null && t.at(0).push({
421
- name: a.type === "Literal" ? `${a.value}` : e.sourceCode.text.slice(...a.range),
422
- size: I(a.range),
423
- type: a.type,
424
- node: a
425
- }), t),
420
+ }), s = a.reduce(
421
+ (r, n) => (n !== null && r.at(0).push({
422
+ name: n.type === "Literal" ? `${n.value}` : e.sourceCode.text.slice(...n.range),
423
+ size: I(n.range),
424
+ type: n.type,
425
+ node: n
426
+ }), r),
426
427
  [[], []]
427
428
  ).flat();
428
- P(r, (t, a) => {
429
- let n;
430
- l["spread-last"] && t.node.type === "Literal" && a.node.type === "SpreadElement" ? n = !1 : l["spread-last"] && t.node.type === "SpreadElement" && a.node.type === "Literal" ? n = !0 : n = O(S(t, a, l)), n && e.report({
429
+ P(s, (r, n) => {
430
+ let p;
431
+ l["spread-last"] && r.node.type === "Literal" && n.node.type === "SpreadElement" ? p = !1 : l["spread-last"] && r.node.type === "SpreadElement" && n.node.type === "Literal" ? p = !0 : p = O(w(r, n, l)), p && e.report({
431
432
  messageId: "unexpectedArrayIncludesOrder",
432
433
  data: {
433
- left: k(t.name),
434
- right: k(a.name)
434
+ left: k(r.name),
435
+ right: k(n.name)
435
436
  },
436
- node: a.node,
437
- fix: (o) => {
438
- let p = v(r, l);
437
+ node: n.node,
438
+ fix: (t) => {
439
+ let o = v(s, l);
439
440
  if (l["spread-last"])
440
- for (let f = 0, y = p.length; f < y; f++)
441
- p.at(f).node.type === "SpreadElement" && p.push(p.splice(f, 1).at(0));
441
+ for (let f = 0, c = o.length; f < c; f++)
442
+ o.at(f).node.type === "SpreadElement" && o.push(o.splice(f, 1).at(0));
442
443
  return M(
444
+ t,
445
+ s,
443
446
  o,
444
- r,
445
- p,
446
447
  e.sourceCode
447
448
  );
448
449
  }
@@ -452,8 +453,8 @@ const Q = "sort-array-includes", he = A({
452
453
  }
453
454
  }
454
455
  })
455
- }), Y = "sort-vue-attributes", be = A({
456
- name: Y,
456
+ }), F = "sort-vue-attributes", Ne = A({
457
+ name: F,
457
458
  meta: {
458
459
  type: "suggestion",
459
460
  docs: {
@@ -477,8 +478,8 @@ const Q = "sort-array-includes", he = A({
477
478
  type: "string"
478
479
  },
479
480
  order: {
480
- enum: [g.asc, g.desc],
481
- default: g.asc,
481
+ enum: [m.asc, m.desc],
482
+ default: m.asc,
482
483
  type: "string"
483
484
  },
484
485
  "ignore-case": {
@@ -500,67 +501,67 @@ const Q = "sort-array-includes", he = A({
500
501
  defaultOptions: [
501
502
  {
502
503
  type: u.alphabetical,
503
- order: g.asc
504
+ order: m.asc
504
505
  }
505
506
  ],
506
507
  create: (e) => {
507
- if (W.extname(e.filename) !== ".vue")
508
+ if (q.extname(e.filename) !== ".vue")
508
509
  return {};
509
510
  if (!("defineTemplateBodyVisitor" in e.sourceCode.parserServices))
510
511
  return {};
511
512
  let { defineTemplateBodyVisitor: i } = e.sourceCode.parserServices;
512
513
  return i({
513
- VStartTag: (s) => {
514
- if (s.attributes.length > 1) {
514
+ VStartTag: (a) => {
515
+ if (a.attributes.length > 1) {
515
516
  let l = j(e.options.at(0), {
516
517
  type: u.alphabetical,
517
- order: g.asc,
518
+ order: m.asc,
518
519
  "ignore-case": !1,
519
520
  "custom-groups": {},
520
521
  groups: []
521
- }), r = s.attributes.reduce(
522
- (t, a) => {
523
- if (a.key.type === "VDirectiveKey" && a.key.name.rawName === "bind")
524
- return t.push([]), t;
525
- let n, { getGroup: o, defineGroup: p, setCustomGroups: f } = G(
522
+ }), s = a.attributes.reduce(
523
+ (r, n) => {
524
+ if (n.key.type === "VDirectiveKey" && n.key.name.rawName === "bind")
525
+ return r.push([]), r;
526
+ let p, { getGroup: t, defineGroup: o, setCustomGroups: f } = R(
526
527
  l.groups
527
528
  );
528
- return typeof a.key.name == "string" && a.key.type !== "VDirectiveKey" ? n = a.key.rawName : n = e.sourceCode.text.slice(...a.key.range), f(l["custom-groups"], n), a.value === null && p("shorthand"), a.loc.start.line !== a.loc.end.line && p("multiline"), t.at(-1).push({
529
- size: I(a.range),
530
- node: a,
531
- group: o(),
532
- name: n
533
- }), t;
529
+ return typeof n.key.name == "string" && n.key.type !== "VDirectiveKey" ? p = n.key.rawName : p = e.sourceCode.text.slice(...n.key.range), f(l["custom-groups"], p), n.value === null && o("shorthand"), n.loc.start.line !== n.loc.end.line && o("multiline"), r.at(-1).push({
530
+ size: I(n.range),
531
+ node: n,
532
+ group: t(),
533
+ name: p
534
+ }), r;
534
535
  },
535
536
  [[]]
536
537
  );
537
- for (let t of r)
538
- P(t, (a, n) => {
539
- let o = h(l.groups, a), p = h(l.groups, n);
540
- (o > p || o === p && O(S(a, n, l))) && e.report({
538
+ for (let r of s)
539
+ P(r, (n, p) => {
540
+ let t = E(l.groups, n), o = E(l.groups, p);
541
+ (t > o || t === o && O(w(n, p, l))) && e.report({
541
542
  messageId: "unexpectedVueAttributesOrder",
542
543
  data: {
543
- left: a.name,
544
- right: n.name
544
+ left: n.name,
545
+ right: p.name
545
546
  },
546
- node: n.node,
547
+ node: p.node,
547
548
  fix: (f) => {
548
- let y = {};
549
- for (let c of t) {
550
- let m = h(l.groups, c);
551
- m in y ? y[m] = v(
552
- [...y[m], c],
549
+ let c = {};
550
+ for (let g of r) {
551
+ let y = E(l.groups, g);
552
+ y in c ? c[y] = v(
553
+ [...c[y], g],
553
554
  l
554
- ) : y[m] = [c];
555
+ ) : c[y] = [g];
555
556
  }
556
557
  let d = [];
557
- for (let c of Object.keys(y).sort(
558
- (m, x) => Number(m) - Number(x)
558
+ for (let g of Object.keys(c).sort(
559
+ (y, b) => Number(y) - Number(b)
559
560
  ))
560
- d.push(...v(y[c], l));
561
+ d.push(...v(c[g], l));
561
562
  return M(
562
563
  f,
563
- t,
564
+ r,
564
565
  d,
565
566
  e.sourceCode
566
567
  );
@@ -571,8 +572,8 @@ const Q = "sort-array-includes", he = A({
571
572
  }
572
573
  });
573
574
  }
574
- }), Z = "sort-named-exports", xe = A({
575
- name: Z,
575
+ }), ee = "sort-named-exports", Ce = A({
576
+ name: ee,
576
577
  meta: {
577
578
  type: "suggestion",
578
579
  docs: {
@@ -593,8 +594,8 @@ const Q = "sort-array-includes", he = A({
593
594
  type: "string"
594
595
  },
595
596
  order: {
596
- enum: [g.asc, g.desc],
597
- default: g.asc,
597
+ enum: [m.asc, m.desc],
598
+ default: m.asc,
598
599
  type: "string"
599
600
  },
600
601
  "ignore-case": {
@@ -603,11 +604,11 @@ const Q = "sort-array-includes", he = A({
603
604
  },
604
605
  "group-kind": {
605
606
  enum: [
606
- L.mixed,
607
- L["values-first"],
608
- L["types-first"]
607
+ T.mixed,
608
+ T["values-first"],
609
+ T["types-first"]
609
610
  ],
610
- default: L.mixed,
611
+ default: T.mixed,
611
612
  type: "string"
612
613
  }
613
614
  },
@@ -621,43 +622,43 @@ const Q = "sort-array-includes", he = A({
621
622
  defaultOptions: [
622
623
  {
623
624
  type: u.alphabetical,
624
- order: g.asc
625
+ order: m.asc
625
626
  }
626
627
  ],
627
628
  create: (e) => ({
628
629
  ExportNamedDeclaration: (i) => {
629
630
  if (i.specifiers.length > 1) {
630
- let s = j(e.options.at(0), {
631
+ let a = j(e.options.at(0), {
631
632
  type: u.alphabetical,
632
633
  "ignore-case": !1,
633
- order: g.asc,
634
- "group-kind": L.mixed
635
- }), l = i.specifiers.map((a) => ({
636
- size: I(a.range),
637
- name: a.local.name,
638
- node: a,
639
- group: a.exportKind
640
- })), r = s["group-kind"] !== L.mixed, t = s["group-kind"] === L["values-first"] ? ["value", "type"] : ["type", "value"];
641
- P(l, (a, n) => {
642
- let o = h(t, a), p = h(t, n);
643
- if (r && o > p || (!r || o === p) && O(S(a, n, s))) {
644
- let f = r ? t.map((y) => l.filter((d) => d.group === y)).map((y) => v(y, s)).flat() : v(l, s);
634
+ order: m.asc,
635
+ "group-kind": T.mixed
636
+ }), l = i.specifiers.map((n) => ({
637
+ size: I(n.range),
638
+ name: n.local.name,
639
+ node: n,
640
+ group: n.exportKind
641
+ })), s = a["group-kind"] !== T.mixed, r = a["group-kind"] === T["values-first"] ? ["value", "type"] : ["type", "value"];
642
+ P(l, (n, p) => {
643
+ let t = E(r, n), o = E(r, p);
644
+ if (s && t > o || (!s || t === o) && O(w(n, p, a))) {
645
+ let f = s ? r.map((c) => l.filter((d) => d.group === c)).map((c) => v(c, a)).flat() : v(l, a);
645
646
  e.report({
646
647
  messageId: "unexpectedNamedExportsOrder",
647
648
  data: {
648
- left: a.name,
649
- right: n.name
649
+ left: n.name,
650
+ right: p.name
650
651
  },
651
- node: n.node,
652
- fix: (y) => M(y, l, f, e.sourceCode)
652
+ node: p.node,
653
+ fix: (c) => M(c, l, f, e.sourceCode)
653
654
  });
654
655
  }
655
656
  });
656
657
  }
657
658
  }
658
659
  })
659
- }), F = "sort-named-imports", Ee = A({
660
- name: F,
660
+ }), te = "sort-named-imports", ve = A({
661
+ name: te,
661
662
  meta: {
662
663
  type: "suggestion",
663
664
  docs: {
@@ -678,8 +679,8 @@ const Q = "sort-array-includes", he = A({
678
679
  type: "string"
679
680
  },
680
681
  order: {
681
- enum: [g.asc, g.desc],
682
- default: g.asc,
682
+ enum: [m.asc, m.desc],
683
+ default: m.asc,
683
684
  type: "string"
684
685
  },
685
686
  "ignore-case": {
@@ -692,11 +693,11 @@ const Q = "sort-array-includes", he = A({
692
693
  },
693
694
  "group-kind": {
694
695
  enum: [
695
- L.mixed,
696
- L["values-first"],
697
- L["types-first"]
696
+ T.mixed,
697
+ T["values-first"],
698
+ T["types-first"]
698
699
  ],
699
- default: L.mixed,
700
+ default: T.mixed,
700
701
  type: "string"
701
702
  }
702
703
  },
@@ -710,42 +711,42 @@ const Q = "sort-array-includes", he = A({
710
711
  defaultOptions: [
711
712
  {
712
713
  type: u.alphabetical,
713
- order: g.asc
714
+ order: m.asc
714
715
  }
715
716
  ],
716
717
  create: (e) => ({
717
718
  ImportDeclaration: (i) => {
718
- let s = i.specifiers.filter(
719
+ let a = i.specifiers.filter(
719
720
  ({ type: l }) => l === "ImportSpecifier"
720
721
  );
721
- if (s.length > 1) {
722
+ if (a.length > 1) {
722
723
  let l = j(e.options.at(0), {
723
724
  type: u.alphabetical,
724
725
  "ignore-alias": !0,
725
726
  "ignore-case": !1,
726
- order: g.asc,
727
- "group-kind": L.mixed
728
- }), r = s.map((n) => {
729
- let o, { name: p } = n.local;
730
- return n.type === "ImportSpecifier" && (l["ignore-alias"] && ({ name: p } = n.imported), o = n.importKind), {
731
- size: I(n.range),
732
- node: n,
733
- name: p,
734
- group: o
727
+ order: m.asc,
728
+ "group-kind": T.mixed
729
+ }), s = a.map((p) => {
730
+ let t, { name: o } = p.local;
731
+ return p.type === "ImportSpecifier" && (l["ignore-alias"] && ({ name: o } = p.imported), t = p.importKind), {
732
+ size: I(p.range),
733
+ node: p,
734
+ name: o,
735
+ group: t
735
736
  };
736
- }), t = l["group-kind"] !== L.mixed, a = l["group-kind"] === L["values-first"] ? ["value", "type"] : ["type", "value"];
737
- P(r, (n, o) => {
738
- let p = h(a, n), f = h(a, o);
739
- if (t && p > f || (!t || p === f) && O(S(n, o, l))) {
740
- let y = t ? a.map((d) => r.filter((c) => c.group === d)).map((d) => v(d, l)).flat() : v(r, l);
737
+ }), r = l["group-kind"] !== T.mixed, n = l["group-kind"] === T["values-first"] ? ["value", "type"] : ["type", "value"];
738
+ P(s, (p, t) => {
739
+ let o = E(n, p), f = E(n, t);
740
+ if (r && o > f || (!r || o === f) && O(w(p, t, l))) {
741
+ let c = r ? n.map((d) => s.filter((g) => g.group === d)).map((d) => v(d, l)).flat() : v(s, l);
741
742
  e.report({
742
743
  messageId: "unexpectedNamedImportsOrder",
743
744
  data: {
744
- left: n.name,
745
- right: o.name
745
+ left: p.name,
746
+ right: t.name
746
747
  },
747
- node: o.node,
748
- fix: (d) => M(d, r, y, e.sourceCode)
748
+ node: t.node,
749
+ fix: (d) => M(d, s, c, e.sourceCode)
749
750
  });
750
751
  }
751
752
  });
@@ -753,12 +754,12 @@ const Q = "sort-array-includes", he = A({
753
754
  }
754
755
  })
755
756
  });
756
- let z = (e, i, s) => e.lines.slice(
757
+ let W = (e, i, a) => e.lines.slice(
757
758
  i.node.loc.end.line,
758
- s.node.loc.start.line - 1
759
- ).filter((r) => !r.trim().length).length;
760
- const ee = "sort-object-types", Ne = A({
761
- name: ee,
759
+ a.node.loc.start.line - 1
760
+ ).filter((s) => !s.trim().length).length;
761
+ const re = "sort-object-types", Se = A({
762
+ name: re,
762
763
  meta: {
763
764
  type: "suggestion",
764
765
  docs: {
@@ -782,8 +783,8 @@ const ee = "sort-object-types", Ne = A({
782
783
  type: "string"
783
784
  },
784
785
  order: {
785
- enum: [g.asc, g.desc],
786
- default: g.asc,
786
+ enum: [m.asc, m.desc],
787
+ default: m.asc,
787
788
  type: "string"
788
789
  },
789
790
  "ignore-case": {
@@ -809,86 +810,86 @@ const ee = "sort-object-types", Ne = A({
809
810
  defaultOptions: [
810
811
  {
811
812
  type: u.alphabetical,
812
- order: g.asc
813
+ order: m.asc
813
814
  }
814
815
  ],
815
816
  create: (e) => ({
816
817
  TSTypeLiteral: (i) => {
817
818
  if (i.members.length > 1) {
818
- let s = j(e.options.at(0), {
819
+ let a = j(e.options.at(0), {
819
820
  "partition-by-new-line": !1,
820
821
  type: u.alphabetical,
821
822
  "ignore-case": !1,
822
- order: g.asc,
823
+ order: m.asc,
823
824
  "custom-groups": {},
824
825
  groups: []
825
826
  }), l = i.members.reduce(
826
- (r, t) => {
827
- var C, b, N, E;
828
- let a, n = e.sourceCode.text.slice(
829
- t.range.at(0),
830
- t.range.at(1)
831
- ), o = (C = r.at(-1)) == null ? void 0 : C.at(-1), { getGroup: p, defineGroup: f, setCustomGroups: y } = G(
832
- s.groups
833
- ), d = (w) => w.replace(/(,|;)$/, "");
834
- if (t.type === "TSPropertySignature")
835
- t.key.type === "Identifier" ? { name: a } = t.key : t.key.type === "Literal" ? a = `${t.key.value}` : a = e.sourceCode.text.slice(
836
- t.range.at(0),
837
- (b = t.typeAnnotation) == null ? void 0 : b.range.at(0)
827
+ (s, r) => {
828
+ var C, h, N, x;
829
+ let n, p = e.sourceCode.text.slice(
830
+ r.range.at(0),
831
+ r.range.at(1)
832
+ ), t = (C = s.at(-1)) == null ? void 0 : C.at(-1), { getGroup: o, defineGroup: f, setCustomGroups: c } = R(
833
+ a.groups
834
+ ), d = (S) => S.replace(/(,|;)$/, "");
835
+ if (r.type === "TSPropertySignature")
836
+ r.key.type === "Identifier" ? { name: n } = r.key : r.key.type === "Literal" ? n = `${r.key.value}` : n = e.sourceCode.text.slice(
837
+ r.range.at(0),
838
+ (h = r.typeAnnotation) == null ? void 0 : h.range.at(0)
838
839
  );
839
- else if (t.type === "TSIndexSignature") {
840
- let w = ((N = t.typeAnnotation) == null ? void 0 : N.range.at(0)) ?? t.range.at(1);
841
- a = d(
842
- e.sourceCode.text.slice(t.range.at(0), w)
840
+ else if (r.type === "TSIndexSignature") {
841
+ let S = ((N = r.typeAnnotation) == null ? void 0 : N.range.at(0)) ?? r.range.at(1);
842
+ n = d(
843
+ e.sourceCode.text.slice(r.range.at(0), S)
843
844
  );
844
845
  } else
845
- a = d(
846
+ n = d(
846
847
  e.sourceCode.text.slice(
847
- t.range.at(0),
848
- t.range.at(1)
848
+ r.range.at(0),
849
+ r.range.at(1)
849
850
  )
850
851
  );
851
- y(s["custom-groups"], a), t.loc.start.line !== t.loc.end.line && f("multiline");
852
- let m = n.endsWith(";") || n.endsWith(",") ? 1 : 0, x = {
853
- size: I(t.range) - m,
854
- node: t,
855
- name: a
852
+ c(a["custom-groups"], n), r.loc.start.line !== r.loc.end.line && f("multiline");
853
+ let y = p.endsWith(";") || p.endsWith(",") ? 1 : 0, b = {
854
+ size: I(r.range) - y,
855
+ node: r,
856
+ name: n
856
857
  };
857
- return s["partition-by-new-line"] && o && z(e.sourceCode, o, x) && r.push([]), (E = r.at(-1)) == null || E.push({
858
- ...x,
859
- group: p()
860
- }), r;
858
+ return a["partition-by-new-line"] && t && W(e.sourceCode, t, b) && s.push([]), (x = s.at(-1)) == null || x.push({
859
+ ...b,
860
+ group: o()
861
+ }), s;
861
862
  },
862
863
  [[]]
863
864
  );
864
- for (let r of l)
865
- P(r, (t, a) => {
866
- let n = h(s.groups, t), o = h(s.groups, a);
867
- (n > o || n === o && O(S(t, a, s))) && e.report({
865
+ for (let s of l)
866
+ P(s, (r, n) => {
867
+ let p = E(a.groups, r), t = E(a.groups, n);
868
+ (p > t || p === t && O(w(r, n, a))) && e.report({
868
869
  messageId: "unexpectedObjectTypesOrder",
869
870
  data: {
870
- left: k(t.name),
871
- right: k(a.name)
871
+ left: k(r.name),
872
+ right: k(n.name)
872
873
  },
873
- node: a.node,
874
- fix: (p) => {
874
+ node: n.node,
875
+ fix: (o) => {
875
876
  let f = {};
876
- for (let d of r) {
877
- let c = h(s.groups, d);
878
- c in f ? f[c] = v(
879
- [...f[c], d],
880
- s
881
- ) : f[c] = [d];
877
+ for (let d of s) {
878
+ let g = E(a.groups, d);
879
+ g in f ? f[g] = v(
880
+ [...f[g], d],
881
+ a
882
+ ) : f[g] = [d];
882
883
  }
883
- let y = [];
884
+ let c = [];
884
885
  for (let d of Object.keys(f).sort(
885
- (c, m) => Number(c) - Number(m)
886
+ (g, y) => Number(g) - Number(y)
886
887
  ))
887
- y.push(...v(f[d], s));
888
+ c.push(...v(f[d], a));
888
889
  return M(
889
- p,
890
- r,
891
- y,
890
+ o,
891
+ s,
892
+ c,
892
893
  e.sourceCode
893
894
  );
894
895
  }
@@ -897,8 +898,8 @@ const ee = "sort-object-types", Ne = A({
897
898
  }
898
899
  }
899
900
  })
900
- }), te = "sort-union-types", Ce = A({
901
- name: te,
901
+ }), se = "sort-union-types", we = A({
902
+ name: se,
902
903
  meta: {
903
904
  type: "suggestion",
904
905
  docs: {
@@ -919,8 +920,8 @@ const ee = "sort-object-types", Ne = A({
919
920
  type: "string"
920
921
  },
921
922
  order: {
922
- enum: [g.asc, g.desc],
923
- default: g.asc,
923
+ enum: [m.asc, m.desc],
924
+ default: m.asc,
924
925
  type: "string"
925
926
  },
926
927
  "ignore-case": {
@@ -942,49 +943,58 @@ const ee = "sort-object-types", Ne = A({
942
943
  defaultOptions: [
943
944
  {
944
945
  type: u.alphabetical,
945
- order: g.asc
946
+ order: m.asc
946
947
  }
947
948
  ],
948
949
  create: (e) => ({
949
950
  TSUnionType: (i) => {
950
- let s = j(e.options.at(0), {
951
+ let a = j(e.options.at(0), {
951
952
  type: u.alphabetical,
952
953
  "nullable-last": !1,
953
954
  "ignore-case": !1,
954
- order: g.asc
955
- }), l = i.types.map((r) => ({
956
- group: r.type === "TSNullKeyword" || r.type === "TSUndefinedKeyword" ? "nullable" : "unknown",
957
- name: e.sourceCode.text.slice(...r.range),
958
- size: I(r.range),
959
- node: r
955
+ order: m.asc
956
+ }), l = i.types.map((s) => ({
957
+ group: s.type === "TSNullKeyword" || s.type === "TSUndefinedKeyword" ? "nullable" : "unknown",
958
+ name: e.sourceCode.text.slice(...s.range),
959
+ size: I(s.range),
960
+ node: s
960
961
  }));
961
- P(l, (r, t) => {
962
- let a = O(S(r, t, s));
963
- s["nullable-last"] && (r.group === "nullable" && t.group === "unknown" ? a = !0 : r.group === "unknown" && t.group === "nullable" && (a = !1)), a && e.report({
962
+ P(l, (s, r) => {
963
+ let n = O(w(s, r, a));
964
+ a["nullable-last"] && (s.group === "nullable" && r.group === "unknown" ? n = !0 : s.group === "unknown" && r.group === "nullable" && (n = !1)), n && e.report({
964
965
  messageId: "unexpectedUnionTypesOrder",
965
966
  data: {
966
- left: k(r.name),
967
- right: k(t.name)
968
- },
969
- node: t.node,
970
- fix: (n) => {
971
- let o = [];
972
- if (s["nullable-last"]) {
973
- let p = [], f = l.filter((y) => y.group === "nullable" ? (p.push(y), !1) : !0);
974
- o = [
975
- ...v(f, s),
976
- ...v(p, s)
967
+ left: k(s.name),
968
+ right: k(r.name)
969
+ },
970
+ node: r.node,
971
+ fix: (p) => {
972
+ let t = [];
973
+ if (a["nullable-last"]) {
974
+ let o = [], f = l.filter((c) => c.group === "nullable" ? (o.push(c), !1) : !0);
975
+ t = [
976
+ ...v(f, a),
977
+ ...v(o, a)
977
978
  ];
978
979
  } else
979
- o = v(l, s);
980
- return M(n, l, o, e.sourceCode);
980
+ t = v(l, a);
981
+ return M(p, l, t, e.sourceCode);
981
982
  }
982
983
  });
983
984
  });
984
985
  }
985
986
  })
986
- }), re = "sort-interfaces", ve = A({
987
- name: re,
987
+ });
988
+ let B = (e) => {
989
+ switch (e.type) {
990
+ case fe.TSMethodSignature:
991
+ case fe.TSPropertySignature:
992
+ return e.optional;
993
+ }
994
+ return !1;
995
+ };
996
+ const ae = "sort-interfaces", ke = A({
997
+ name: ae,
988
998
  meta: {
989
999
  type: "suggestion",
990
1000
  docs: {
@@ -998,6 +1008,15 @@ const ee = "sort-object-types", Ne = A({
998
1008
  "custom-groups": {
999
1009
  type: "object"
1000
1010
  },
1011
+ "optionality-order": {
1012
+ enum: [
1013
+ G.ignore,
1014
+ G["optional-first"],
1015
+ G["required-first"]
1016
+ ],
1017
+ default: G.ignore,
1018
+ type: "string"
1019
+ },
1001
1020
  type: {
1002
1021
  enum: [
1003
1022
  u.alphabetical,
@@ -1008,8 +1027,8 @@ const ee = "sort-object-types", Ne = A({
1008
1027
  type: "string"
1009
1028
  },
1010
1029
  order: {
1011
- enum: [g.asc, g.desc],
1012
- default: g.asc,
1030
+ enum: [m.asc, m.desc],
1031
+ default: m.asc,
1013
1032
  type: "string"
1014
1033
  },
1015
1034
  "ignore-case": {
@@ -1041,100 +1060,128 @@ const ee = "sort-object-types", Ne = A({
1041
1060
  defaultOptions: [
1042
1061
  {
1043
1062
  type: u.alphabetical,
1044
- order: g.asc
1063
+ order: m.asc
1045
1064
  }
1046
1065
  ],
1047
1066
  create: (e) => ({
1048
1067
  TSInterfaceDeclaration: (i) => {
1049
1068
  if (i.body.body.length > 1) {
1050
- let s = j(e.options.at(0), {
1069
+ let a = j(e.options.at(0), {
1070
+ "optionality-order": G.ignore,
1051
1071
  "partition-by-new-line": !1,
1052
1072
  type: u.alphabetical,
1053
1073
  "ignore-case": !1,
1054
- order: g.asc,
1074
+ order: m.asc,
1055
1075
  "ignore-pattern": [],
1056
1076
  "custom-groups": {},
1057
1077
  groups: []
1058
1078
  });
1059
- if (!s["ignore-pattern"].some(
1060
- (l) => D(i.id.name, l, {
1079
+ if (!a["ignore-pattern"].some(
1080
+ (l) => U(i.id.name, l, {
1061
1081
  nocomment: !0
1062
1082
  })
1063
1083
  )) {
1064
1084
  let l = i.body.body.reduce(
1065
- (r, t) => {
1066
- var d, c, m, x;
1067
- if (t.type === "TSCallSignatureDeclaration")
1068
- return r.push([]), r;
1069
- let a = (d = r.at(-1)) == null ? void 0 : d.at(-1), n, { getGroup: o, defineGroup: p, setCustomGroups: f } = G(
1070
- s.groups
1085
+ (t, o) => {
1086
+ var C, h, N, x;
1087
+ if (o.type === "TSCallSignatureDeclaration")
1088
+ return t.push([]), t;
1089
+ let f = (C = t.at(-1)) == null ? void 0 : C.at(-1), c, { getGroup: d, defineGroup: g, setCustomGroups: y } = R(
1090
+ a.groups
1071
1091
  );
1072
- if (t.type === "TSPropertySignature")
1073
- if (t.key.type === "Identifier")
1074
- ({ name: n } = t.key);
1075
- else if (t.key.type === "Literal")
1076
- n = `${t.key.value}`;
1092
+ if (o.type === "TSPropertySignature")
1093
+ if (o.key.type === "Identifier")
1094
+ ({ name: c } = o.key);
1095
+ else if (o.key.type === "Literal")
1096
+ c = `${o.key.value}`;
1077
1097
  else {
1078
- let C = ((c = t.typeAnnotation) == null ? void 0 : c.range.at(0)) ?? t.range.at(1) - (t.optional ? 1 : 0);
1079
- n = e.sourceCode.text.slice(t.range.at(0), C);
1098
+ let S = ((h = o.typeAnnotation) == null ? void 0 : h.range.at(0)) ?? o.range.at(1) - (o.optional ? 1 : 0);
1099
+ c = e.sourceCode.text.slice(o.range.at(0), S);
1080
1100
  }
1081
- else if (t.type === "TSIndexSignature") {
1082
- let C = ((m = t.typeAnnotation) == null ? void 0 : m.range.at(0)) ?? t.range.at(1);
1083
- n = e.sourceCode.text.slice(
1084
- t.range.at(0),
1085
- C
1101
+ else if (o.type === "TSIndexSignature") {
1102
+ let S = ((N = o.typeAnnotation) == null ? void 0 : N.range.at(0)) ?? o.range.at(1);
1103
+ c = e.sourceCode.text.slice(
1104
+ o.range.at(0),
1105
+ S
1086
1106
  );
1087
1107
  } else {
1088
- let C = ((x = t.returnType) == null ? void 0 : x.range.at(0)) ?? t.range.at(1);
1089
- n = e.sourceCode.text.slice(
1090
- t.range.at(0),
1091
- C
1108
+ let S = ((x = o.returnType) == null ? void 0 : x.range.at(0)) ?? o.range.at(1);
1109
+ c = e.sourceCode.text.slice(
1110
+ o.range.at(0),
1111
+ S
1092
1112
  );
1093
1113
  }
1094
- let y = {
1095
- size: I(t.range),
1096
- node: t,
1097
- name: n
1114
+ let b = {
1115
+ size: I(o.range),
1116
+ node: o,
1117
+ name: c
1098
1118
  };
1099
- return s["partition-by-new-line"] && a && z(
1119
+ return a["partition-by-new-line"] && f && W(
1100
1120
  e.sourceCode,
1101
- a,
1102
- y
1103
- ) && r.push([]), f(s["custom-groups"], n), t.loc.start.line !== t.loc.end.line && p("multiline"), r.at(-1).push({
1104
- ...y,
1105
- group: o()
1106
- }), r;
1121
+ f,
1122
+ b
1123
+ ) && t.push([]), y(a["custom-groups"], c), o.loc.start.line !== o.loc.end.line && g("multiline"), t.at(-1).push({
1124
+ ...b,
1125
+ group: d()
1126
+ }), t;
1107
1127
  },
1108
1128
  [[]]
1109
- );
1110
- for (let r of l)
1111
- P(r, (t, a) => {
1112
- let n = h(s.groups, t), o = h(s.groups, a);
1113
- (n > o || n === o && O(S(t, a, s))) && e.report({
1129
+ ), s = (t) => {
1130
+ let o = {};
1131
+ for (let c of t) {
1132
+ let d = E(a.groups, c);
1133
+ d in o ? o[d] = v(
1134
+ [...o[d], c],
1135
+ a
1136
+ ) : o[d] = [c];
1137
+ }
1138
+ let f = [];
1139
+ for (let c of Object.keys(o).sort(
1140
+ (d, g) => Number(d) - Number(g)
1141
+ ))
1142
+ f.push(...v(o[c], a));
1143
+ return f;
1144
+ }, r = (t, o) => {
1145
+ let f = E(a.groups, t), c = E(a.groups, o);
1146
+ return f > c || f === c && O(w(t, o, a));
1147
+ }, n = a["optionality-order"], p = (t, o, f, c) => {
1148
+ if (n === G.ignore)
1149
+ return r(o, f);
1150
+ let d = t.findIndex(
1151
+ (g, y) => y && B(t[y - 1].node) !== B(t[y].node)
1152
+ );
1153
+ return c < d && c + 1 !== d ? r(o, f) : B(o.node) !== B(f.node) ? B(o.node) !== (n === G["optional-first"]) : r(o, f);
1154
+ };
1155
+ for (let t of l)
1156
+ P(t, (o, f, c) => {
1157
+ p(t, o, f, c) && e.report({
1114
1158
  messageId: "unexpectedInterfacePropertiesOrder",
1115
1159
  data: {
1116
- left: k(t.name),
1117
- right: k(a.name)
1160
+ left: k(o.name),
1161
+ right: k(f.name)
1118
1162
  },
1119
- node: a.node,
1120
- fix: (p) => {
1121
- let f = {};
1122
- for (let d of r) {
1123
- let c = h(s.groups, d);
1124
- c in f ? f[c] = v(
1125
- [...f[c], d],
1126
- s
1127
- ) : f[c] = [d];
1128
- }
1129
- let y = [];
1130
- for (let d of Object.keys(f).sort(
1131
- (c, m) => Number(c) - Number(m)
1132
- ))
1133
- y.push(...v(f[d], s));
1163
+ node: f.node,
1164
+ fix: (d) => {
1165
+ let g;
1166
+ if (n !== G.ignore) {
1167
+ let y = t.filter(
1168
+ (C) => B(C.node)
1169
+ ), b = t.filter(
1170
+ (C) => !B(C.node)
1171
+ );
1172
+ g = n === G["optional-first"] ? [
1173
+ ...s(y),
1174
+ ...s(b)
1175
+ ] : [
1176
+ ...s(b),
1177
+ ...s(y)
1178
+ ];
1179
+ } else
1180
+ g = s(t);
1134
1181
  return M(
1135
- p,
1136
- r,
1137
- y,
1182
+ d,
1183
+ t,
1184
+ g,
1138
1185
  e.sourceCode
1139
1186
  );
1140
1187
  }
@@ -1144,8 +1191,8 @@ const ee = "sort-object-types", Ne = A({
1144
1191
  }
1145
1192
  }
1146
1193
  })
1147
- }), se = "sort-jsx-props", we = A({
1148
- name: se,
1194
+ }), oe = "sort-jsx-props", Ae = A({
1195
+ name: oe,
1149
1196
  meta: {
1150
1197
  type: "suggestion",
1151
1198
  docs: {
@@ -1169,8 +1216,8 @@ const ee = "sort-object-types", Ne = A({
1169
1216
  type: "string"
1170
1217
  },
1171
1218
  order: {
1172
- enum: [g.asc, g.desc],
1173
- default: g.asc,
1219
+ enum: [m.asc, m.desc],
1220
+ default: m.asc,
1174
1221
  type: "string"
1175
1222
  },
1176
1223
  groups: {
@@ -1191,64 +1238,64 @@ const ee = "sort-object-types", Ne = A({
1191
1238
  defaultOptions: [
1192
1239
  {
1193
1240
  type: u.alphabetical,
1194
- order: g.asc
1241
+ order: m.asc
1195
1242
  }
1196
1243
  ],
1197
- create: (e) => [".svelte", ".astro", ".vue"].includes(W.extname(e.filename)) ? {} : {
1244
+ create: (e) => [".svelte", ".astro", ".vue"].includes(q.extname(e.filename)) ? {} : {
1198
1245
  JSXElement: (i) => {
1199
1246
  if (i.openingElement.attributes.length > 1) {
1200
- let s = j(e.options.at(0), {
1247
+ let a = j(e.options.at(0), {
1201
1248
  type: u.alphabetical,
1202
1249
  "ignore-case": !1,
1203
- order: g.asc,
1250
+ order: m.asc,
1204
1251
  "custom-groups": {},
1205
1252
  groups: []
1206
1253
  }), l = i.openingElement.attributes.reduce(
1207
- (r, t) => {
1208
- if (t.type === "JSXSpreadAttribute")
1209
- return r.push([]), r;
1210
- let a = t.name.type === "JSXNamespacedName" ? `${t.name.namespace.name}:${t.name.name.name}` : t.name.name, { getGroup: n, defineGroup: o, setCustomGroups: p } = G(
1211
- s.groups
1254
+ (s, r) => {
1255
+ if (r.type === "JSXSpreadAttribute")
1256
+ return s.push([]), s;
1257
+ let n = r.name.type === "JSXNamespacedName" ? `${r.name.namespace.name}:${r.name.name.name}` : r.name.name, { getGroup: p, defineGroup: t, setCustomGroups: o } = R(
1258
+ a.groups
1212
1259
  );
1213
- p(s["custom-groups"], a), t.value === null && o("shorthand"), t.loc.start.line !== t.loc.end.line && o("multiline");
1260
+ o(a["custom-groups"], n), r.value === null && t("shorthand"), r.loc.start.line !== r.loc.end.line && t("multiline");
1214
1261
  let f = {
1215
- size: I(t.range),
1216
- group: n(),
1217
- node: t,
1218
- name: a
1262
+ size: I(r.range),
1263
+ group: p(),
1264
+ node: r,
1265
+ name: n
1219
1266
  };
1220
- return r.at(-1).push(f), r;
1267
+ return s.at(-1).push(f), s;
1221
1268
  },
1222
1269
  [[]]
1223
1270
  );
1224
- for (let r of l)
1225
- P(r, (t, a) => {
1226
- let n = h(s.groups, t), o = h(s.groups, a);
1227
- (n > o || n === o && O(S(t, a, s))) && e.report({
1271
+ for (let s of l)
1272
+ P(s, (r, n) => {
1273
+ let p = E(a.groups, r), t = E(a.groups, n);
1274
+ (p > t || p === t && O(w(r, n, a))) && e.report({
1228
1275
  messageId: "unexpectedJSXPropsOrder",
1229
1276
  data: {
1230
- left: t.name,
1231
- right: a.name
1277
+ left: r.name,
1278
+ right: n.name
1232
1279
  },
1233
- node: a.node,
1234
- fix: (p) => {
1280
+ node: n.node,
1281
+ fix: (o) => {
1235
1282
  let f = {};
1236
- for (let d of r) {
1237
- let c = h(s.groups, d);
1238
- c in f ? f[c] = v(
1239
- [...f[c], d],
1240
- s
1241
- ) : f[c] = [d];
1283
+ for (let d of s) {
1284
+ let g = E(a.groups, d);
1285
+ g in f ? f[g] = v(
1286
+ [...f[g], d],
1287
+ a
1288
+ ) : f[g] = [d];
1242
1289
  }
1243
- let y = [];
1290
+ let c = [];
1244
1291
  for (let d of Object.keys(f).sort(
1245
- (c, m) => Number(c) - Number(m)
1292
+ (g, y) => Number(g) - Number(y)
1246
1293
  ))
1247
- y.push(...v(f[d], s));
1294
+ c.push(...v(f[d], a));
1248
1295
  return M(
1249
- p,
1250
- r,
1251
- y,
1296
+ o,
1297
+ s,
1298
+ c,
1252
1299
  e.sourceCode
1253
1300
  );
1254
1301
  }
@@ -1257,8 +1304,8 @@ const ee = "sort-object-types", Ne = A({
1257
1304
  }
1258
1305
  }
1259
1306
  }
1260
- }), ae = "sort-exports", Se = A({
1261
- name: ae,
1307
+ }), ne = "sort-exports", Ie = A({
1308
+ name: ne,
1262
1309
  meta: {
1263
1310
  type: "suggestion",
1264
1311
  docs: {
@@ -1279,8 +1326,8 @@ const ee = "sort-object-types", Ne = A({
1279
1326
  type: "string"
1280
1327
  },
1281
1328
  order: {
1282
- enum: [g.asc, g.desc],
1283
- default: g.asc,
1329
+ enum: [m.asc, m.desc],
1330
+ default: m.asc,
1284
1331
  type: "string"
1285
1332
  },
1286
1333
  "ignore-case": {
@@ -1298,40 +1345,40 @@ const ee = "sort-object-types", Ne = A({
1298
1345
  defaultOptions: [
1299
1346
  {
1300
1347
  type: u.alphabetical,
1301
- order: g.asc
1348
+ order: m.asc
1302
1349
  }
1303
1350
  ],
1304
1351
  create: (e) => {
1305
1352
  let i = j(e.options.at(0), {
1306
1353
  type: u.alphabetical,
1307
- order: g.asc,
1354
+ order: m.asc,
1308
1355
  "ignore-case": !1
1309
- }), s = [[]], l = (r) => {
1310
- r.type === "ExportAllDeclaration" && r.exported === null ? s.push([]) : s.at(-1).push({
1311
- size: I(r.range),
1312
- name: r.source.value,
1313
- node: r
1356
+ }), a = [[]], l = (s) => {
1357
+ s.type === "ExportAllDeclaration" && s.exported === null ? a.push([]) : a.at(-1).push({
1358
+ size: I(s.range),
1359
+ name: s.source.value,
1360
+ node: s
1314
1361
  });
1315
1362
  };
1316
1363
  return {
1317
1364
  ExportAllDeclaration: l,
1318
- ExportNamedDeclaration: (r) => {
1319
- r.source !== null && l(r);
1365
+ ExportNamedDeclaration: (s) => {
1366
+ s.source !== null && l(s);
1320
1367
  },
1321
1368
  "Program:exit": () => {
1322
- for (let r of s)
1323
- P(r, (t, a) => {
1324
- O(S(t, a, i)) && e.report({
1369
+ for (let s of a)
1370
+ P(s, (r, n) => {
1371
+ O(w(r, n, i)) && e.report({
1325
1372
  messageId: "unexpectedExportsOrder",
1326
1373
  data: {
1327
- left: t.name,
1328
- right: a.name
1374
+ left: r.name,
1375
+ right: n.name
1329
1376
  },
1330
- node: a.node,
1331
- fix: (n) => M(
1332
- n,
1333
- r,
1334
- v(r, i),
1377
+ node: n.node,
1378
+ fix: (p) => M(
1379
+ p,
1380
+ s,
1381
+ v(s, i),
1335
1382
  e.sourceCode
1336
1383
  )
1337
1384
  });
@@ -1339,8 +1386,8 @@ const ee = "sort-object-types", Ne = A({
1339
1386
  }
1340
1387
  };
1341
1388
  }
1342
- }), oe = "sort-imports", ke = A({
1343
- name: oe,
1389
+ }), le = "sort-imports", Oe = A({
1390
+ name: le,
1344
1391
  meta: {
1345
1392
  type: "suggestion",
1346
1393
  docs: {
@@ -1374,8 +1421,8 @@ const ee = "sort-object-types", Ne = A({
1374
1421
  type: "string"
1375
1422
  },
1376
1423
  order: {
1377
- enum: [g.asc, g.desc],
1378
- default: g.asc,
1424
+ enum: [m.asc, m.desc],
1425
+ default: m.asc,
1379
1426
  type: "string"
1380
1427
  },
1381
1428
  "ignore-case": {
@@ -1444,7 +1491,7 @@ const ee = "sort-object-types", Ne = A({
1444
1491
  defaultOptions: [
1445
1492
  {
1446
1493
  type: u.alphabetical,
1447
- order: g.asc
1494
+ order: m.asc
1448
1495
  }
1449
1496
  ],
1450
1497
  create: (e) => {
@@ -1453,21 +1500,21 @@ const ee = "sort-object-types", Ne = A({
1453
1500
  "custom-groups": { type: {}, value: {} },
1454
1501
  "internal-pattern": ["~/**"],
1455
1502
  type: u.alphabetical,
1456
- order: g.asc,
1503
+ order: m.asc,
1457
1504
  "ignore-case": !1,
1458
1505
  groups: []
1459
- }), s = !1;
1460
- for (let o of i.groups)
1461
- if (Array.isArray(o))
1462
- for (let p of o)
1463
- p === "unknown" && (s = !0);
1506
+ }), a = !1;
1507
+ for (let t of i.groups)
1508
+ if (Array.isArray(t))
1509
+ for (let o of t)
1510
+ o === "unknown" && (a = !0);
1464
1511
  else
1465
- o === "unknown" && (s = !0);
1466
- s || (i.groups = [...i.groups, "unknown"]);
1467
- let l = [], r = (o) => o.type === "ImportDeclaration" && o.specifiers.length === 0, t = (o) => {
1468
- let p = (E) => [".less", ".scss", ".sass", ".styl", ".pcss", ".css", ".sss"].some(
1469
- (w) => E.endsWith(w)
1470
- ), f = (E) => [
1512
+ t === "unknown" && (a = !0);
1513
+ a || (i.groups = [...i.groups, "unknown"]);
1514
+ let l = [], s = (t) => t.type === "ImportDeclaration" && t.specifiers.length === 0, r = (t) => {
1515
+ let o = (x) => [".less", ".scss", ".sass", ".styl", ".pcss", ".css", ".sss"].some(
1516
+ (S) => x.endsWith(S)
1517
+ ), f = (x) => [
1471
1518
  "./index.d.js",
1472
1519
  "./index.d.ts",
1473
1520
  "./index.js",
@@ -1475,12 +1522,12 @@ const ee = "sort-object-types", Ne = A({
1475
1522
  "./index",
1476
1523
  "./",
1477
1524
  "."
1478
- ].includes(E), y = (E) => E.indexOf("..") === 0, d = (E) => E.indexOf("./") === 0, { getGroup: c, defineGroup: m, setCustomGroups: x } = G(i.groups), C = (E) => i["internal-pattern"].length && i["internal-pattern"].some(
1479
- (w) => D(E.source.value, w, {
1525
+ ].includes(x), c = (x) => x.indexOf("..") === 0, d = (x) => x.indexOf("./") === 0, { getGroup: g, defineGroup: y, setCustomGroups: b } = R(i.groups), C = (x) => i["internal-pattern"].length && i["internal-pattern"].some(
1526
+ (S) => U(x.source.value, S, {
1480
1527
  nocomment: !0
1481
1528
  })
1482
- ), b = (E) => {
1483
- let w = [
1529
+ ), h = (x) => {
1530
+ let S = [
1484
1531
  "bun",
1485
1532
  "bun:ffi",
1486
1533
  "bun:jsc",
@@ -1491,98 +1538,98 @@ const ee = "sort-object-types", Ne = A({
1491
1538
  "undici",
1492
1539
  "ws"
1493
1540
  ];
1494
- return fe.includes(
1495
- E.startsWith("node:") ? E.split("node:")[1] : E
1496
- ) || w.includes(E);
1497
- }, N = (E) => !(E.startsWith(".") || E.startsWith("/"));
1498
- return o.importKind === "type" && (o.type === "ImportDeclaration" && (x(i["custom-groups"].type, o.source.value), f(o.source.value) && m("index-type"), d(o.source.value) && m("sibling-type"), y(o.source.value) && m("parent-type"), C(o) && m("internal-type"), b(o.source.value) && m("builtin-type"), N(o.source.value) && m("external-type")), m("type")), o.type === "ImportDeclaration" && (x(i["custom-groups"].value, o.source.value), r(o) && p(o.source.value) && m("side-effect-style"), r(o) && m("side-effect"), p(o.source.value) && m("style"), f(o.source.value) && m("index"), d(o.source.value) && m("sibling"), y(o.source.value) && m("parent"), C(o) && m("internal"), b(o.source.value) && m("builtin"), N(o.source.value) && m("external")), c();
1499
- }, a = (o) => o.specifiers.length > 1, n = (o) => {
1500
- let p;
1501
- o.type === "ImportDeclaration" ? p = o.source.value : o.moduleReference.type === "TSExternalModuleReference" && o.moduleReference.expression.type === "Literal" ? p = `${o.moduleReference.expression.value}` : p = e.sourceCode.text.slice(...o.moduleReference.range), l.push({
1502
- size: I(o.range),
1503
- group: t(o),
1504
- name: p,
1505
- node: o,
1541
+ return me.includes(
1542
+ x.startsWith("node:") ? x.split("node:")[1] : x
1543
+ ) || S.includes(x);
1544
+ }, N = (x) => !(x.startsWith(".") || x.startsWith("/"));
1545
+ return t.importKind === "type" && (t.type === "ImportDeclaration" && (b(i["custom-groups"].type, t.source.value), f(t.source.value) && y("index-type"), d(t.source.value) && y("sibling-type"), c(t.source.value) && y("parent-type"), C(t) && y("internal-type"), h(t.source.value) && y("builtin-type"), N(t.source.value) && y("external-type")), y("type")), t.type === "ImportDeclaration" && (b(i["custom-groups"].value, t.source.value), s(t) && o(t.source.value) && y("side-effect-style"), s(t) && y("side-effect"), o(t.source.value) && y("style"), f(t.source.value) && y("index"), d(t.source.value) && y("sibling"), c(t.source.value) && y("parent"), C(t) && y("internal"), h(t.source.value) && y("builtin"), N(t.source.value) && y("external")), g();
1546
+ }, n = (t) => t.specifiers.length > 1, p = (t) => {
1547
+ let o;
1548
+ t.type === "ImportDeclaration" ? o = t.source.value : t.moduleReference.type === "TSExternalModuleReference" && t.moduleReference.expression.type === "Literal" ? o = `${t.moduleReference.expression.value}` : o = e.sourceCode.text.slice(...t.moduleReference.range), l.push({
1549
+ size: I(t.range),
1550
+ group: r(t),
1551
+ name: o,
1552
+ node: t,
1506
1553
  ...i.type === u["line-length"] && i["max-line-length"] && {
1507
- hasMultipleImportDeclarations: a(
1508
- o
1554
+ hasMultipleImportDeclarations: n(
1555
+ t
1509
1556
  )
1510
1557
  }
1511
1558
  });
1512
1559
  };
1513
1560
  return {
1514
- TSImportEqualsDeclaration: n,
1515
- ImportDeclaration: n,
1561
+ TSImportEqualsDeclaration: p,
1562
+ ImportDeclaration: p,
1516
1563
  "Program:exit": () => {
1517
- var y;
1518
- let o = (d, c) => !!e.sourceCode.getTokensBetween(
1564
+ var c;
1565
+ let t = (d, g) => !!e.sourceCode.getTokensBetween(
1519
1566
  d.node,
1520
- V(c.node, e.sourceCode) || c.node,
1567
+ K(g.node, e.sourceCode) || g.node,
1521
1568
  {
1522
1569
  includeComments: !0
1523
1570
  }
1524
- ).length, p = (d, c) => {
1525
- let m = [], x = {};
1526
- for (let b of c) {
1527
- let N = h(i.groups, b);
1528
- N in x ? x[N] = v(
1529
- [...x[N], b],
1571
+ ).length, o = (d, g) => {
1572
+ let y = [], b = {};
1573
+ for (let h of g) {
1574
+ let N = E(i.groups, h);
1575
+ N in b ? b[N] = v(
1576
+ [...b[N], h],
1530
1577
  i
1531
- ) : x[N] = [b];
1578
+ ) : b[N] = [h];
1532
1579
  }
1533
- let C = Object.keys(x).sort((b, N) => Number(b) - Number(N)).reduce(
1534
- (b, N) => [
1535
- ...b,
1536
- ...x[N]
1580
+ let C = Object.keys(b).sort((h, N) => Number(h) - Number(N)).reduce(
1581
+ (h, N) => [
1582
+ ...h,
1583
+ ...b[N]
1537
1584
  ],
1538
1585
  []
1539
1586
  );
1540
- for (let b = 0, N = C.length; b < N; b++) {
1541
- let E = C.at(b);
1542
- if (m.push(
1587
+ for (let h = 0, N = C.length; h < N; h++) {
1588
+ let x = C.at(h);
1589
+ if (y.push(
1543
1590
  d.replaceTextRange(
1544
- T(c.at(b).node, e.sourceCode),
1591
+ L(g.at(h).node, e.sourceCode),
1545
1592
  e.sourceCode.text.slice(
1546
- ...T(E.node, e.sourceCode)
1593
+ ...L(x.node, e.sourceCode)
1547
1594
  )
1548
1595
  )
1549
1596
  ), i["newlines-between"] !== "ignore") {
1550
- let w = C.at(b + 1);
1551
- if (w) {
1552
- let R = z(
1597
+ let S = C.at(h + 1);
1598
+ if (S) {
1599
+ let $ = W(
1553
1600
  e.sourceCode,
1554
- c.at(b),
1555
- c.at(b + 1)
1601
+ g.at(h),
1602
+ g.at(h + 1)
1556
1603
  );
1557
- (i["newlines-between"] === "always" && h(i.groups, E) === h(i.groups, w) && R !== 0 || i["newlines-between"] === "never" && R > 0) && m.push(
1604
+ (i["newlines-between"] === "always" && E(i.groups, x) === E(i.groups, S) && $ !== 0 || i["newlines-between"] === "never" && $ > 0) && y.push(
1558
1605
  d.removeRange([
1559
- T(
1560
- c.at(b).node,
1606
+ L(
1607
+ g.at(h).node,
1561
1608
  e.sourceCode
1562
1609
  ).at(1),
1563
- T(
1564
- c.at(b + 1).node,
1610
+ L(
1611
+ g.at(h + 1).node,
1565
1612
  e.sourceCode
1566
1613
  ).at(0) - 1
1567
1614
  ])
1568
- ), i["newlines-between"] === "always" && h(i.groups, E) !== h(i.groups, w) && R > 1 && m.push(
1615
+ ), i["newlines-between"] === "always" && E(i.groups, x) !== E(i.groups, S) && $ > 1 && y.push(
1569
1616
  d.replaceTextRange(
1570
1617
  [
1571
- T(
1572
- c.at(b).node,
1618
+ L(
1619
+ g.at(h).node,
1573
1620
  e.sourceCode
1574
1621
  ).at(1),
1575
- T(
1576
- c.at(b + 1).node,
1622
+ L(
1623
+ g.at(h + 1).node,
1577
1624
  e.sourceCode
1578
1625
  ).at(0) - 1
1579
1626
  ],
1580
1627
  `
1581
1628
  `
1582
1629
  )
1583
- ), i["newlines-between"] === "always" && h(i.groups, E) !== h(i.groups, w) && R === 0 && m.push(
1630
+ ), i["newlines-between"] === "always" && E(i.groups, x) !== E(i.groups, S) && $ === 0 && y.push(
1584
1631
  d.insertTextAfterRange(
1585
- T(c.at(b).node, e.sourceCode),
1632
+ L(g.at(h).node, e.sourceCode),
1586
1633
  `
1587
1634
  `
1588
1635
  )
@@ -1590,58 +1637,58 @@ const ee = "sort-object-types", Ne = A({
1590
1637
  }
1591
1638
  }
1592
1639
  }
1593
- return m;
1640
+ return y;
1594
1641
  }, f = [[]];
1595
1642
  for (let d of l) {
1596
- let c = (y = f.at(-1)) == null ? void 0 : y.at(-1);
1597
- c && o(c, d) ? f.push([d]) : f.at(-1).push(d);
1643
+ let g = (c = f.at(-1)) == null ? void 0 : c.at(-1);
1644
+ g && t(g, d) ? f.push([d]) : f.at(-1).push(d);
1598
1645
  }
1599
1646
  for (let d of f)
1600
- P(d, (c, m) => {
1601
- let x = h(i.groups, c), C = h(i.groups, m), b = z(
1647
+ P(d, (g, y) => {
1648
+ let b = E(i.groups, g), C = E(i.groups, y), h = W(
1602
1649
  e.sourceCode,
1603
- c,
1604
- m
1650
+ g,
1651
+ y
1605
1652
  );
1606
- !(r(c.node) && r(m.node)) && !o(c, m) && (x > C || x === C && O(S(c, m, i))) && e.report({
1653
+ !(s(g.node) && s(y.node)) && !t(g, y) && (b > C || b === C && O(w(g, y, i))) && e.report({
1607
1654
  messageId: "unexpectedImportsOrder",
1608
1655
  data: {
1609
- left: c.name,
1610
- right: m.name
1656
+ left: g.name,
1657
+ right: y.name
1611
1658
  },
1612
- node: m.node,
1613
- fix: (N) => p(N, d)
1614
- }), i["newlines-between"] === "never" && b > 0 && e.report({
1659
+ node: y.node,
1660
+ fix: (N) => o(N, d)
1661
+ }), i["newlines-between"] === "never" && h > 0 && e.report({
1615
1662
  messageId: "extraSpacingBetweenImports",
1616
1663
  data: {
1617
- left: c.name,
1618
- right: m.name
1664
+ left: g.name,
1665
+ right: y.name
1619
1666
  },
1620
- node: m.node,
1621
- fix: (N) => p(N, d)
1622
- }), i["newlines-between"] === "always" && (x < C && b === 0 ? e.report({
1667
+ node: y.node,
1668
+ fix: (N) => o(N, d)
1669
+ }), i["newlines-between"] === "always" && (b < C && h === 0 ? e.report({
1623
1670
  messageId: "missedSpacingBetweenImports",
1624
1671
  data: {
1625
- left: c.name,
1626
- right: m.name
1672
+ left: g.name,
1673
+ right: y.name
1627
1674
  },
1628
- node: m.node,
1629
- fix: (N) => p(N, d)
1630
- }) : (b > 1 || x === C && b > 0) && e.report({
1675
+ node: y.node,
1676
+ fix: (N) => o(N, d)
1677
+ }) : (h > 1 || b === C && h > 0) && e.report({
1631
1678
  messageId: "extraSpacingBetweenImports",
1632
1679
  data: {
1633
- left: c.name,
1634
- right: m.name
1680
+ left: g.name,
1681
+ right: y.name
1635
1682
  },
1636
- node: m.node,
1637
- fix: (N) => p(N, d)
1683
+ node: y.node,
1684
+ fix: (N) => o(N, d)
1638
1685
  }));
1639
1686
  });
1640
1687
  }
1641
1688
  };
1642
1689
  }
1643
- }), ne = "sort-objects", Ae = A({
1644
- name: ne,
1690
+ }), ie = "sort-objects", je = A({
1691
+ name: ie,
1645
1692
  meta: {
1646
1693
  type: "suggestion",
1647
1694
  docs: {
@@ -1677,8 +1724,8 @@ const ee = "sort-object-types", Ne = A({
1677
1724
  type: "string"
1678
1725
  },
1679
1726
  order: {
1680
- enum: [g.asc, g.desc],
1681
- default: g.asc,
1727
+ enum: [m.asc, m.desc],
1728
+ default: m.asc,
1682
1729
  type: "string"
1683
1730
  },
1684
1731
  "ignore-case": {
@@ -1705,11 +1752,11 @@ const ee = "sort-object-types", Ne = A({
1705
1752
  defaultOptions: [
1706
1753
  {
1707
1754
  type: u.alphabetical,
1708
- order: g.asc
1755
+ order: m.asc
1709
1756
  }
1710
1757
  ],
1711
1758
  create: (e) => {
1712
- let i = (s) => {
1759
+ let i = (a) => {
1713
1760
  let l = j(e.options.at(0), {
1714
1761
  "partition-by-new-line": !1,
1715
1762
  "partition-by-comment": !1,
@@ -1717,100 +1764,100 @@ const ee = "sort-object-types", Ne = A({
1717
1764
  "styled-components": !0,
1718
1765
  "ignore-case": !1,
1719
1766
  "ignore-pattern": [],
1720
- order: g.asc,
1767
+ order: m.asc,
1721
1768
  "custom-groups": {},
1722
1769
  groups: []
1723
- }), r = s.parent.type === "VariableDeclarator" && s.parent.id.type === "Identifier" ? s.parent.id.name : null;
1724
- if (!(l["ignore-pattern"].length && typeof r == "string" ? l["ignore-pattern"].some(
1725
- (a) => D(r, a, {
1770
+ }), s = a.parent.type === "VariableDeclarator" && a.parent.id.type === "Identifier" ? a.parent.id.name : null;
1771
+ if (!(l["ignore-pattern"].length && typeof s == "string" ? l["ignore-pattern"].some(
1772
+ (n) => U(s, n, {
1726
1773
  nocomment: !0
1727
1774
  })
1728
- ) : !1) && s.properties.length > 1) {
1729
- let a = (p) => p.type === "Identifier" && p.name === "styled", n = (p) => p !== void 0 && p.type === "CallExpression" && (p.callee.type === "MemberExpression" && a(p.callee.object) || p.callee.type === "CallExpression" && a(p.callee.callee));
1730
- if (!l["styled-components"] && (n(s.parent) || s.parent.type === "ArrowFunctionExpression" && n(s.parent.parent)))
1775
+ ) : !1) && a.properties.length > 1) {
1776
+ let n = (o) => o.type === "Identifier" && o.name === "styled", p = (o) => o !== void 0 && o.type === "CallExpression" && (o.callee.type === "MemberExpression" && n(o.callee.object) || o.callee.type === "CallExpression" && n(o.callee.callee));
1777
+ if (!l["styled-components"] && (p(a.parent) || a.parent.type === "ArrowFunctionExpression" && p(a.parent.parent)))
1731
1778
  return;
1732
- let o = (p) => p.reduce(
1733
- (f, y) => {
1734
- var R;
1735
- if (y.type === "SpreadElement" || y.type === "RestElement")
1779
+ let t = (o) => o.reduce(
1780
+ (f, c) => {
1781
+ var $;
1782
+ if (c.type === "SpreadElement" || c.type === "RestElement")
1736
1783
  return f.push([]), f;
1737
- let d = V(y, e.sourceCode), c = (R = f.at(-1)) == null ? void 0 : R.at(-1);
1738
- l["partition-by-comment"] && d && X(
1784
+ let d = K(c, e.sourceCode), g = ($ = f.at(-1)) == null ? void 0 : $.at(-1);
1785
+ l["partition-by-comment"] && d && Y(
1739
1786
  l["partition-by-comment"],
1740
1787
  d.value
1741
1788
  ) && f.push([]);
1742
- let m, x = "ignore", C = [], { getGroup: b, setCustomGroups: N } = G(l.groups);
1743
- y.key.type === "Identifier" ? { name: m } = y.key : y.key.type === "Literal" ? m = `${y.key.value}` : m = e.sourceCode.text.slice(...y.key.range);
1744
- let E = {
1745
- size: I(y.range),
1746
- node: y,
1747
- name: m
1789
+ let y, b = "ignore", C = [], { getGroup: h, setCustomGroups: N } = R(l.groups);
1790
+ c.key.type === "Identifier" ? { name: y } = c.key : c.key.type === "Literal" ? y = `${c.key.value}` : y = e.sourceCode.text.slice(...c.key.range);
1791
+ let x = {
1792
+ size: I(c.range),
1793
+ node: c,
1794
+ name: y
1748
1795
  };
1749
- l["partition-by-new-line"] && c && z(e.sourceCode, c, E) && f.push([]), y.value.type === "AssignmentPattern" && ((_) => {
1750
- _.right.type === "Identifier" && C.push(_.right.name);
1751
- let ue = ($) => {
1752
- let B = [];
1753
- switch ($.type) {
1796
+ l["partition-by-new-line"] && g && W(e.sourceCode, g, x) && f.push([]), c.value.type === "AssignmentPattern" && ((V) => {
1797
+ V.right.type === "Identifier" && C.push(V.right.name);
1798
+ let ce = (D) => {
1799
+ let z = [];
1800
+ switch (D.type) {
1754
1801
  case "ArrowFunctionExpression":
1755
- B.push($.body);
1802
+ z.push(D.body);
1756
1803
  break;
1757
1804
  case "ConditionalExpression":
1758
- B.push($.consequent, $.alternate);
1805
+ z.push(D.consequent, D.alternate);
1759
1806
  break;
1760
1807
  case "LogicalExpression":
1761
1808
  case "BinaryExpression":
1762
- B.push($.left, $.right);
1809
+ z.push(D.left, D.right);
1763
1810
  break;
1764
1811
  case "CallExpression":
1765
- B.push(...$.arguments);
1812
+ z.push(...D.arguments);
1766
1813
  break;
1767
1814
  }
1768
- B.forEach((U) => {
1769
- U.type === "Identifier" && C.push(U.name), (U.type === "BinaryExpression" || U.type === "ConditionalExpression") && ue(U);
1815
+ z.forEach((_) => {
1816
+ _.type === "Identifier" && C.push(_.name), (_.type === "BinaryExpression" || _.type === "ConditionalExpression") && ce(_);
1770
1817
  });
1771
1818
  };
1772
- switch (_.right.type) {
1819
+ switch (V.right.type) {
1773
1820
  case "ArrowFunctionExpression":
1774
1821
  case "ConditionalExpression":
1775
1822
  case "LogicalExpression":
1776
1823
  case "BinaryExpression":
1777
1824
  case "CallExpression":
1778
- ue(_.right);
1825
+ ce(V.right);
1779
1826
  break;
1780
1827
  }
1781
- })(y.value), N(l["custom-groups"], m);
1782
- let w = {
1783
- ...E,
1784
- group: b(),
1828
+ })(c.value), N(l["custom-groups"], y);
1829
+ let S = {
1830
+ ...x,
1831
+ group: h(),
1785
1832
  dependencies: C,
1786
- position: x
1833
+ position: b
1787
1834
  };
1788
- return f.at(-1).push(w), f;
1835
+ return f.at(-1).push(S), f;
1789
1836
  },
1790
1837
  [[]]
1791
1838
  );
1792
- for (let p of o(s.properties))
1793
- P(p, (f, y) => {
1794
- let d = h(l.groups, f), c = h(l.groups, y);
1795
- if (d > c || d === c && O(S(f, y, l))) {
1796
- let m = (x) => {
1839
+ for (let o of t(a.properties))
1840
+ P(o, (f, c) => {
1841
+ let d = E(l.groups, f), g = E(l.groups, c);
1842
+ if (d > g || d === g && O(w(f, c, l))) {
1843
+ let y = (b) => {
1797
1844
  let C = {};
1798
- for (let N of p) {
1799
- let E = h(l.groups, N);
1800
- E in C ? C[E] = v(
1801
- [...C[E], N],
1845
+ for (let N of o) {
1846
+ let x = E(l.groups, N);
1847
+ x in C ? C[x] = v(
1848
+ [...C[x], N],
1802
1849
  l
1803
- ) : C[E] = [N];
1850
+ ) : C[x] = [N];
1804
1851
  }
1805
- let b = [];
1852
+ let h = [];
1806
1853
  for (let N of Object.keys(C).sort(
1807
- (E, w) => Number(E) - Number(w)
1854
+ (x, S) => Number(x) - Number(S)
1808
1855
  ))
1809
- b.push(...v(C[N], l));
1856
+ h.push(...v(C[N], l));
1810
1857
  return M(
1811
- x,
1812
- p,
1813
1858
  b,
1859
+ o,
1860
+ h,
1814
1861
  e.sourceCode,
1815
1862
  {
1816
1863
  partitionComment: l["partition-by-comment"]
@@ -1821,10 +1868,10 @@ const ee = "sort-object-types", Ne = A({
1821
1868
  messageId: "unexpectedObjectsOrder",
1822
1869
  data: {
1823
1870
  left: k(f.name),
1824
- right: k(y.name)
1871
+ right: k(c.name)
1825
1872
  },
1826
- node: y.node,
1827
- fix: m
1873
+ node: c.node,
1874
+ fix: y
1828
1875
  });
1829
1876
  }
1830
1877
  });
@@ -1835,8 +1882,8 @@ const ee = "sort-object-types", Ne = A({
1835
1882
  ObjectPattern: i
1836
1883
  };
1837
1884
  }
1838
- }), le = "sort-classes", Ie = A({
1839
- name: le,
1885
+ }), pe = "sort-classes", Pe = A({
1886
+ name: pe,
1840
1887
  meta: {
1841
1888
  type: "suggestion",
1842
1889
  docs: {
@@ -1861,8 +1908,8 @@ const ee = "sort-object-types", Ne = A({
1861
1908
  default: !1
1862
1909
  },
1863
1910
  order: {
1864
- enum: [g.asc, g.desc],
1865
- default: g.asc,
1911
+ enum: [m.asc, m.desc],
1912
+ default: m.asc,
1866
1913
  type: "string"
1867
1914
  },
1868
1915
  groups: {
@@ -1880,85 +1927,85 @@ const ee = "sort-object-types", Ne = A({
1880
1927
  defaultOptions: [
1881
1928
  {
1882
1929
  type: u.alphabetical,
1883
- order: g.asc
1930
+ order: m.asc
1884
1931
  }
1885
1932
  ],
1886
1933
  create: (e) => ({
1887
1934
  ClassBody: (i) => {
1888
1935
  if (i.body.length > 1) {
1889
- let s = j(e.options.at(0), {
1936
+ let a = j(e.options.at(0), {
1890
1937
  type: u.alphabetical,
1891
- order: g.asc,
1938
+ order: m.asc,
1892
1939
  "ignore-case": !1,
1893
1940
  groups: ["property", "constructor", "method", "unknown"]
1894
- }), l = i.body.map((r) => {
1941
+ }), l = i.body.map((s) => {
1895
1942
  var f;
1896
- let t, { getGroup: a, defineGroup: n } = G(s.groups);
1897
- r.type === "StaticBlock" ? t = "static" : r.type === "TSIndexSignature" ? t = e.sourceCode.text.slice(
1898
- r.range.at(0),
1899
- ((f = r.typeAnnotation) == null ? void 0 : f.range.at(0)) ?? r.range.at(1)
1900
- ) : r.key.type === "Identifier" ? { name: t } = r.key : t = e.sourceCode.text.slice(...r.key.range);
1901
- let o = t.startsWith("_") || t.startsWith("#"), p = "decorators" in r && r.decorators.length > 0;
1902
- if (r.type === "MethodDefinition") {
1903
- r.kind === "constructor" && n("constructor");
1904
- let y = r.accessibility === "private" || o, d = r.static;
1905
- p && (r.kind === "get" && n("decorated-get-method"), r.kind === "set" && n("decorated-set-method"), n("decorated-method")), y && d && n("static-private-method"), y && n("private-method"), d && n("static-method"), r.kind === "get" && n("get-method"), r.kind === "set" && n("set-method"), n("method");
1943
+ let r, { getGroup: n, defineGroup: p } = R(a.groups);
1944
+ s.type === "StaticBlock" ? r = "static" : s.type === "TSIndexSignature" ? r = e.sourceCode.text.slice(
1945
+ s.range.at(0),
1946
+ ((f = s.typeAnnotation) == null ? void 0 : f.range.at(0)) ?? s.range.at(1)
1947
+ ) : s.key.type === "Identifier" ? { name: r } = s.key : r = e.sourceCode.text.slice(...s.key.range);
1948
+ let t = r.startsWith("_") || r.startsWith("#"), o = "decorators" in s && s.decorators.length > 0;
1949
+ if (s.type === "MethodDefinition") {
1950
+ s.kind === "constructor" && p("constructor");
1951
+ let c = s.accessibility === "private" || t, d = s.static;
1952
+ o && (s.kind === "get" && p("decorated-get-method"), s.kind === "set" && p("decorated-set-method"), p("decorated-method")), c && d && p("static-private-method"), c && p("private-method"), d && p("static-method"), s.kind === "get" && p("get-method"), s.kind === "set" && p("set-method"), p("method");
1906
1953
  } else
1907
- r.type === "TSIndexSignature" ? n("index-signature") : r.type === "AccessorProperty" ? p && ((r.accessibility === "private" || o) && n("private-decorated-accessor-property"), n("decorated-accessor-property")) : r.type === "PropertyDefinition" && (p && ((r.accessibility === "private" || o) && n("private-decorated-property"), n("decorated-property")), (r.accessibility === "private" || o) && n("private-property"), r.static && n("static-property"), n("property"));
1954
+ s.type === "TSIndexSignature" ? p("index-signature") : s.type === "AccessorProperty" ? o && ((s.accessibility === "private" || t) && p("private-decorated-accessor-property"), p("decorated-accessor-property")) : s.type === "PropertyDefinition" && (o && ((s.accessibility === "private" || t) && p("private-decorated-property"), p("decorated-property")), (s.accessibility === "private" || t) && p("private-property"), s.static && p("static-property"), p("property"));
1908
1955
  return {
1909
- size: I(r.range),
1910
- group: a(),
1911
- node: r,
1912
- name: t
1956
+ size: I(s.range),
1957
+ group: n(),
1958
+ node: s,
1959
+ name: r
1913
1960
  };
1914
1961
  });
1915
- P(l, (r, t) => {
1916
- let a = h(s.groups, r), n = h(s.groups, t);
1917
- r.name !== t.name && (a > n || a === n && O(S(r, t, s))) && e.report({
1962
+ P(l, (s, r) => {
1963
+ let n = E(a.groups, s), p = E(a.groups, r);
1964
+ s.name !== r.name && (n > p || n === p && O(w(s, r, a))) && e.report({
1918
1965
  messageId: "unexpectedClassesOrder",
1919
1966
  data: {
1920
- left: k(r.name),
1921
- right: k(t.name)
1967
+ left: k(s.name),
1968
+ right: k(r.name)
1922
1969
  },
1923
- node: t.node,
1924
- fix: (o) => {
1925
- let p = [], f = l.reduce(
1926
- (d, c) => {
1927
- let m = h(s.groups, c);
1928
- return m in d ? d[m] = v(
1929
- [...d[m], c],
1930
- s
1931
- ) : d[m] = [c], d;
1970
+ node: r.node,
1971
+ fix: (t) => {
1972
+ let o = [], f = l.reduce(
1973
+ (d, g) => {
1974
+ let y = E(a.groups, g);
1975
+ return y in d ? d[y] = v(
1976
+ [...d[y], g],
1977
+ a
1978
+ ) : d[y] = [g], d;
1932
1979
  },
1933
1980
  {}
1934
- ), y = Object.keys(f).sort((d, c) => Number(d) - Number(c)).reduce(
1935
- (d, c) => [
1981
+ ), c = Object.keys(f).sort((d, g) => Number(d) - Number(g)).reduce(
1982
+ (d, g) => [
1936
1983
  ...d,
1937
- ...f[c]
1984
+ ...f[g]
1938
1985
  ],
1939
1986
  []
1940
1987
  );
1941
- for (let d = 0, c = y.length; d < c; d++)
1942
- p.push(
1943
- o.replaceTextRange(
1944
- T(l.at(d).node, e.sourceCode),
1988
+ for (let d = 0, g = c.length; d < g; d++)
1989
+ o.push(
1990
+ t.replaceTextRange(
1991
+ L(l.at(d).node, e.sourceCode),
1945
1992
  e.sourceCode.text.slice(
1946
- ...T(
1947
- y.at(d).node,
1993
+ ...L(
1994
+ c.at(d).node,
1948
1995
  e.sourceCode
1949
1996
  )
1950
1997
  )
1951
1998
  )
1952
1999
  );
1953
- return p;
2000
+ return o;
1954
2001
  }
1955
2002
  });
1956
2003
  });
1957
2004
  }
1958
2005
  }
1959
2006
  })
1960
- }), ie = "sort-enums", Oe = A({
1961
- name: ie,
2007
+ }), ue = "sort-enums", Te = A({
2008
+ name: ue,
1962
2009
  meta: {
1963
2010
  type: "suggestion",
1964
2011
  docs: {
@@ -1987,8 +2034,8 @@ const ee = "sort-object-types", Ne = A({
1987
2034
  default: !1
1988
2035
  },
1989
2036
  order: {
1990
- enum: [g.asc, g.desc],
1991
- default: g.asc,
2037
+ enum: [m.asc, m.desc],
2038
+ default: m.asc,
1992
2039
  type: "string"
1993
2040
  }
1994
2041
  },
@@ -2002,43 +2049,43 @@ const ee = "sort-object-types", Ne = A({
2002
2049
  defaultOptions: [
2003
2050
  {
2004
2051
  type: u.alphabetical,
2005
- order: g.asc
2052
+ order: m.asc
2006
2053
  }
2007
2054
  ],
2008
2055
  create: (e) => ({
2009
2056
  TSEnumDeclaration: (i) => {
2010
- if (i.members.length > 1 && i.members.every(({ initializer: s }) => s)) {
2011
- let s = j(e.options.at(0), {
2057
+ if (i.members.length > 1 && i.members.every(({ initializer: a }) => a)) {
2058
+ let a = j(e.options.at(0), {
2012
2059
  type: u.alphabetical,
2013
- order: g.asc,
2060
+ order: m.asc,
2014
2061
  "ignore-case": !1,
2015
2062
  "partition-by-comment": !1
2016
- }), l = s["partition-by-comment"], r = i.members.reduce(
2017
- (t, a) => {
2018
- let n = V(a, e.sourceCode);
2019
- l && n && X(l, n.value) && t.push([]);
2020
- let p = {
2021
- name: a.id.type === "Literal" ? `${a.id.value}` : `${e.sourceCode.text.slice(...a.id.range)}`,
2022
- node: a,
2023
- size: I(a.range)
2063
+ }), l = a["partition-by-comment"], s = i.members.reduce(
2064
+ (r, n) => {
2065
+ let p = K(n, e.sourceCode);
2066
+ l && p && Y(l, p.value) && r.push([]);
2067
+ let o = {
2068
+ name: n.id.type === "Literal" ? `${n.id.value}` : `${e.sourceCode.text.slice(...n.id.range)}`,
2069
+ node: n,
2070
+ size: I(n.range)
2024
2071
  };
2025
- return t.at(-1).push(p), t;
2072
+ return r.at(-1).push(o), r;
2026
2073
  },
2027
2074
  [[]]
2028
2075
  );
2029
- for (let t of r)
2030
- P(t, (a, n) => {
2031
- O(S(a, n, s)) && e.report({
2076
+ for (let r of s)
2077
+ P(r, (n, p) => {
2078
+ O(w(n, p, a)) && e.report({
2032
2079
  messageId: "unexpectedEnumsOrder",
2033
2080
  data: {
2034
- left: k(a.name),
2035
- right: k(n.name)
2081
+ left: k(n.name),
2082
+ right: k(p.name)
2036
2083
  },
2037
- node: n.node,
2038
- fix: (o) => M(
2039
- o,
2084
+ node: p.node,
2085
+ fix: (t) => M(
2040
2086
  t,
2041
- v(t, s),
2087
+ r,
2088
+ v(r, a),
2042
2089
  e.sourceCode,
2043
2090
  { partitionComment: l }
2044
2091
  )
@@ -2047,8 +2094,8 @@ const ee = "sort-object-types", Ne = A({
2047
2094
  }
2048
2095
  }
2049
2096
  })
2050
- }), pe = "sort-maps", je = A({
2051
- name: pe,
2097
+ }), de = "sort-maps", Me = A({
2098
+ name: de,
2052
2099
  meta: {
2053
2100
  type: "suggestion",
2054
2101
  docs: {
@@ -2069,8 +2116,8 @@ const ee = "sort-object-types", Ne = A({
2069
2116
  type: "string"
2070
2117
  },
2071
2118
  order: {
2072
- enum: [g.asc, g.desc],
2073
- default: g.asc,
2119
+ enum: [m.asc, m.desc],
2120
+ default: m.asc,
2074
2121
  type: "string"
2075
2122
  },
2076
2123
  "ignore-case": {
@@ -2088,48 +2135,48 @@ const ee = "sort-object-types", Ne = A({
2088
2135
  defaultOptions: [
2089
2136
  {
2090
2137
  type: u.alphabetical,
2091
- order: g.asc
2138
+ order: m.asc
2092
2139
  }
2093
2140
  ],
2094
2141
  create: (e) => ({
2095
2142
  NewExpression: (i) => {
2096
2143
  if (i.callee.type === "Identifier" && i.callee.name === "Map" && i.arguments.length && i.arguments[0].type === "ArrayExpression") {
2097
- let [{ elements: s }] = i.arguments;
2098
- if (s.length > 1) {
2144
+ let [{ elements: a }] = i.arguments;
2145
+ if (a.length > 1) {
2099
2146
  let l = j(e.options.at(0), {
2100
2147
  type: u.alphabetical,
2101
2148
  "ignore-case": !1,
2102
- order: g.asc
2103
- }), r = s.reduce(
2104
- (t, a) => (a === null || a.type === "SpreadElement" ? t.push([]) : t.at(-1).push(a), t),
2149
+ order: m.asc
2150
+ }), s = a.reduce(
2151
+ (r, n) => (n === null || n.type === "SpreadElement" ? r.push([]) : r.at(-1).push(n), r),
2105
2152
  [[]]
2106
2153
  );
2107
- for (let t of r) {
2108
- let a = t.map((n) => {
2109
- let o;
2110
- if (n.type === "ArrayExpression") {
2111
- let [p] = n.elements;
2112
- p ? p.type === "Literal" ? o = p.raw : o = e.sourceCode.text.slice(...p.range) : o = `${p}`;
2154
+ for (let r of s) {
2155
+ let n = r.map((p) => {
2156
+ let t;
2157
+ if (p.type === "ArrayExpression") {
2158
+ let [o] = p.elements;
2159
+ o ? o.type === "Literal" ? t = o.raw : t = e.sourceCode.text.slice(...o.range) : t = `${o}`;
2113
2160
  } else
2114
- o = e.sourceCode.text.slice(...n.range);
2161
+ t = e.sourceCode.text.slice(...p.range);
2115
2162
  return {
2116
- size: I(n.range),
2117
- node: n,
2118
- name: o
2163
+ size: I(p.range),
2164
+ node: p,
2165
+ name: t
2119
2166
  };
2120
2167
  });
2121
- P(a, (n, o) => {
2122
- O(S(n, o, l)) && e.report({
2168
+ P(n, (p, t) => {
2169
+ O(w(p, t, l)) && e.report({
2123
2170
  messageId: "unexpectedMapElementsOrder",
2124
2171
  data: {
2125
- left: k(n.name),
2126
- right: k(o.name)
2172
+ left: k(p.name),
2173
+ right: k(t.name)
2127
2174
  },
2128
- node: o.node,
2129
- fix: (p) => M(
2130
- p,
2131
- a,
2132
- v(a, l),
2175
+ node: t.node,
2176
+ fix: (o) => M(
2177
+ o,
2178
+ n,
2179
+ v(n, l),
2133
2180
  e.sourceCode
2134
2181
  )
2135
2182
  });
@@ -2139,10 +2186,10 @@ const ee = "sort-object-types", Ne = A({
2139
2186
  }
2140
2187
  }
2141
2188
  })
2142
- }), Pe = "eslint-plugin-perfectionist";
2143
- let J = (e) => {
2189
+ }), Le = "eslint-plugin-perfectionist";
2190
+ let X = (e) => {
2144
2191
  let i = {
2145
- [oe]: [
2192
+ [le]: [
2146
2193
  "error",
2147
2194
  {
2148
2195
  groups: [
@@ -2163,7 +2210,7 @@ let J = (e) => {
2163
2210
  "internal-pattern": ["~/**"]
2164
2211
  }
2165
2212
  ],
2166
- [le]: [
2213
+ [pe]: [
2167
2214
  "error",
2168
2215
  {
2169
2216
  groups: [
@@ -2180,78 +2227,78 @@ let J = (e) => {
2180
2227
  ]
2181
2228
  }
2182
2229
  ],
2183
- [ne]: [
2230
+ [ie]: [
2184
2231
  "error",
2185
2232
  {
2186
2233
  "partition-by-comment": !1
2187
2234
  }
2188
2235
  ],
2189
- [Q]: [
2236
+ [Z]: [
2190
2237
  "error",
2191
2238
  {
2192
2239
  "spread-last": !0
2193
2240
  }
2194
2241
  ],
2195
- [q]: ["error"],
2196
2242
  [H]: ["error"],
2197
- [Y]: ["error"],
2198
- [Z]: ["error"],
2243
+ [Q]: ["error"],
2199
2244
  [F]: ["error"],
2200
2245
  [ee]: ["error"],
2201
2246
  [te]: ["error"],
2202
2247
  [re]: ["error"],
2203
2248
  [se]: ["error"],
2204
2249
  [ae]: ["error"],
2205
- [ie]: ["error"],
2206
- [pe]: ["error"]
2250
+ [oe]: ["error"],
2251
+ [ne]: ["error"],
2252
+ [ue]: ["error"],
2253
+ [de]: ["error"]
2207
2254
  };
2208
2255
  return {
2209
2256
  rules: Object.fromEntries(
2210
- Object.entries(i).map(([s, [l, r = {}]]) => [
2211
- `perfectionist/${s}`,
2212
- [l, Object.assign(r, e)]
2257
+ Object.entries(i).map(([a, [l, s = {}]]) => [
2258
+ `perfectionist/${a}`,
2259
+ [l, Object.assign(s, e)]
2213
2260
  ])
2214
2261
  ),
2215
2262
  plugins: ["perfectionist"]
2216
2263
  };
2217
2264
  };
2218
- const De = {
2265
+ const _e = {
2219
2266
  rules: {
2220
- [Q]: he,
2221
- [H]: me,
2222
- [le]: Ie,
2223
- [ie]: Oe,
2224
- [ae]: Se,
2225
- [oe]: ke,
2226
- [re]: ve,
2267
+ [Z]: Ee,
2268
+ [Q]: xe,
2269
+ [pe]: Pe,
2270
+ [ue]: Te,
2271
+ [ne]: Ie,
2272
+ [le]: Oe,
2273
+ [ae]: ke,
2274
+ [oe]: Ae,
2275
+ [de]: Me,
2276
+ [ee]: Ce,
2277
+ [te]: ve,
2278
+ [re]: Se,
2279
+ [ie]: je,
2280
+ [H]: be,
2227
2281
  [se]: we,
2228
- [pe]: je,
2229
- [Z]: xe,
2230
- [F]: Ee,
2231
- [ee]: Ne,
2232
- [ne]: Ae,
2233
- [q]: ye,
2234
- [te]: Ce,
2235
- [Y]: be
2282
+ [F]: Ne
2236
2283
  },
2237
2284
  configs: {
2238
- "recommended-alphabetical": J({
2285
+ "recommended-alphabetical": X({
2239
2286
  type: u.alphabetical,
2240
- order: g.asc,
2287
+ order: m.asc,
2241
2288
  "ignore-case": !1
2242
2289
  }),
2243
- "recommended-natural": J({
2290
+ "recommended-natural": X({
2244
2291
  type: u.natural,
2245
- order: g.asc,
2292
+ order: m.asc,
2246
2293
  "ignore-case": !1
2247
2294
  }),
2248
- "recommended-line-length": J({
2295
+ "recommended-line-length": X({
2249
2296
  type: u["line-length"],
2250
- order: g.desc
2297
+ order: m.desc
2251
2298
  })
2252
2299
  },
2253
- name: Pe
2300
+ name: Le
2254
2301
  };
2255
2302
  export {
2256
- De as default
2303
+ _e as default
2257
2304
  };