eslint-plugin-perfectionist 3.7.0 → 3.9.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.d.ts +91 -31
- package/dist/index.js +7 -4
- package/dist/index.mjs +7 -4
- package/dist/rules/sort-array-includes.js +17 -3
- package/dist/rules/sort-array-includes.mjs +17 -3
- package/dist/rules/sort-astro-attributes.js +18 -1
- package/dist/rules/sort-astro-attributes.mjs +19 -3
- package/dist/rules/sort-classes-utils.js +62 -8
- package/dist/rules/sort-classes-utils.mjs +56 -8
- package/dist/rules/sort-classes.js +52 -63
- package/dist/rules/sort-classes.mjs +48 -60
- package/dist/rules/sort-classes.types.js +4 -0
- package/dist/rules/sort-classes.types.mjs +4 -0
- package/dist/rules/sort-enums.js +24 -3
- package/dist/rules/sort-enums.mjs +18 -3
- package/dist/rules/sort-exports.js +23 -3
- package/dist/rules/sort-exports.mjs +17 -3
- package/dist/rules/sort-imports.js +234 -238
- package/dist/rules/sort-imports.mjs +219 -227
- package/dist/rules/sort-interfaces.js +37 -10
- package/dist/rules/sort-interfaces.mjs +32 -12
- package/dist/rules/sort-intersection-types.js +24 -4
- package/dist/rules/sort-intersection-types.mjs +18 -4
- package/dist/rules/sort-jsx-props.js +18 -3
- package/dist/rules/sort-jsx-props.mjs +19 -5
- package/dist/rules/sort-maps.js +17 -3
- package/dist/rules/sort-maps.mjs +17 -3
- package/dist/rules/sort-named-exports.js +23 -3
- package/dist/rules/sort-named-exports.mjs +17 -3
- package/dist/rules/sort-named-imports.js +22 -3
- package/dist/rules/sort-named-imports.mjs +16 -3
- package/dist/rules/sort-object-types.js +37 -8
- package/dist/rules/sort-object-types.mjs +31 -10
- package/dist/rules/sort-objects.js +35 -16
- package/dist/rules/sort-objects.mjs +33 -15
- package/dist/rules/sort-sets.js +2 -0
- package/dist/rules/sort-sets.mjs +2 -0
- package/dist/rules/sort-svelte-attributes.js +21 -6
- package/dist/rules/sort-svelte-attributes.mjs +22 -8
- package/dist/rules/sort-switch-case.js +10 -1
- package/dist/rules/sort-switch-case.mjs +10 -1
- package/dist/rules/sort-union-types.js +24 -4
- package/dist/rules/sort-union-types.mjs +18 -4
- package/dist/rules/sort-variable-declarations.js +23 -3
- package/dist/rules/sort-variable-declarations.mjs +17 -3
- package/dist/rules/sort-vue-attributes.js +18 -1
- package/dist/rules/sort-vue-attributes.mjs +19 -3
- package/dist/utils/compare.js +26 -6
- package/dist/utils/compare.mjs +26 -6
- package/dist/utils/get-node-range.js +11 -3
- package/dist/utils/get-node-range.mjs +13 -3
- package/dist/utils/get-options-with-clean-groups.js +13 -0
- package/dist/utils/get-options-with-clean-groups.mjs +11 -0
- package/dist/utils/get-settings.js +9 -10
- package/dist/utils/get-settings.mjs +9 -10
- package/dist/utils/is-partition-comment.js +8 -10
- package/dist/utils/is-partition-comment.mjs +8 -10
- package/dist/utils/matches.js +15 -0
- package/dist/utils/matches.mjs +13 -0
- package/dist/utils/sort-nodes-by-groups.js +33 -7
- package/dist/utils/sort-nodes-by-groups.mjs +33 -7
- package/dist/utils/use-groups.js +4 -8
- package/dist/utils/use-groups.mjs +4 -13
- package/dist/utils/validate-groups-configuration.js +11 -0
- package/dist/utils/validate-groups-configuration.mjs +11 -1
- package/{license → license.md} +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare type AccessorPropertySelector = 'accessor-property'
|
|
|
12
12
|
|
|
13
13
|
declare type AdvancedSingleCustomGroup<T extends Selector> = {
|
|
14
14
|
decoratorNamePattern?: string
|
|
15
|
+
elementValuePattern?: string
|
|
15
16
|
elementNamePattern?: string
|
|
16
17
|
} & BaseSingleCustomGroup<T>
|
|
17
18
|
|
|
@@ -114,6 +115,8 @@ declare const _default: {
|
|
|
114
115
|
Partial<{
|
|
115
116
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
116
117
|
partitionByComment: string[] | boolean | string
|
|
118
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
119
|
+
matcher: 'minimatch' | 'regex'
|
|
117
120
|
partitionByNewLine: boolean
|
|
118
121
|
order: 'desc' | 'asc'
|
|
119
122
|
ignoreCase: boolean
|
|
@@ -129,6 +132,8 @@ declare const _default: {
|
|
|
129
132
|
Partial<{
|
|
130
133
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
131
134
|
partitionByComment: string[] | boolean | string
|
|
135
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
136
|
+
matcher: 'minimatch' | 'regex'
|
|
132
137
|
groups: (
|
|
133
138
|
| (
|
|
134
139
|
| 'object'
|
|
@@ -178,7 +183,9 @@ declare const _default: {
|
|
|
178
183
|
[x: string]: string | string[]
|
|
179
184
|
}
|
|
180
185
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
186
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
181
187
|
groups: (string | string[])[]
|
|
188
|
+
matcher: 'minimatch' | 'regex'
|
|
182
189
|
order: 'desc' | 'asc'
|
|
183
190
|
ignoreCase: boolean
|
|
184
191
|
}>,
|
|
@@ -194,7 +201,9 @@ declare const _default: {
|
|
|
194
201
|
[x: string]: string | string[]
|
|
195
202
|
}
|
|
196
203
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
204
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
197
205
|
groups: (string | string[])[]
|
|
206
|
+
matcher: 'minimatch' | 'regex'
|
|
198
207
|
order: 'desc' | 'asc'
|
|
199
208
|
ignoreCase: boolean
|
|
200
209
|
}>,
|
|
@@ -210,7 +219,9 @@ declare const _default: {
|
|
|
210
219
|
[x: string]: string | string[]
|
|
211
220
|
}
|
|
212
221
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
222
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
213
223
|
groups: (string | string[])[]
|
|
224
|
+
matcher: 'minimatch' | 'regex'
|
|
214
225
|
order: 'desc' | 'asc'
|
|
215
226
|
ignoreCase: boolean
|
|
216
227
|
}>,
|
|
@@ -231,6 +242,8 @@ declare const _default: {
|
|
|
231
242
|
groupKind: 'values-first' | 'types-first' | 'mixed'
|
|
232
243
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
233
244
|
partitionByComment: string[] | boolean | string
|
|
245
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
246
|
+
matcher: 'minimatch' | 'regex'
|
|
234
247
|
partitionByNewLine: boolean
|
|
235
248
|
order: 'desc' | 'asc'
|
|
236
249
|
ignoreAlias: boolean
|
|
@@ -247,6 +260,8 @@ declare const _default: {
|
|
|
247
260
|
groupKind: 'values-first' | 'types-first' | 'mixed'
|
|
248
261
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
249
262
|
partitionByComment: string[] | boolean | string
|
|
263
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
264
|
+
matcher: 'minimatch' | 'regex'
|
|
250
265
|
partitionByNewLine: boolean
|
|
251
266
|
order: 'desc' | 'asc'
|
|
252
267
|
ignoreCase: boolean
|
|
@@ -265,7 +280,9 @@ declare const _default: {
|
|
|
265
280
|
}
|
|
266
281
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
267
282
|
partitionByComment: string[] | boolean | string
|
|
283
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
268
284
|
groups: (string | string[])[]
|
|
285
|
+
matcher: 'minimatch' | 'regex'
|
|
269
286
|
partitionByNewLine: boolean
|
|
270
287
|
order: 'desc' | 'asc'
|
|
271
288
|
ignoreCase: boolean
|
|
@@ -280,6 +297,8 @@ declare const _default: {
|
|
|
280
297
|
Partial<{
|
|
281
298
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
282
299
|
partitionByComment: string[] | boolean | string
|
|
300
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
301
|
+
matcher: 'minimatch' | 'regex'
|
|
283
302
|
groups: (
|
|
284
303
|
| (
|
|
285
304
|
| 'object'
|
|
@@ -325,6 +344,7 @@ declare const _default: {
|
|
|
325
344
|
[
|
|
326
345
|
Partial<{
|
|
327
346
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
347
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
328
348
|
order: 'desc' | 'asc'
|
|
329
349
|
ignoreCase: boolean
|
|
330
350
|
}>,
|
|
@@ -343,7 +363,9 @@ declare const _default: {
|
|
|
343
363
|
}
|
|
344
364
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
345
365
|
partitionByComment: string[] | boolean | string
|
|
366
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
346
367
|
groups: (string | string[])[]
|
|
368
|
+
matcher: 'minimatch' | 'regex'
|
|
347
369
|
partitionByNewLine: boolean
|
|
348
370
|
ignorePattern: string[]
|
|
349
371
|
order: 'desc' | 'asc'
|
|
@@ -361,7 +383,9 @@ declare const _default: {
|
|
|
361
383
|
[x: string]: string | string[]
|
|
362
384
|
}
|
|
363
385
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
386
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
364
387
|
groups: (string | string[])[]
|
|
388
|
+
matcher: 'minimatch' | 'regex'
|
|
365
389
|
ignorePattern: string[]
|
|
366
390
|
order: 'desc' | 'asc'
|
|
367
391
|
ignoreCase: boolean
|
|
@@ -379,35 +403,8 @@ declare const _default: {
|
|
|
379
403
|
RuleListener
|
|
380
404
|
>
|
|
381
405
|
'sort-imports': RuleModule<
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
| 'extraSpacingBetweenImports'
|
|
385
|
-
| 'unexpectedImportsOrder',
|
|
386
|
-
[
|
|
387
|
-
Partial<{
|
|
388
|
-
customGroups: {
|
|
389
|
-
value?:
|
|
390
|
-
| {
|
|
391
|
-
[x: string]: string | string[]
|
|
392
|
-
}
|
|
393
|
-
| undefined
|
|
394
|
-
type?:
|
|
395
|
-
| {
|
|
396
|
-
[x: string]: string | string[]
|
|
397
|
-
}
|
|
398
|
-
| undefined
|
|
399
|
-
}
|
|
400
|
-
type: 'alphabetical' | 'line-length' | 'natural'
|
|
401
|
-
newlinesBetween: 'ignore' | 'always' | 'never'
|
|
402
|
-
groups: (string | string[])[]
|
|
403
|
-
environment: 'node' | 'bun'
|
|
404
|
-
internalPattern: string[]
|
|
405
|
-
sortSideEffects: boolean
|
|
406
|
-
maxLineLength?: number
|
|
407
|
-
order: 'desc' | 'asc'
|
|
408
|
-
ignoreCase: boolean
|
|
409
|
-
}>,
|
|
410
|
-
],
|
|
406
|
+
MESSAGE_ID,
|
|
407
|
+
Options_2<string[]>,
|
|
411
408
|
unknown,
|
|
412
409
|
RuleListener
|
|
413
410
|
>
|
|
@@ -418,6 +415,8 @@ declare const _default: {
|
|
|
418
415
|
groupKind: 'values-first' | 'types-first' | 'mixed'
|
|
419
416
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
420
417
|
partitionByComment: string[] | boolean | string
|
|
418
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
419
|
+
matcher: 'minimatch' | 'regex'
|
|
421
420
|
partitionByNewLine: boolean
|
|
422
421
|
order: 'desc' | 'asc'
|
|
423
422
|
ignoreCase: boolean
|
|
@@ -437,6 +436,8 @@ declare const _default: {
|
|
|
437
436
|
}
|
|
438
437
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
439
438
|
partitionByComment: string[] | boolean | string
|
|
439
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
440
|
+
matcher: 'minimatch' | 'regex'
|
|
440
441
|
groups: (string[] | string)[]
|
|
441
442
|
partitionByNewLine: boolean
|
|
442
443
|
styledComponents: boolean
|
|
@@ -451,7 +452,7 @@ declare const _default: {
|
|
|
451
452
|
>
|
|
452
453
|
'sort-enums': RuleModule<
|
|
453
454
|
'unexpectedEnumsDependencyOrder' | 'unexpectedEnumsOrder',
|
|
454
|
-
|
|
455
|
+
Options_3,
|
|
455
456
|
unknown,
|
|
456
457
|
RuleListener
|
|
457
458
|
>
|
|
@@ -467,6 +468,8 @@ declare const _default: {
|
|
|
467
468
|
Partial<{
|
|
468
469
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
469
470
|
partitionByComment: string[] | boolean | string
|
|
471
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
472
|
+
matcher: 'minimatch' | 'regex'
|
|
470
473
|
partitionByNewLine: boolean
|
|
471
474
|
order: 'desc' | 'asc'
|
|
472
475
|
ignoreCase: boolean
|
|
@@ -512,11 +515,38 @@ declare type Group =
|
|
|
512
515
|
| 'unknown'
|
|
513
516
|
| string
|
|
514
517
|
|
|
518
|
+
declare type Group_2<T extends string[]> =
|
|
519
|
+
| 'side-effect-style'
|
|
520
|
+
| 'external-type'
|
|
521
|
+
| 'internal-type'
|
|
522
|
+
| 'builtin-type'
|
|
523
|
+
| 'sibling-type'
|
|
524
|
+
| 'parent-type'
|
|
525
|
+
| 'side-effect'
|
|
526
|
+
| 'index-type'
|
|
527
|
+
| 'internal'
|
|
528
|
+
| 'external'
|
|
529
|
+
| T[number]
|
|
530
|
+
| 'sibling'
|
|
531
|
+
| 'unknown'
|
|
532
|
+
| 'builtin'
|
|
533
|
+
| 'parent'
|
|
534
|
+
| 'object'
|
|
535
|
+
| 'index'
|
|
536
|
+
| 'style'
|
|
537
|
+
| 'type'
|
|
538
|
+
|
|
515
539
|
declare type IndexSignatureGroup =
|
|
516
540
|
`${StaticModifierPrefix}${ReadonlyModifierPrefix}${IndexSignatureSelector}`
|
|
517
541
|
|
|
518
542
|
declare type IndexSignatureSelector = 'index-signature'
|
|
519
543
|
|
|
544
|
+
declare type MESSAGE_ID =
|
|
545
|
+
| 'missedSpacingBetweenImports'
|
|
546
|
+
| 'unexpectedImportsGroupOrder'
|
|
547
|
+
| 'extraSpacingBetweenImports'
|
|
548
|
+
| 'unexpectedImportsOrder'
|
|
549
|
+
|
|
520
550
|
declare type MethodGroup =
|
|
521
551
|
`${PublicOrProtectedOrPrivateModifierPrefix}${StaticOrAbstractModifierPrefix}${OverrideModifierPrefix}${DecoratedModifierPrefix}${OptionalModifierPrefix}${MethodSelector}`
|
|
522
552
|
|
|
@@ -534,16 +564,44 @@ declare type Options = [
|
|
|
534
564
|
groupKind: 'literals-first' | 'spreads-first' | 'mixed'
|
|
535
565
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
536
566
|
partitionByComment: string[] | boolean | string
|
|
567
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
568
|
+
matcher: 'minimatch' | 'regex'
|
|
537
569
|
partitionByNewLine: boolean
|
|
538
570
|
order: 'desc' | 'asc'
|
|
539
571
|
ignoreCase: boolean
|
|
540
572
|
}>,
|
|
541
573
|
]
|
|
542
574
|
|
|
543
|
-
declare type Options_2 = [
|
|
575
|
+
declare type Options_2<T extends string[]> = [
|
|
576
|
+
Partial<{
|
|
577
|
+
customGroups: {
|
|
578
|
+
value?: {
|
|
579
|
+
[key in T[number]]: string[] | string
|
|
580
|
+
}
|
|
581
|
+
type?: {
|
|
582
|
+
[key in T[number]]: string[] | string
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
type: 'alphabetical' | 'line-length' | 'natural'
|
|
586
|
+
newlinesBetween: 'ignore' | 'always' | 'never'
|
|
587
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
588
|
+
groups: (Group_2<T>[] | Group_2<T>)[]
|
|
589
|
+
matcher: 'minimatch' | 'regex'
|
|
590
|
+
environment: 'node' | 'bun'
|
|
591
|
+
internalPattern: string[]
|
|
592
|
+
sortSideEffects: boolean
|
|
593
|
+
maxLineLength?: number
|
|
594
|
+
order: 'desc' | 'asc'
|
|
595
|
+
ignoreCase: boolean
|
|
596
|
+
}>,
|
|
597
|
+
]
|
|
598
|
+
|
|
599
|
+
declare type Options_3 = [
|
|
544
600
|
Partial<{
|
|
545
601
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
546
602
|
partitionByComment: string[] | boolean | string
|
|
603
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
604
|
+
matcher: 'minimatch' | 'regex'
|
|
547
605
|
partitionByNewLine: boolean
|
|
548
606
|
forceNumericSort: boolean
|
|
549
607
|
order: 'desc' | 'asc'
|
|
@@ -610,6 +668,8 @@ declare type SortClassesOptions = [
|
|
|
610
668
|
| CustomGroup[]
|
|
611
669
|
type: 'alphabetical' | 'line-length' | 'natural'
|
|
612
670
|
partitionByComment: string[] | boolean | string
|
|
671
|
+
specialCharacters: 'remove' | 'trim' | 'keep'
|
|
672
|
+
matcher: 'minimatch' | 'regex'
|
|
613
673
|
groups: (Group[] | Group)[]
|
|
614
674
|
order: 'desc' | 'asc'
|
|
615
675
|
ignoreCase: boolean
|
package/dist/index.js
CHANGED
|
@@ -47,10 +47,13 @@ let plugin = {
|
|
|
47
47
|
}
|
|
48
48
|
let getRules = options =>
|
|
49
49
|
Object.fromEntries(
|
|
50
|
-
Object.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Object.entries(plugin.rules).reduce(
|
|
51
|
+
(accumulator, [ruleName, ruleValue]) =>
|
|
52
|
+
ruleValue.meta.deprecated
|
|
53
|
+
? accumulator
|
|
54
|
+
: [...accumulator, [`${name}/${ruleName}`, ['error', options]]],
|
|
55
|
+
[],
|
|
56
|
+
),
|
|
54
57
|
)
|
|
55
58
|
let createConfig = options => ({
|
|
56
59
|
plugins: {
|
package/dist/index.mjs
CHANGED
|
@@ -46,10 +46,13 @@ let plugin = {
|
|
|
46
46
|
}
|
|
47
47
|
let getRules = options =>
|
|
48
48
|
Object.fromEntries(
|
|
49
|
-
Object.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
Object.entries(plugin.rules).reduce(
|
|
50
|
+
(accumulator, [ruleName, ruleValue]) =>
|
|
51
|
+
ruleValue.meta.deprecated
|
|
52
|
+
? accumulator
|
|
53
|
+
: [...accumulator, [`${name}/${ruleName}`, ['error', options]]],
|
|
54
|
+
[],
|
|
55
|
+
),
|
|
53
56
|
)
|
|
54
57
|
let createConfig = options => ({
|
|
55
58
|
plugins: {
|
|
@@ -32,10 +32,21 @@ let jsonSchema = {
|
|
|
32
32
|
type: 'string',
|
|
33
33
|
enum: ['asc', 'desc'],
|
|
34
34
|
},
|
|
35
|
+
matcher: {
|
|
36
|
+
description: 'Specifies the string matcher.',
|
|
37
|
+
type: 'string',
|
|
38
|
+
enum: ['minimatch', 'regex'],
|
|
39
|
+
},
|
|
35
40
|
ignoreCase: {
|
|
36
41
|
description: 'Controls whether sorting should be case-sensitive or not.',
|
|
37
42
|
type: 'boolean',
|
|
38
43
|
},
|
|
44
|
+
specialCharacters: {
|
|
45
|
+
description:
|
|
46
|
+
'Controls how special characters should be handled before sorting.',
|
|
47
|
+
type: 'string',
|
|
48
|
+
enum: ['remove', 'trim', 'keep'],
|
|
49
|
+
},
|
|
39
50
|
groupKind: {
|
|
40
51
|
description: 'Specifies top-level groups.',
|
|
41
52
|
enum: ['mixed', 'literals-first', 'spreads-first'],
|
|
@@ -86,6 +97,8 @@ const sortArrayIncludes = createEslintRule.createEslintRule({
|
|
|
86
97
|
type: 'alphabetical',
|
|
87
98
|
order: 'asc',
|
|
88
99
|
ignoreCase: true,
|
|
100
|
+
specialCharacters: 'keep',
|
|
101
|
+
matcher: 'minimatch',
|
|
89
102
|
groupKind: 'literals-first',
|
|
90
103
|
partitionByComment: false,
|
|
91
104
|
partitionByNewLine: false,
|
|
@@ -115,6 +128,8 @@ let sortArray = (context, messageId, elements) => {
|
|
|
115
128
|
groupKind: 'literals-first',
|
|
116
129
|
type: 'alphabetical',
|
|
117
130
|
ignoreCase: true,
|
|
131
|
+
specialCharacters: 'keep',
|
|
132
|
+
matcher: 'minimatch',
|
|
118
133
|
order: 'asc',
|
|
119
134
|
partitionByComment: false,
|
|
120
135
|
partitionByNewLine: false,
|
|
@@ -145,6 +160,7 @@ let sortArray = (context, messageId, elements) => {
|
|
|
145
160
|
isPartitionComment.hasPartitionComment(
|
|
146
161
|
partitionComment,
|
|
147
162
|
getCommentsBefore.getCommentsBefore(element, sourceCode),
|
|
163
|
+
options.matcher,
|
|
148
164
|
)) ||
|
|
149
165
|
(options.partitionByNewLine &&
|
|
150
166
|
lastSortingNode &&
|
|
@@ -200,9 +216,7 @@ let sortArray = (context, messageId, elements) => {
|
|
|
200
216
|
nodes,
|
|
201
217
|
sortedNodes,
|
|
202
218
|
sourceCode,
|
|
203
|
-
|
|
204
|
-
partitionComment,
|
|
205
|
-
},
|
|
219
|
+
options,
|
|
206
220
|
)
|
|
207
221
|
},
|
|
208
222
|
})
|
|
@@ -27,10 +27,21 @@ let jsonSchema = {
|
|
|
27
27
|
type: 'string',
|
|
28
28
|
enum: ['asc', 'desc'],
|
|
29
29
|
},
|
|
30
|
+
matcher: {
|
|
31
|
+
description: 'Specifies the string matcher.',
|
|
32
|
+
type: 'string',
|
|
33
|
+
enum: ['minimatch', 'regex'],
|
|
34
|
+
},
|
|
30
35
|
ignoreCase: {
|
|
31
36
|
description: 'Controls whether sorting should be case-sensitive or not.',
|
|
32
37
|
type: 'boolean',
|
|
33
38
|
},
|
|
39
|
+
specialCharacters: {
|
|
40
|
+
description:
|
|
41
|
+
'Controls how special characters should be handled before sorting.',
|
|
42
|
+
type: 'string',
|
|
43
|
+
enum: ['remove', 'trim', 'keep'],
|
|
44
|
+
},
|
|
34
45
|
groupKind: {
|
|
35
46
|
description: 'Specifies top-level groups.',
|
|
36
47
|
enum: ['mixed', 'literals-first', 'spreads-first'],
|
|
@@ -81,6 +92,8 @@ const sortArrayIncludes = createEslintRule({
|
|
|
81
92
|
type: 'alphabetical',
|
|
82
93
|
order: 'asc',
|
|
83
94
|
ignoreCase: true,
|
|
95
|
+
specialCharacters: 'keep',
|
|
96
|
+
matcher: 'minimatch',
|
|
84
97
|
groupKind: 'literals-first',
|
|
85
98
|
partitionByComment: false,
|
|
86
99
|
partitionByNewLine: false,
|
|
@@ -110,6 +123,8 @@ let sortArray = (context, messageId, elements) => {
|
|
|
110
123
|
groupKind: 'literals-first',
|
|
111
124
|
type: 'alphabetical',
|
|
112
125
|
ignoreCase: true,
|
|
126
|
+
specialCharacters: 'keep',
|
|
127
|
+
matcher: 'minimatch',
|
|
113
128
|
order: 'asc',
|
|
114
129
|
partitionByComment: false,
|
|
115
130
|
partitionByNewLine: false,
|
|
@@ -140,6 +155,7 @@ let sortArray = (context, messageId, elements) => {
|
|
|
140
155
|
hasPartitionComment(
|
|
141
156
|
partitionComment,
|
|
142
157
|
getCommentsBefore(element, sourceCode),
|
|
158
|
+
options.matcher,
|
|
143
159
|
)) ||
|
|
144
160
|
(options.partitionByNewLine &&
|
|
145
161
|
lastSortingNode &&
|
|
@@ -184,9 +200,7 @@ let sortArray = (context, messageId, elements) => {
|
|
|
184
200
|
.map(groupedNodes => sortNodes(groupedNodes, options))
|
|
185
201
|
.flat()
|
|
186
202
|
: sortNodes(nodes, options)
|
|
187
|
-
return makeFixes(fixer, nodes, sortedNodes, sourceCode,
|
|
188
|
-
partitionComment,
|
|
189
|
-
})
|
|
203
|
+
return makeFixes(fixer, nodes, sortedNodes, sourceCode, options)
|
|
190
204
|
},
|
|
191
205
|
})
|
|
192
206
|
}
|
|
@@ -19,6 +19,8 @@ const sortAstroAttributes = createEslintRule.createEslintRule({
|
|
|
19
19
|
description: 'Enforce sorted Astro attributes.',
|
|
20
20
|
},
|
|
21
21
|
fixable: 'code',
|
|
22
|
+
deprecated: true,
|
|
23
|
+
replacedBy: ['astro/sort-attributes'],
|
|
22
24
|
schema: [
|
|
23
25
|
{
|
|
24
26
|
type: 'object',
|
|
@@ -34,11 +36,22 @@ const sortAstroAttributes = createEslintRule.createEslintRule({
|
|
|
34
36
|
type: 'string',
|
|
35
37
|
enum: ['asc', 'desc'],
|
|
36
38
|
},
|
|
39
|
+
matcher: {
|
|
40
|
+
description: 'Specifies the string matcher.',
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: ['minimatch', 'regex'],
|
|
43
|
+
},
|
|
37
44
|
ignoreCase: {
|
|
38
45
|
description:
|
|
39
46
|
'Controls whether sorting should be case-sensitive or not.',
|
|
40
47
|
type: 'boolean',
|
|
41
48
|
},
|
|
49
|
+
specialCharacters: {
|
|
50
|
+
description:
|
|
51
|
+
'Controls how special characters should be handled before sorting.',
|
|
52
|
+
type: 'string',
|
|
53
|
+
enum: ['remove', 'trim', 'keep'],
|
|
54
|
+
},
|
|
42
55
|
groups: {
|
|
43
56
|
description: 'Specifies the order of the groups.',
|
|
44
57
|
type: 'array',
|
|
@@ -89,6 +102,8 @@ const sortAstroAttributes = createEslintRule.createEslintRule({
|
|
|
89
102
|
type: 'alphabetical',
|
|
90
103
|
order: 'asc',
|
|
91
104
|
ignoreCase: true,
|
|
105
|
+
specialCharacters: 'keep',
|
|
106
|
+
matcher: 'minimatch',
|
|
92
107
|
groups: [],
|
|
93
108
|
customGroups: {},
|
|
94
109
|
},
|
|
@@ -106,6 +121,8 @@ const sortAstroAttributes = createEslintRule.createEslintRule({
|
|
|
106
121
|
let options = complete.complete(context.options.at(0), settings, {
|
|
107
122
|
type: 'alphabetical',
|
|
108
123
|
ignoreCase: true,
|
|
124
|
+
specialCharacters: 'keep',
|
|
125
|
+
matcher: 'minimatch',
|
|
109
126
|
customGroups: {},
|
|
110
127
|
order: 'asc',
|
|
111
128
|
groups: [],
|
|
@@ -127,7 +144,7 @@ const sortAstroAttributes = createEslintRule.createEslintRule({
|
|
|
127
144
|
? attribute.name.name
|
|
128
145
|
: sourceCode.text.slice(...attribute.name.range)
|
|
129
146
|
let { getGroup, defineGroup, setCustomGroups } =
|
|
130
|
-
useGroups.useGroups(options
|
|
147
|
+
useGroups.useGroups(options)
|
|
131
148
|
setCustomGroups(options.customGroups, name)
|
|
132
149
|
if (attribute.type === 'AstroShorthandAttribute') {
|
|
133
150
|
defineGroup('astro-shorthand')
|
|
@@ -18,6 +18,8 @@ const sortAstroAttributes = createEslintRule({
|
|
|
18
18
|
description: 'Enforce sorted Astro attributes.',
|
|
19
19
|
},
|
|
20
20
|
fixable: 'code',
|
|
21
|
+
deprecated: true,
|
|
22
|
+
replacedBy: ['astro/sort-attributes'],
|
|
21
23
|
schema: [
|
|
22
24
|
{
|
|
23
25
|
type: 'object',
|
|
@@ -33,11 +35,22 @@ const sortAstroAttributes = createEslintRule({
|
|
|
33
35
|
type: 'string',
|
|
34
36
|
enum: ['asc', 'desc'],
|
|
35
37
|
},
|
|
38
|
+
matcher: {
|
|
39
|
+
description: 'Specifies the string matcher.',
|
|
40
|
+
type: 'string',
|
|
41
|
+
enum: ['minimatch', 'regex'],
|
|
42
|
+
},
|
|
36
43
|
ignoreCase: {
|
|
37
44
|
description:
|
|
38
45
|
'Controls whether sorting should be case-sensitive or not.',
|
|
39
46
|
type: 'boolean',
|
|
40
47
|
},
|
|
48
|
+
specialCharacters: {
|
|
49
|
+
description:
|
|
50
|
+
'Controls how special characters should be handled before sorting.',
|
|
51
|
+
type: 'string',
|
|
52
|
+
enum: ['remove', 'trim', 'keep'],
|
|
53
|
+
},
|
|
41
54
|
groups: {
|
|
42
55
|
description: 'Specifies the order of the groups.',
|
|
43
56
|
type: 'array',
|
|
@@ -88,6 +101,8 @@ const sortAstroAttributes = createEslintRule({
|
|
|
88
101
|
type: 'alphabetical',
|
|
89
102
|
order: 'asc',
|
|
90
103
|
ignoreCase: true,
|
|
104
|
+
specialCharacters: 'keep',
|
|
105
|
+
matcher: 'minimatch',
|
|
91
106
|
groups: [],
|
|
92
107
|
customGroups: {},
|
|
93
108
|
},
|
|
@@ -105,6 +120,8 @@ const sortAstroAttributes = createEslintRule({
|
|
|
105
120
|
let options = complete(context.options.at(0), settings, {
|
|
106
121
|
type: 'alphabetical',
|
|
107
122
|
ignoreCase: true,
|
|
123
|
+
specialCharacters: 'keep',
|
|
124
|
+
matcher: 'minimatch',
|
|
108
125
|
customGroups: {},
|
|
109
126
|
order: 'asc',
|
|
110
127
|
groups: [],
|
|
@@ -125,9 +142,8 @@ const sortAstroAttributes = createEslintRule({
|
|
|
125
142
|
typeof attribute.name.name === 'string'
|
|
126
143
|
? attribute.name.name
|
|
127
144
|
: sourceCode.text.slice(...attribute.name.range)
|
|
128
|
-
let { getGroup, defineGroup, setCustomGroups } =
|
|
129
|
-
options
|
|
130
|
-
)
|
|
145
|
+
let { getGroup, defineGroup, setCustomGroups } =
|
|
146
|
+
useGroups(options)
|
|
131
147
|
setCustomGroups(options.customGroups, name)
|
|
132
148
|
if (attribute.type === 'AstroShorthandAttribute') {
|
|
133
149
|
defineGroup('astro-shorthand')
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
3
|
-
const
|
|
3
|
+
const validateGroupsConfiguration$1 = require('../utils/validate-groups-configuration.js')
|
|
4
|
+
const sortClasses_types = require('./sort-classes.types.js')
|
|
5
|
+
const matches = require('../utils/matches.js')
|
|
4
6
|
const cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
5
7
|
const generateOfficialGroups = (modifiers, selectors) => {
|
|
6
8
|
let modifiersAndSelectorsKey = modifiers.join('&') + '/' + selectors.join('&')
|
|
@@ -119,26 +121,35 @@ const customGroupMatches = props => {
|
|
|
119
121
|
'elementNamePattern' in props.customGroup &&
|
|
120
122
|
props.customGroup.elementNamePattern
|
|
121
123
|
) {
|
|
122
|
-
let matchesElementNamePattern =
|
|
124
|
+
let matchesElementNamePattern = matches.matches(
|
|
123
125
|
props.elementName,
|
|
124
126
|
props.customGroup.elementNamePattern,
|
|
125
|
-
|
|
126
|
-
nocomment: true,
|
|
127
|
-
},
|
|
127
|
+
props.matcher,
|
|
128
128
|
)
|
|
129
129
|
if (!matchesElementNamePattern) {
|
|
130
130
|
return false
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
if (
|
|
134
|
+
'elementValuePattern' in props.customGroup &&
|
|
135
|
+
props.customGroup.elementValuePattern
|
|
136
|
+
) {
|
|
137
|
+
let matchesElementValuePattern = matches.matches(
|
|
138
|
+
props.elementValue ?? '',
|
|
139
|
+
props.customGroup.elementValuePattern,
|
|
140
|
+
props.matcher,
|
|
141
|
+
)
|
|
142
|
+
if (!matchesElementValuePattern) {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
}
|
|
133
146
|
if (
|
|
134
147
|
'decoratorNamePattern' in props.customGroup &&
|
|
135
148
|
props.customGroup.decoratorNamePattern
|
|
136
149
|
) {
|
|
137
150
|
let decoratorPattern = props.customGroup.decoratorNamePattern
|
|
138
151
|
let matchesDecoratorNamePattern = props.decorators.some(decorator =>
|
|
139
|
-
|
|
140
|
-
nocomment: true,
|
|
141
|
-
}),
|
|
152
|
+
matches.matches(decorator, decoratorPattern, props.matcher),
|
|
142
153
|
)
|
|
143
154
|
if (!matchesDecoratorNamePattern) {
|
|
144
155
|
return false
|
|
@@ -161,10 +172,53 @@ const getCompareOptions = (options, groupNumber) => {
|
|
|
161
172
|
customGroup && 'order' in customGroup && customGroup.order
|
|
162
173
|
? customGroup.order
|
|
163
174
|
: options.order,
|
|
175
|
+
specialCharacters: options.specialCharacters,
|
|
164
176
|
ignoreCase: options.ignoreCase,
|
|
165
177
|
}
|
|
166
178
|
}
|
|
179
|
+
let validateGroupsConfiguration = (groups, customGroups) => {
|
|
180
|
+
let availableCustomGroupNames = Array.isArray(customGroups)
|
|
181
|
+
? customGroups.map(customGroup => customGroup.groupName)
|
|
182
|
+
: Object.keys(customGroups)
|
|
183
|
+
let invalidGroups = groups
|
|
184
|
+
.flat()
|
|
185
|
+
.filter(
|
|
186
|
+
group =>
|
|
187
|
+
!isPredefinedGroup(group) && !availableCustomGroupNames.includes(group),
|
|
188
|
+
)
|
|
189
|
+
if (invalidGroups.length) {
|
|
190
|
+
throw new Error('Invalid group(s): ' + invalidGroups.join(', '))
|
|
191
|
+
}
|
|
192
|
+
validateGroupsConfiguration$1.validateNoDuplicatedGroups(groups)
|
|
193
|
+
}
|
|
194
|
+
const isPredefinedGroup = input => {
|
|
195
|
+
if (input === 'unknown') {
|
|
196
|
+
return true
|
|
197
|
+
}
|
|
198
|
+
let singleWordSelector = input.split('-').at(-1)
|
|
199
|
+
if (!singleWordSelector) {
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
let twoWordsSelector = input.split('-').slice(-2).join('-')
|
|
203
|
+
let isTwoWordSelectorValid =
|
|
204
|
+
sortClasses_types.allSelectors.includes(twoWordsSelector)
|
|
205
|
+
if (
|
|
206
|
+
!sortClasses_types.allSelectors.includes(singleWordSelector) &&
|
|
207
|
+
!isTwoWordSelectorValid
|
|
208
|
+
) {
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
let modifiers = input.split('-').slice(0, isTwoWordSelectorValid ? -2 : -1)
|
|
212
|
+
return (
|
|
213
|
+
new Set(modifiers).size === modifiers.length &&
|
|
214
|
+
modifiers.every(modifier =>
|
|
215
|
+
sortClasses_types.allModifiers.includes(modifier),
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
}
|
|
167
219
|
exports.customGroupMatches = customGroupMatches
|
|
168
220
|
exports.generateOfficialGroups = generateOfficialGroups
|
|
221
|
+
exports.getCombinations = getCombinations
|
|
169
222
|
exports.getCompareOptions = getCompareOptions
|
|
170
223
|
exports.getOverloadSignatureGroups = getOverloadSignatureGroups
|
|
224
|
+
exports.validateGroupsConfiguration = validateGroupsConfiguration
|