Skip to content

Commit 8f2126c

Browse files
authored
feat!: improve comment above integration in groups
1 parent 590ce8e commit 8f2126c

Some content is hidden

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

48 files changed

+959
-350
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,14 @@ Example configuration:
310310
### groups
311311

312312
<sub>
313-
type: `Array<string | string[]>`
313+
type:
314+
```ts
315+
Array<
316+
| string
317+
| string[]
318+
| { newlinesBetween: number }
319+
>
320+
```
314321
</sub>
315322
<sub>default: `['literal']`</sub>
316323

docs/content/rules/sort-classes.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,18 @@ Without `ignoreCallbackDependenciesPatterns: ['^computed$']`, `role` and `userna
324324
### groups
325325

326326
<sub>
327-
type: `Array<string | string[]>`
327+
type:
328+
```ts
329+
Array<
330+
| string
331+
| string[]
332+
| { newlinesBetween: number }
333+
>
334+
```
328335
</sub>
329336
<sub>
330337
default:
331-
```
338+
```ts
332339
[
333340
'index-signature',
334341
'static-property',
@@ -709,7 +716,7 @@ you must write a custom group definition that does the same as what the predefin
709716

710717
Example:
711718

712-
```js
719+
```ts
713720
{
714721
groups: [
715722
'static-block',

docs/content/rules/sort-decorators.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,14 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
270270
### groups
271271

272272
<sub>
273-
type: `Array<string | string[]>`
273+
type:
274+
```ts
275+
Array<
276+
| string
277+
| string[]
278+
| { newlinesBetween: number }
279+
>
280+
```
274281
</sub>
275282
<sub>default: `[]`</sub>
276283

@@ -412,7 +419,7 @@ class MyClass {
412419

413420
`groups` and `customGroups` configuration:
414421

415-
```js
422+
```ts
416423
{
417424
groups: [
418425
'unknown',

docs/content/rules/sort-enums.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,14 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
233233
### groups
234234

235235
<sub>
236-
type: `Array<string | string[]>`
236+
type:
237+
```ts
238+
Array<
239+
| string
240+
| string[]
241+
| { newlinesBetween: number }
242+
>
243+
```
237244
</sub>
238245
<sub>default: `[]`</sub>
239246

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ Controls newlines between groups:
157157

158158
### groups
159159

160+
<sub>
161+
type:
162+
```ts
163+
Array<
164+
| string
165+
| string[]
166+
| { newlinesBetween: number }
167+
>
168+
```
169+
</sub>
160170
<sub>default: `[]`</sub>
161171

162172
Defines the order of attribute groups. Unknown attributes are placed after the last group.

docs/content/rules/sort-exports.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Enables the use of comments to separate the exports into logical groups. This ca
180180

181181
When `true`, the rule will not sort the exports if there is an empty line between them. This helps maintain the defined order of logically separated groups of exports.
182182

183-
```js
183+
```ts
184184
// Group 1
185185
export * from "./atoms";
186186
export * from "./organisms";
@@ -213,7 +213,15 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
213213
### groups
214214

215215
<sub>
216-
type: `Array<string | string[]>`
216+
type:
217+
```ts
218+
Array<
219+
| string
220+
| string[]
221+
| { newlinesBetween: number }
222+
| { group: string | string[]; commentAbove: string }
223+
>
224+
```
217225
</sub>
218226
<sub>default: `[]`</sub>
219227

@@ -268,18 +276,14 @@ This feature is only applicable when [`partitionByNewLine`](#partitionbynewline)
268276

269277
#### Comment above groups
270278

271-
You may place `commentAbove` objects between above your groups to enforce the presence of a comment containing the
279+
You may place `commentAbove` objects alongside their related group(s) to enforce the presence of a comment containing the
272280
content of `commentAbove`.
273281

274-
`newlinesBetween` and `commentAbove` objects can be combined together.
275-
276282
```ts
277283
{
278284
groups: [
279-
{ commentAbove: 'Type exports' },
280-
'type-export',
281-
{ commentAbove: 'Value exports' },
282-
'value-export',
285+
{ group: 'type-export', commentAbove: 'Type exports' },
286+
{ group: 'value-export', commentAbove: 'Value exports' },
283287
]
284288
}
285289
```

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,14 @@ This option is only applicable when [`partitionByNewLine`](#partitionbynewline)
183183
### groups
184184

185185
<sub>
186-
type: `Array<string | string[]>`
186+
type:
187+
```ts
188+
Array<
189+
| string
190+
| string[]
191+
| { newlinesBetween: number }
192+
>
193+
```
187194
</sub>
188195
<sub>default: `[]`</sub>
189196

@@ -320,7 +327,7 @@ interface Interface extends WithId, Logged, StartupService {
320327

321328
`groups` and `customGroups` configuration:
322329

323-
```js
330+
```ts
324331
{
325332
groups: [
326333
'withIdInterface', // [!code ++]

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ Controls newlines between groups:
157157

158158
### groups
159159

160+
<sub>
161+
type:
162+
```ts
163+
Array<
164+
| string
165+
| string[]
166+
| { newlinesBetween: number }
167+
>
168+
```
169+
</sub>
160170
<sub>default: `[]`</sub>
161171

162172
Defines the order of attribute groups. Unknown attributes are placed after the last group.

docs/content/rules/sort-imports.mdx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,19 @@ If this option is not set, the rule will not search for a `tsconfig.json` file.
285285
### groups
286286

287287
<sub>
288-
type: `Array<string | string[]>`
288+
type:
289+
```ts
290+
Array<
291+
| string
292+
| string[]
293+
| { newlinesBetween: number }
294+
| { group: string | string[]; commentAbove: string }
295+
>
296+
```
289297
</sub>
290298
<sub>
291299
default:
292-
```
300+
```ts
293301
[
294302
'type-import',
295303
['value-builtin', 'value-external'],
@@ -458,18 +466,14 @@ This feature is only applicable when [`partitionByNewLine`](#partitionbynewline)
458466

459467
#### Comment above groups
460468

461-
You may place `commentAbove` objects between above your groups to enforce the presence of a comment containing the
469+
You may place `commentAbove` objects alongside their related group(s) to enforce the presence of a comment containing the
462470
content of `commentAbove`.
463471

464-
`newlinesBetween` and `commentAbove` objects can be combined together.
465-
466472
```ts
467473
{
468474
groups: [
469-
{ commentAbove: 'Internal imports' },
470-
'internal',
471-
{ commentAbove: 'External imports' },
472-
'external',
475+
{ group: 'internal', commentAbove: 'Internal imports' },
476+
{ group: 'external', commentAbove: 'External imports' },
473477
]
474478
}
475479
```
@@ -589,7 +593,7 @@ you must write a custom group definition that does the same as what the predefin
589593

590594
#### Example
591595

592-
```js
596+
```ts
593597
groups: [
594598
+ 'react', // [!code ++]
595599
'type-import',

docs/content/rules/sort-interfaces.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ interface User {
241241

242242
`sortBy` option configuration:
243243

244-
```js
244+
```ts
245245
{
246246
sortBy: 'value',
247247
}
@@ -419,7 +419,14 @@ Example configuration:
419419
### groups
420420

421421
<sub>
422-
type: `Array<string | string[]>`
422+
type:
423+
```ts
424+
Array<
425+
| string
426+
| string[]
427+
| { newlinesBetween: number }
428+
>
429+
```
423430
</sub>
424431
<sub>default: `[]`</sub>
425432

@@ -453,7 +460,7 @@ interface User {
453460

454461
`groups` option configuration:
455462

456-
```js
463+
```ts
457464
{
458465
groups: [
459466
'unknown',
@@ -670,7 +677,7 @@ interface User {
670677
671678
`groups` and `customGroups` configuration:
672679
673-
```js
680+
```ts
674681
{
675682
groups: [
676683
+ 'top', // [!code ++]

0 commit comments

Comments
 (0)