Skip to content

Commit f9919cb

Browse files
authored
feat: allow order overrides in groups option
1 parent 98404bf commit f9919cb

File tree

71 files changed

+675
-1130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+675
-1130
lines changed

docs/content/rules/sort-array-includes.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ Example configuration:
317317
| { newlinesBetween: number }
318318
| {
319319
group: string | string[];
320-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
320+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
321+
order?: 'asc' | 'desc';
321322
}
322323
>
323324
```
@@ -346,6 +347,7 @@ Predefined groups are characterized by a selector.
346347
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
347348

348349
- `type` — Overrides the [`type`](#type) option for that group.
350+
- `order` — Overrides the [`order`](#order) option for that group.
349351

350352
```ts
351353
{
@@ -514,4 +516,4 @@ This rule was introduced in [v0.5.0](https://github.com/azat-io/eslint-plugin-pe
514516
## Resources
515517

516518
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-array-includes.ts)
517-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-array-includes.test.ts)
519+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-array-includes.test.ts)

docs/content/rules/sort-classes.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ Without `ignoreCallbackDependenciesPatterns: ['^computed$']`, `role` and `userna
332332
| { newlinesBetween: number }
333333
| {
334334
group: string | string[];
335-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
335+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
336+
order?: 'asc' | 'desc';
336337
}
337338
>
338339
```
@@ -607,6 +608,7 @@ abstract class Example extends BaseExample {
607608
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
608609

609610
- `type` — Overrides the [`type`](#type) option for that group.
611+
- `order` — Overrides the [`order`](#order) option for that group.
610612

611613
```ts
612614
{
@@ -911,4 +913,4 @@ This rule was introduced in [v0.11.0](https://github.com/azat-io/eslint-plugin-p
911913
## Resources
912914

913915
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-classes.ts)
914-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-classes.test.ts)
916+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-classes.test.ts)

docs/content/rules/sort-decorators.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
278278
| { newlinesBetween: number }
279279
| {
280280
group: string | string[];
281-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
281+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
282+
order?: 'asc' | 'desc';
282283
}
283284
>
284285
```
@@ -306,6 +307,7 @@ All members of the groups in the array will be sorted together as if they were p
306307
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
307308

308309
- `type` — Overrides the [`type`](#type) option for that group.
310+
- `order` — Overrides the [`order`](#order) option for that group.
309311

310312
```ts
311313
{
@@ -542,4 +544,4 @@ This rule was introduced in [v4.0.0](https://github.com/azat-io/eslint-plugin-pe
542544
## Resources
543545

544546
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-decorators.ts)
545-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-decorators.test.ts)
547+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-decorators.test.ts)

docs/content/rules/sort-enums.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
241241
| { newlinesBetween: number }
242242
| {
243243
group: string | string[];
244-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
244+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
245+
order?: 'asc' | 'desc';
245246
}
246247
>
247248
```
@@ -263,6 +264,7 @@ All members of the groups in the array will be sorted together as if they were p
263264
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
264265

265266
- `type` — Overrides the [`type`](#type) option for that group.
267+
- `order` — Overrides the [`order`](#order) option for that group.
266268

267269
```ts
268270
{

docs/content/rules/sort-export-attributes.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ Controls newlines between groups:
166166
| { newlinesBetween: number }
167167
| {
168168
group: string | string[];
169-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
169+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
170+
order?: 'asc' | 'desc';
170171
}
171172
>
172173
```
@@ -192,6 +193,7 @@ newlinesBetween: 'always'
192193
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
193194

194195
- `type` — Overrides the [`type`](#type) option for that group.
196+
- `order` — Overrides the [`order`](#order) option for that group.
195197

196198
```ts
197199
{

docs/content/rules/sort-exports.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
221221
| { newlinesBetween: number }
222222
| {
223223
group: string | string[];
224-
commentAbove?: string;
225224
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
225+
order?: 'asc' | 'desc';
226+
commentAbove?: string;
226227
}
227228
>
228229
```
@@ -264,6 +265,7 @@ it will automatically be added to the end of the list.
264265
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
265266

266267
- `type` — Overrides the [`type`](#type) option for that group.
268+
- `order` — Overrides the [`order`](#order) option for that group.
267269
- `commentAbove` — Enforces the presence of a comment containing the content of `commentAbove` above the top element of the group.
268270
- An error will be raised if no comment containing the content of `commentAbove` is found above the top element of the
269271
group.
@@ -440,4 +442,4 @@ This rule was introduced in [v1.2.0](https://github.com/azat-io/eslint-plugin-pe
440442
## Resources
441443

442444
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-exports.ts)
443-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-exports.test.ts)
445+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-exports.test.ts)

docs/content/rules/sort-heritage-clauses.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
191191
| { newlinesBetween: number }
192192
| {
193193
group: string | string[];
194-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
194+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
195+
order?: 'asc' | 'desc';
195196
}
196197
>
197198
```
@@ -219,6 +220,7 @@ All members of the groups in the array will be sorted together as if they were p
219220
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
220221

221222
- `type` — Overrides the [`type`](#type) option for that group.
223+
- `order` — Overrides the [`order`](#order) option for that group.
222224

223225
```ts
224226
{
@@ -440,4 +442,4 @@ This rule was introduced in [v4.0.0](https://github.com/azat-io/eslint-plugin-pe
440442
## Resources
441443

442444
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-heritage-clauses.ts)
443-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-heritage-clauses.test.ts)
445+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-heritage-clauses.test.ts)

docs/content/rules/sort-import-attributes.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ Controls newlines between groups:
166166
| { newlinesBetween: number }
167167
| {
168168
group: string | string[];
169-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
169+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
170+
order?: 'asc' | 'desc';
170171
}
171172
>
172173
```
@@ -192,6 +193,7 @@ newlinesBetween: 'always'
192193
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
193194

194195
- `type` — Overrides the [`type`](#type) option for that group.
196+
- `order` — Overrides the [`order`](#order) option for that group.
195197

196198
```ts
197199
{

docs/content/rules/sort-imports.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ If this option is not set, the rule will not search for a `tsconfig.json` file.
293293
| { newlinesBetween: number }
294294
| {
295295
group: string | string[];
296-
commentAbove?: string;
297296
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
297+
order?: 'asc' | 'desc';
298+
commentAbove?: string;
298299
}
299300
>
300301
```
@@ -454,6 +455,7 @@ import NotFoundError = ErrorsNamespace.NotFoundError
454455
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
455456

456457
- `type` — Overrides the [`type`](#type) option for that group.
458+
- `order` — Overrides the [`order`](#order) option for that group.
457459
- `commentAbove` — Enforces the presence of a comment containing the content of `commentAbove` above the top element of the group.
458460
- An error will be raised if no comment containing the content of `commentAbove` is found above the top element of the
459461
group.
@@ -734,4 +736,4 @@ This rule was introduced in [v0.9.0](https://github.com/azat-io/eslint-plugin-pe
734736
## Resources
735737

736738
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-imports.ts)
737-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-imports.test.ts)
739+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-imports.test.ts)

docs/content/rules/sort-interfaces.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ Example configuration:
427427
| { newlinesBetween: number }
428428
| {
429429
group: string | string[];
430-
type: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
430+
type?: 'alphabetical' | 'natural' | 'line-length' | 'custom' | 'unsorted';
431+
order?: 'asc' | 'desc';
431432
}
432433
>
433434
```
@@ -549,6 +550,7 @@ interface Interface {
549550
You may directly override options for a specific group by using an object with the `group` property and other option overrides.
550551
551552
- `type` — Overrides the [`type`](#type) option for that group.
553+
- `order` — Overrides the [`order`](#order) option for that group.
552554
553555
```ts
554556
{
@@ -801,4 +803,4 @@ This rule was introduced in [v0.1.0](https://github.com/azat-io/eslint-plugin-pe
801803
## Resources
802804
803805
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-interfaces.ts)
804-
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-interfaces.test.ts)
806+
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/rules/sort-interfaces.test.ts)

0 commit comments

Comments
 (0)