Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improves regex-related options #464

Merged
merged 25 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0f0b82a
feat: adds `RegexOption` type
hugop95 Feb 7, 2025
207a55e
feat: adds `RegexOption` handling in `partitionByComment`
hugop95 Feb 7, 2025
e319030
feat: adds `RegexOption` handling in `settings.ignorePattern`
hugop95 Feb 7, 2025
4915b0a
feat: adds `RegexOption` handling in `useConfigurationIf.allNamesMatc…
hugop95 Feb 7, 2025
f5cf077
feat: improves other JSON schemas
hugop95 Feb 7, 2025
f6b349d
feat(sort-imports): adds `RegexOption` handling
hugop95 Feb 7, 2025
ddc908d
feat(sort-jsx-props): adds `RegexOption` handling
hugop95 Feb 7, 2025
9eef42c
feat(sort-array-includes): adds `RegexOption` handling
hugop95 Feb 7, 2025
e3a47cd
feat(sort-sets): adds `RegexOption` handling
hugop95 Feb 7, 2025
31ad6b9
feat(sort-maps): adds `RegexOption` handling
hugop95 Feb 7, 2025
1ee113c
feat(sort-classes): adds `RegexOption` handling
hugop95 Feb 7, 2025
85b4116
feat(sort-enums): adds `RegexOption` handling
hugop95 Feb 7, 2025
b22e58f
feat(sort-modules): adds `RegexOption` handling
hugop95 Feb 7, 2025
2a45d1b
feat(sort-object-types): adds `RegexOption` handling
hugop95 Feb 7, 2025
cac7f90
feat(sort-interfaces): adds `RegexOption` handling
hugop95 Feb 7, 2025
87411a5
feat(sort-objects): adds `RegexOption` handling
hugop95 Feb 7, 2025
abe2578
feat(sort-decorators): adds `RegexOption` handling
hugop95 Feb 7, 2025
00de9ab
feat(sort-exports): adds `RegexOption` handling
hugop95 Feb 7, 2025
b488a00
feat(sort-intersection-types): adds `RegexOption` handling
hugop95 Feb 7, 2025
8de9087
feat(sort-union-types): adds `RegexOption` handling
hugop95 Feb 7, 2025
af5d3e3
feat(sort-named-exports): adds `RegexOption` handling
hugop95 Feb 7, 2025
6a5a9f9
feat(sort-named-imports): adds `RegexOption` handling
hugop95 Feb 7, 2025
ffd9f96
feat(sort-variable-declarations): adds `RegexOption` handling
hugop95 Feb 7, 2025
1bc725a
test: removes useless regex character
hugop95 Feb 8, 2025
1b33260
docs: updates readme wordings
hugop95 Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/content/rules/sort-array-includes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ Allows you to group array elements by their kind, determining whether spread val
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.

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

### partitionByNewLine

Expand Down Expand Up @@ -251,7 +251,7 @@ This option is only applicable when `partitionByNewLine` is `false`.
### useConfigurationIf

<sub>
type: `{ allNamesMatchPattern?: string }`
type: `{ allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[] }`
</sub>
<sub>default: `{}`</sub>

Expand Down Expand Up @@ -353,7 +353,7 @@ interface CustomGroupDefinition {
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
order?: 'asc' | 'desc'
selector?: string
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}

```
Expand All @@ -368,7 +368,7 @@ interface CustomGroupAnyOfDefinition {
order?: 'asc' | 'desc'
anyOf: Array<{
selector?: string
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
19 changes: 10 additions & 9 deletions docs/content/rules/sort-classes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
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.

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

### partitionByNewLine

Expand Down Expand Up @@ -626,9 +627,9 @@ interface CustomGroupDefinition {
newlinesInside?: 'always' | 'never'
selector?: string
modifiers?: string[]
elementNamePattern?: string
elementValuePattern?: string
decoratorNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
elementValuePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}
```
A class member will match a `CustomGroupDefinition` group if it matches all the filters of the custom group's definition.
Expand All @@ -644,9 +645,9 @@ interface CustomGroupAnyOfDefinition {
anyOf: Array<{
selector?: string
modifiers?: string[]
elementNamePattern?: string
elementValuePattern?: string
decoratorNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
elementValuePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/content/rules/sort-decorators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ Allows you to use comments to separate class decorators into logical groups.

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

### groups

Expand Down
12 changes: 6 additions & 6 deletions docs/content/rules/sort-enums.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ Controls whether numeric enums should always be sorted numerically, regardless o
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.

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

### partitionByNewLine

Expand Down Expand Up @@ -265,7 +265,7 @@ interface CustomGroupDefinition {
groupName: string
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
order?: 'asc' | 'desc'
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}

```
Expand All @@ -279,7 +279,7 @@ interface CustomGroupAnyOfDefinition {
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
order?: 'asc' | 'desc'
anyOf: Array<{
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
8 changes: 4 additions & 4 deletions docs/content/rules/sort-exports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
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.

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

### partitionByNewLine

Expand Down
6 changes: 3 additions & 3 deletions docs/content/rules/sort-imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ Allows you to use comments to separate imports into logical groups.

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

### partitionByNewLine

Expand Down
19 changes: 12 additions & 7 deletions docs/content/rules/sort-interfaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ Allows you to use comments to separate the properties of interfaces into logical

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

### partitionByNewLine

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

<sub>
type: `{ allNamesMatchPattern?: string; declarationMatchesPattern?: string }`
type:
```
{
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
declarationMatchesPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
}
```
</sub>
<sub>default: `{}`</sub>

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

Expand Down Expand Up @@ -503,7 +508,7 @@ interface CustomGroupDefinition {
newlinesInside?: 'always' | 'never'
selector?: string
modifiers?: string[]
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}

```
Expand All @@ -520,7 +525,7 @@ interface CustomGroupAnyOfDefinition {
anyOf: Array<{
selector?: string
modifiers?: string[]
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
8 changes: 4 additions & 4 deletions docs/content/rules/sort-intersection-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
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.

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

### partitionByNewLine

Expand Down
8 changes: 8 additions & 0 deletions docs/content/rules/sort-jsx-props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](

### ignorePattern

<sub>
type:
```
{
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
}
```
</sub>
<sub>default: `[]`</sub>

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.
Expand Down
19 changes: 12 additions & 7 deletions docs/content/rules/sort-maps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
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.

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

### partitionByNewLine

Expand Down Expand Up @@ -197,7 +197,12 @@ This option is only applicable when `partitionByNewLine` is `false`.
### useConfigurationIf

<sub>
type: `{ allNamesMatchPattern?: string }`
type:
```
{
allNamesMatchPattern?: string | string[] | { pattern: string; flags: string } | { pattern: string; flags: string }[]
}
```
</sub>
<sub>default: `{}`</sub>

Expand Down Expand Up @@ -291,7 +296,7 @@ interface CustomGroupDefinition {
groupName: string
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
order?: 'asc' | 'desc'
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}

```
Expand All @@ -305,7 +310,7 @@ interface CustomGroupAnyOfDefinition {
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted'
order?: 'asc' | 'desc'
anyOf: Array<{
elementNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
15 changes: 8 additions & 7 deletions docs/content/rules/sort-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ Specifies the sorting locales. See [String.prototype.localeCompare() - locales](
Allows you to use comments to separate the module members into logical groups. This can help in organizing and maintaining large modules by creating partitions based on comments.

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

### partitionByNewLine

Expand Down Expand Up @@ -408,8 +409,8 @@ interface CustomGroupDefinition {
newlinesInside?: 'always' | 'never'
selector?: string
modifiers?: string[]
elementNamePattern?: string
decoratorNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}
```
A module member will match a `CustomGroupDefinition` group if it matches all the filters of the custom group's definition.
Expand All @@ -425,8 +426,8 @@ interface CustomGroupAnyOfDefinition {
anyOf: Array<{
selector?: string
modifiers?: string[]
elementNamePattern?: string
decoratorNamePattern?: string
elementNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
decoratorNamePattern?: string | string[] | { pattern: string; flags?: string } | { pattern: string; flags?: string }[]
}>
}
```
Expand Down
8 changes: 4 additions & 4 deletions docs/content/rules/sort-named-exports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ Allows you to group named exports by their kind, determining whether value expor
Allows you to use comments to separate the members of named exports into logical groups. This can help in organizing and maintaining large named exports by creating partitions based on comments.

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

### partitionByNewLine

Expand Down
Loading