Skip to content

Commit 00a8080

Browse files
authored
feat: improve regex-related options
1 parent 103a8c9 commit 00a8080

Some content is hidden

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

57 files changed

+1722
-1481
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ Allows you to group array elements by their kind, determining whether spread val
197197
Allows you to use comments to separate the members of arrays into logical groups. This can help in organizing and maintaining large arrays by creating partitions based on comments.
198198

199199
- `true` — All comments will be treated as delimiters, creating partitions.
200-
- `false` — Comments will not be used as delimiters.
201-
- `string` — A regexp pattern to specify which comments should act as delimiters.
202-
- `string[]` — A list of regexp patterns to specify which comments should act as delimiters.
203-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
200+
- `false` — Comments will not be used as delimiters.
201+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
202+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
203+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
204204

205205
### partitionByNewLine
206206

@@ -251,7 +251,7 @@ This option is only applicable when `partitionByNewLine` is `false`.
251251
### useConfigurationIf
252252

253253
<sub>
254-
type: `{ allNamesMatchPattern?: string }`
254+
type: `{ allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[] }`
255255
</sub>
256256
<sub>default: `{}`</sub>
257257

@@ -353,7 +353,7 @@ interface CustomGroupDefinition {
353353
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
354354
order?: 'asc' | 'desc'
355355
selector?: string
356-
elementNamePattern?: string
356+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
357357
}
358358

359359
```
@@ -368,7 +368,7 @@ interface CustomGroupAnyOfDefinition {
368368
order?: 'asc' | 'desc'
369369
anyOf: Array<{
370370
selector?: string
371-
elementNamePattern?: string
371+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
372372
}>
373373
}
374374
```

docs/content/rules/sort-classes.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
219219
Allows you to use comments to separate the class members into logical groups. This can help in organizing and maintaining large classes by creating partitions within the class based on comments.
220220

221221
- `true` — All comments will be treated as delimiters, creating partitions.
222-
- `false` — Comments will not be used as delimiters.
223-
- string — A regexp pattern to specify which comments should act as delimiters.
224-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
222+
- `false` — Comments will not be used as delimiters.
223+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
224+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
225+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
225226

226227
### partitionByNewLine
227228

@@ -626,9 +627,9 @@ interface CustomGroupDefinition {
626627
newlinesInside?: 'always' | 'never'
627628
selector?: string
628629
modifiers?: string[]
629-
elementNamePattern?: string
630-
elementValuePattern?: string
631-
decoratorNamePattern?: string
630+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
631+
elementValuePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
632+
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
632633
}
633634
```
634635
A class member will match a `CustomGroupDefinition` group if it matches all the filters of the custom group's definition.
@@ -644,9 +645,9 @@ interface CustomGroupAnyOfDefinition {
644645
anyOf: Array<{
645646
selector?: string
646647
modifiers?: string[]
647-
elementNamePattern?: string
648-
elementValuePattern?: string
649-
decoratorNamePattern?: string
648+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
649+
elementValuePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
650+
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
650651
}>
651652
}
652653
```

docs/content/rules/sort-decorators.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ Allows you to use comments to separate class decorators into logical groups.
214214

215215
- `true` — All comments will be treated as delimiters, creating partitions.
216216
- `false` — Comments will not be used as delimiters.
217-
- `string` — A regexp pattern to specify which comments should act as delimiters.
218-
- `string[]`An array of regexp patterns to specify which comments should act as delimiters.
219-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
217+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
218+
- `RegExpPattern[]`A list of regexp patterns to specify which comments should act as delimiters.
219+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
220220

221221
### groups
222222

docs/content/rules/sort-enums.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ Controls whether numeric enums should always be sorted numerically, regardless o
169169
Allows you to use comments to separate the members of enums into logical groups. This can help in organizing and maintaining large enums by creating partitions within the enum based on comments.
170170

171171
- `true` — All comments will be treated as delimiters, creating partitions.
172-
- `false` — Comments will not be used as delimiters.
173-
- `string` — A regexp pattern to specify which comments should act as delimiters.
174-
- `string[]` — A list of regexp patterns to specify which comments should act as delimiters.
175-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
172+
- `false` — Comments will not be used as delimiters.
173+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
174+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
175+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
176176

177177
### partitionByNewLine
178178

@@ -265,7 +265,7 @@ interface CustomGroupDefinition {
265265
groupName: string
266266
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
267267
order?: 'asc' | 'desc'
268-
elementNamePattern?: string
268+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
269269
}
270270

271271
```
@@ -279,7 +279,7 @@ interface CustomGroupAnyOfDefinition {
279279
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
280280
order?: 'asc' | 'desc'
281281
anyOf: Array<{
282-
elementNamePattern?: string
282+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
283283
}>
284284
}
285285
```

docs/content/rules/sort-exports.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
143143
Allows you to use comments to separate the exports into logical groups. This can help in organizing and maintaining large export blocks by creating partitions based on comments.
144144

145145
- `true` — All comments will be treated as delimiters, creating partitions.
146-
- `false` — Comments will not be used as delimiters.
147-
- `string` — A regexp pattern to specify which comments should act as delimiters.
148-
- `string[]` — A list of regexp patterns to specify which comments should act as delimiters.
149-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
146+
- `false` — Comments will not be used as delimiters.
147+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
148+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
149+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
150150

