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