You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/content/rules/sort-imports.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -369,7 +369,7 @@ This feature is only applicable when `partitionByNewLine` is false.
369
369
</sub>
370
370
<sub>default: `{ value: {}, type: {} }`</sub>
371
371
372
-
You can define your own groups and use regexp pattern to match specific imports.
372
+
You can define your own groups and use regexp patterns to match specific imports.
373
373
374
374
Each key of the `value` or `type` fields represents a group name which you can then use in the `groups` option. The value for each key can either be of type:
375
375
-`string` — An import matching the value will be marked as part of the group referenced by the key.
Copy file name to clipboardexpand all lines: docs/content/rules/sort-objects.mdx
+183-37
Original file line number
Diff line number
Diff line change
@@ -365,55 +365,194 @@ Example configuration:
365
365
366
366
Allows you to specify a list of object keys groups for sorting. Groups help organize object keys into categories, making your objects more readable and maintainable.
367
367
368
-
Predefined groups:
369
-
370
-
-`'multiline'` — Properties with multiline definitions, such as methods or complex type declarations.
371
-
-`'method'` - Members that are methods.
372
-
-`'unknown'` — Properties that don’t fit into any group specified in the `groups` option.
373
-
374
-
If the `unknown` group is not specified in the `groups` option, it will automatically be added to the end of the list.
375
-
376
-
Each object member will be assigned a single group specified in the `groups` option (or the `unknown` group if no match is found).
368
+
Each property will be assigned a single group specified in the `groups` option (or the `unknown` group if no match is found).
377
369
The order of items in the `groups` option determines how groups are ordered.
378
370
379
371
Within a given group, members will be sorted according to the `type`, `order`, `ignoreCase`, etc. options.
380
372
381
373
Individual groups can be combined together by placing them in an array. The order of groups in that array does not matter.
382
374
All members of the groups in the array will be sorted together as if they were part of a single group.
383
375
376
+
Predefined groups are characterized by a single selector and potentially multiple modifiers. You may enter modifiers in any order, but the selector must always come at the end.
Members that don’t fit into any group specified in the `groups` option will be placed in the `unknown` group. If the `unknown` group is not specified in the `groups` option,
422
+
it will automatically be added to the end of the list.
423
+
424
+
##### Behavior when multiple groups match an element
425
+
426
+
The lists of modifiers above are sorted by importance, from most to least important.
427
+
In case of multiple groups matching an element, the following rules will be applied:
428
+
429
+
1. The group with the most modifiers matching will be selected.
430
+
2. If modifiers quantity is the same, order will be chosen based on modifier importance as listed above.
431
+
432
+
Example :
433
+
434
+
```ts
435
+
interfaceTest {
436
+
multilineMethod: () => {
437
+
property:string;
438
+
}
439
+
}
440
+
```
441
+
442
+
`multilineMethod` can be matched by the following groups, from most to least important:
443
+
-`multiline-method`.
444
+
-`method`.
445
+
-`multiline-member`.
446
+
-`member`.
447
+
-`unknown`.
448
+
384
449
### customGroups
385
450
451
+
<Importanttitle="Migrating from the old API">
452
+
Support for the object-based `customGroups` option is deprecated.
453
+
454
+
Migrating from the old to the current API is easy:
0 commit comments