151151
### partitionByNewLine
152152

docs/content/rules/sort-imports.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ Allows you to use comments to separate imports into logical groups.
200200

201201
- `true` — All comments will be treated as delimiters, creating partitions.
202202
- `false` — Comments will not be used as delimiters.
203-
- `string` — A regexp pattern to specify which comments should act as delimiters.
204-
- `string[]`An array of regexp patterns to specify which comments should act as delimiters.
205-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
203+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
204+
- `RegExpPattern[]`A list of regexp patterns to specify which comments should act as delimiters.
205+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
206206

207207
### partitionByNewLine
208208

docs/content/rules/sort-interfaces.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ Allows you to use comments to separate the properties of interfaces into logical
210210

211211
- `true` — All comments will be treated as delimiters, creating partitions.
212212
- `false` — Comments will not be used as delimiters.
213-
- `string` — A regexp pattern to specify which comments should act as delimiters.
214-
- `string[]`An array of regexp patterns to specify which comments should act as delimiters.
215-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
213+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
214+
- `RegExpPattern[]`A list of regexp patterns to specify which comments should act as delimiters.
215+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
216216

217217
### partitionByNewLine
218218

@@ -269,9 +269,14 @@ Specifies how optional and required members should be ordered in TypeScript inte
269269
### useConfigurationIf
270270

271271
<sub>
272-
type: `{ allNamesMatchPattern?: string; declarationMatchesPattern?: string }`
272+
type:
273+
```
274+
{
275+
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
276+
declarationMatchesPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
277+
}
278+
```
273279
</sub>
274-
<sub>default: `{}`</sub>
275280

276281
Allows you to specify filters to match a particular options configuration for a given interface.
277282

@@ -503,7 +508,7 @@ interface CustomGroupDefinition {
503508
newlinesInside?: 'always' | 'never'
504509
selector?: string
505510
modifiers?: string[]
506-
elementNamePattern?: string
511+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
507512
}
508513

509514
```
@@ -520,7 +525,7 @@ interface CustomGroupAnyOfDefinition {
520525
anyOf: Array<{
521526
selector?: string
522527
modifiers?: string[]
523-
elementNamePattern?: string
528+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
524529
}>
525530
}
526531
```

docs/content/rules/sort-intersection-types.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
139139
Allows you to use comments to separate the members of intersection types into logical groups. This can help in organizing and maintaining large intersection types by creating partitions based on comments.
140140

141141
- `true` — All comments will be treated as delimiters, creating partitions.
142-
- `false` — Comments will not be used as delimiters.
143-
- `string` — A regexp pattern to specify which comments should act as delimiters.
144-
- `string[]` — A list of regexp patterns to specify which comments should act as delimiters.
145-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
142+
- `false` — Comments will not be used as delimiters.
143+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
144+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
145+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
146146

147147
### partitionByNewLine
148148

docs/content/rules/sort-jsx-props.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
194194

195195
### ignorePattern
196196

197+
<sub>
198+
type:
199+
```
200+
{
201+
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
202+
}
203+
```
204+
</sub>
197205
<sub>default: `[]`</sub>
198206

199207
Allows you to specify names or patterns for JSX elements that should be ignored by this rule. This can be useful if you have specific components that you do not want to sort.

docs/content/rules/sort-maps.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
145145
Allows you to use comments to separate the members of maps into logical groups. This can help in organizing and maintaining large maps by creating partitions based on comments.
146146

147147
- `true` — All comments will be treated as delimiters, creating partitions.
148-
- `false` — Comments will not be used as delimiters.
149-
- `string` — A regexp pattern to specify which comments should act as delimiters.
150-
- `string[]` — A list of regexp patterns to specify which comments should act as delimiters.
151-
- `{ block: boolean | string | string[]; line: boolean | string | string[] }` — Specify which block and line comments should act as delimiters.
148+
- `false` — Comments will not be used as delimiters.
149+
- `RegExpPattern = string | { pattern: string; flags: string}` — A regexp pattern to specify which comments should act as delimiters.
150+
- `RegExpPattern[]` — A list of regexp patterns to specify which comments should act as delimiters.
151+
- `{ block: boolean | RegExpPattern | RegExpPattern[]; line: boolean | RegExpPattern | RegExpPattern[] }` — Specify which block and line comments should act as delimiters.
152152

153153
### partitionByNewLine
154154

@@ -197,7 +197,12 @@ This option is only applicable when `partitionByNewLine` is `false`.
197197
### useConfigurationIf
198198

199199
<sub>
200-
type: `{ allNamesMatchPattern?: string }`
200+
type:
201+
```
202+
{
203+
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
204+
}
205+
```
201206
</sub>
202207
<sub>default: `{}`</sub>
203208

@@ -291,7 +296,7 @@ interface CustomGroupDefinition {
291296
groupName: string
292297
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
293298
order?: 'asc' | 'desc'
294-
elementNamePattern?: string
299+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
295300
}
296301

297302
```
@@ -305,7 +310,7 @@ interface CustomGroupAnyOfDefinition {
305310
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
306311
order?: 'asc' | 'desc'
307312
anyOf: Array<{
308-
elementNamePattern?: string
313+
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
309314
}>
310315
}
311316
```

0 commit comments

Comments
 (0)