eslint-plugin-perfectionist 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json.js +1 -1
- package/dist/rules/sort-array-includes/types.d.ts +15 -18
- package/dist/rules/sort-array-includes/types.js +2 -2
- package/dist/rules/sort-array-includes.js +13 -10
- package/dist/rules/sort-classes/compute-dependencies.d.ts +24 -0
- package/dist/rules/sort-classes/compute-dependencies.js +147 -0
- package/dist/rules/sort-classes/compute-dependency-name.d.ts +9 -0
- package/dist/rules/sort-classes/compute-dependency-name.js +8 -0
- package/dist/rules/sort-classes/compute-identifier-name-details.d.ts +16 -0
- package/dist/rules/sort-classes/compute-identifier-name-details.js +27 -0
- package/dist/rules/sort-classes/get-overload-signature-groups.js +4 -3
- package/dist/rules/sort-classes/node-info/common-modifiers.d.ts +39 -0
- package/dist/rules/sort-classes/node-info/common-modifiers.js +62 -0
- package/dist/rules/sort-classes/node-info/compute-accessor-details.d.ts +26 -0
- package/dist/rules/sort-classes/node-info/compute-accessor-details.js +43 -0
- package/dist/rules/sort-classes/node-info/compute-index-signature-details.d.ts +23 -0
- package/dist/rules/sort-classes/node-info/compute-index-signature-details.js +21 -0
- package/dist/rules/sort-classes/node-info/compute-method-details.d.ts +29 -0
- package/dist/rules/sort-classes/node-info/compute-method-details.js +80 -0
- package/dist/rules/sort-classes/node-info/compute-method-or-property-name-details.d.ts +21 -0
- package/dist/rules/sort-classes/node-info/compute-method-or-property-name-details.js +17 -0
- package/dist/rules/sort-classes/node-info/compute-property-details.d.ts +36 -0
- package/dist/rules/sort-classes/node-info/compute-property-details.js +109 -0
- package/dist/rules/sort-classes/node-info/compute-static-block-details.d.ts +26 -0
- package/dist/rules/sort-classes/node-info/compute-static-block-details.js +18 -0
- package/dist/rules/sort-classes/types.d.ts +15 -18
- package/dist/rules/sort-classes/types.js +6 -2
- package/dist/rules/sort-classes.js +79 -291
- package/dist/rules/sort-decorators/types.d.ts +10 -12
- package/dist/rules/sort-decorators.js +57 -56
- package/dist/rules/sort-enums/build-comparator-by-options-computer.js +6 -0
- package/dist/rules/sort-enums/types.d.ts +16 -19
- package/dist/rules/sort-enums/types.js +2 -2
- package/dist/rules/sort-enums.js +13 -11
- package/dist/rules/sort-export-attributes/types.d.ts +6 -8
- package/dist/rules/sort-export-attributes.js +2 -1
- package/dist/rules/sort-exports/types.d.ts +11 -10
- package/dist/rules/sort-exports/types.js +6 -2
- package/dist/rules/sort-exports.js +7 -6
- package/dist/rules/sort-heritage-clauses/types.d.ts +6 -8
- package/dist/rules/sort-heritage-clauses.js +2 -1
- package/dist/rules/sort-import-attributes/types.d.ts +6 -8
- package/dist/rules/sort-import-attributes.js +2 -1
- package/dist/rules/sort-imports/comparator-by-options-computer.js +5 -0
- package/dist/rules/sort-imports/compute-specifier-modifiers.js +1 -1
- package/dist/rules/sort-imports/is-non-external-reference-ts-import-equals.js +1 -1
- package/dist/rules/sort-imports/is-side-effect-import.js +1 -1
- package/dist/rules/sort-imports/types.d.ts +18 -24
- package/dist/rules/sort-imports/types.js +9 -6
- package/dist/rules/sort-imports.js +25 -17
- package/dist/rules/sort-jsx-props/types.d.ts +18 -18
- package/dist/rules/sort-jsx-props/types.js +6 -2
- package/dist/rules/sort-jsx-props.js +14 -7
- package/dist/rules/sort-maps/types.d.ts +10 -16
- package/dist/rules/sort-maps.js +11 -6
- package/dist/rules/sort-modules/build-comparator-by-options-computer.js +2 -0
- package/dist/rules/sort-modules/compute-dependencies.d.ts +2 -5
- package/dist/rules/sort-modules/compute-dependencies.js +3 -0
- package/dist/rules/sort-modules/compute-node-details.d.ts +38 -0
- package/dist/rules/sort-modules/compute-node-details.js +127 -0
- package/dist/rules/sort-modules/is-arrow-function-node.js +1 -1
- package/dist/rules/sort-modules/is-property-or-accessor-node.js +1 -1
- package/dist/rules/sort-modules/types.d.ts +24 -17
- package/dist/rules/sort-modules/types.js +2 -2
- package/dist/rules/sort-modules.js +72 -141
- package/dist/rules/sort-named-exports/compute-node-name.js +1 -1
- package/dist/rules/sort-named-exports/types.d.ts +16 -16
- package/dist/rules/sort-named-exports/types.js +6 -2
- package/dist/rules/sort-named-exports.js +6 -5
- package/dist/rules/sort-named-imports/compute-node-name.js +1 -1
- package/dist/rules/sort-named-imports/types.d.ts +16 -17
- package/dist/rules/sort-named-imports/types.js +6 -2
- package/dist/rules/sort-named-imports.js +7 -6
- package/dist/rules/sort-object-types/comparator-by-options-computer.js +3 -0
- package/dist/rules/sort-object-types/is-member-optional.js +1 -1
- package/dist/rules/sort-object-types/is-node-function-type.js +20 -0
- package/dist/rules/sort-object-types/types.d.ts +21 -34
- package/dist/rules/sort-object-types/types.js +9 -6
- package/dist/rules/sort-object-types.js +7 -6
- package/dist/rules/sort-objects/types.d.ts +17 -21
- package/dist/rules/sort-objects/types.js +3 -3
- package/dist/rules/sort-objects.js +5 -3
- package/dist/rules/sort-sets.js +5 -4
- package/dist/rules/sort-switch-case.js +6 -4
- package/dist/rules/sort-union-types/types.d.ts +12 -12
- package/dist/rules/sort-union-types/types.js +2 -2
- package/dist/rules/sort-union-types.js +37 -35
- package/dist/rules/sort-variable-declarations/types.d.ts +12 -13
- package/dist/rules/sort-variable-declarations/types.js +2 -2
- package/dist/rules/sort-variable-declarations.js +14 -12
- package/dist/types/all-common-options.d.ts +14 -0
- package/dist/types/common-groups-options.d.ts +73 -95
- package/dist/types/common-options.d.ts +60 -55
- package/dist/utils/build-default-options-by-group-index-computer.d.ts +1 -1
- package/dist/utils/compare/build-string-formatter.d.ts +4 -5
- package/dist/utils/compare/build-subgroup-order-comparator.d.ts +10 -0
- package/dist/utils/compare/build-subgroup-order-comparator.js +49 -0
- package/dist/utils/compare/default-comparator-by-options-computer.d.ts +4 -1
- package/dist/utils/compare/default-comparator-by-options-computer.js +9 -0
- package/dist/utils/compute-group.d.ts +9 -9
- package/dist/utils/compute-overridden-options-by-group-index.d.ts +1 -1
- package/dist/utils/does-custom-group-match.d.ts +6 -4
- package/dist/utils/get-comment-above-that-should-exist.d.ts +1 -1
- package/dist/utils/get-newlines-between-errors.d.ts +1 -1
- package/dist/utils/get-newlines-between-option.d.ts +1 -7
- package/dist/utils/get-node-range.d.ts +2 -9
- package/dist/utils/get-settings.d.ts +1 -1
- package/dist/utils/is-group-with-overrides-option.d.ts +3 -6
- package/dist/utils/json-schemas/common-groups-json-schemas.d.ts +6 -6
- package/dist/utils/json-schemas/common-groups-json-schemas.js +12 -10
- package/dist/utils/json-schemas/common-json-schemas.d.ts +5 -5
- package/dist/utils/json-schemas/common-json-schemas.js +13 -12
- package/dist/utils/make-comment-above-fixes.d.ts +1 -1
- package/dist/utils/make-fixes.d.ts +3 -5
- package/dist/utils/make-newlines-between-fixes.d.ts +1 -1
- package/dist/utils/make-order-fixes.d.ts +2 -5
- package/dist/utils/report-all-errors.d.ts +19 -17
- package/dist/utils/report-errors.d.ts +3 -1
- package/dist/utils/should-partition.d.ts +2 -5
- package/dist/utils/validate-custom-sort-configuration.d.ts +1 -1
- package/dist/utils/validate-groups-configuration.d.ts +1 -1
- package/dist/utils/validate-newlines-and-partition-configuration.d.ts +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/dist/types/join.d.ts +0 -19
- package/dist/utils/is-node-function-type.js +0 -13
- /package/dist/{utils → rules/sort-object-types}/is-node-function-type.d.ts +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NewlinesBetweenOption,
|
|
3
|
-
NewlinesInsideOption,
|
|
4
3
|
CommonGroupsOptions,
|
|
5
4
|
} from '../types/common-groups-options.js'
|
|
6
5
|
/**
|
|
@@ -11,12 +10,7 @@ import {
|
|
|
11
10
|
*/
|
|
12
11
|
export interface GetNewlinesBetweenOptionParameters {
|
|
13
12
|
/** Configuration options for newlines and groups. */
|
|
14
|
-
options:
|
|
15
|
-
CommonGroupsOptions<unknown, unknown, string>,
|
|
16
|
-
'newlinesInside'
|
|
17
|
-
> & {
|
|
18
|
-
newlinesInside: NewlinesInsideOption | 'newlinesBetween'
|
|
19
|
-
}
|
|
13
|
+
options: CommonGroupsOptions<string, unknown, unknown>
|
|
20
14
|
/** Group index of the next/second node. */
|
|
21
15
|
nextNodeGroupIndex: number
|
|
22
16
|
/** Group index of the current/first node. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types'
|
|
2
2
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
3
|
-
import {
|
|
3
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for determining the complete range of a node.
|
|
6
6
|
*
|
|
@@ -9,14 +9,7 @@ import { PartitionByCommentOption } from '../types/common-partition-options.js'
|
|
|
9
9
|
*/
|
|
10
10
|
interface GetNodeRangeParameters {
|
|
11
11
|
/** Optional configuration for comment handling. */
|
|
12
|
-
options?:
|
|
13
|
-
/**
|
|
14
|
-
* Configuration for partition comments that separate code sections. If
|
|
15
|
-
* specified, partition comments stop the inclusion of preceding
|
|
16
|
-
* comments.
|
|
17
|
-
*/
|
|
18
|
-
partitionByComment?: PartitionByCommentOption
|
|
19
|
-
}
|
|
12
|
+
options?: Pick<CommonPartitionOptions, 'partitionByComment'>
|
|
20
13
|
/**
|
|
21
14
|
* Whether to exclude the highest-level block comment from the range. Useful
|
|
22
15
|
* for preserving file-level documentation comments in their original
|
|
@@ -11,7 +11,7 @@ import { CommonOptions } from '../types/common-options.js'
|
|
|
11
11
|
*/
|
|
12
12
|
export type Settings = Partial<
|
|
13
13
|
Pick<
|
|
14
|
-
CommonGroupsOptions<
|
|
14
|
+
CommonGroupsOptions<string, unknown, unknown>,
|
|
15
15
|
'newlinesBetween' | 'newlinesInside'
|
|
16
16
|
> &
|
|
17
17
|
CommonPartitionOptions &
|
|
@@ -28,13 +28,10 @@ import {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function isGroupWithOverridesOption<
|
|
30
30
|
CustomTypeOption extends string,
|
|
31
|
-
|
|
31
|
+
AdditionalSortOptions,
|
|
32
32
|
>(
|
|
33
|
-
groupOption: GroupsOptions<
|
|
34
|
-
CustomTypeOption,
|
|
35
|
-
AdditionalSortProperties
|
|
36
|
-
>[number],
|
|
33
|
+
groupOption: GroupsOptions<CustomTypeOption, AdditionalSortOptions>[number],
|
|
37
34
|
): groupOption is GroupWithOverridesOption<
|
|
38
35
|
CustomTypeOption,
|
|
39
|
-
|
|
36
|
+
AdditionalSortOptions
|
|
40
37
|
>
|
|
@@ -36,25 +36,25 @@ export declare function buildGroupsJsonSchema({
|
|
|
36
36
|
*
|
|
37
37
|
* @param options - Configuration options.
|
|
38
38
|
* @param options.additionalSortProperties - Extra properties for sorting.
|
|
39
|
-
* @param options.
|
|
40
|
-
*
|
|
39
|
+
* @param options.additionalCustomGroupMatchProperties - Extra properties for
|
|
40
|
+
* matching custom groups.
|
|
41
41
|
* @returns JSON schema for custom groups array validation.
|
|
42
42
|
*/
|
|
43
43
|
export declare function buildCustomGroupsArrayJsonSchema({
|
|
44
|
-
|
|
44
|
+
additionalCustomGroupMatchProperties,
|
|
45
45
|
allowedAdditionalTypeValues,
|
|
46
46
|
additionalSortProperties,
|
|
47
47
|
}: {
|
|
48
|
-
|
|
48
|
+
additionalCustomGroupMatchProperties: Record<string, JSONSchema4> | undefined
|
|
49
49
|
additionalSortProperties: Record<string, JSONSchema4> | undefined
|
|
50
50
|
allowedAdditionalTypeValues: undefined | string[]
|
|
51
51
|
}): JSONSchema4
|
|
52
52
|
export declare function buildCommonGroupsJsonSchemas({
|
|
53
|
-
|
|
53
|
+
additionalCustomGroupMatchProperties,
|
|
54
54
|
allowedAdditionalTypeValues,
|
|
55
55
|
additionalSortProperties,
|
|
56
56
|
}?: {
|
|
57
|
-
|
|
57
|
+
additionalCustomGroupMatchProperties?: Record<string, JSONSchema4>
|
|
58
58
|
additionalSortProperties?: Record<string, JSONSchema4>
|
|
59
59
|
allowedAdditionalTypeValues?: string[]
|
|
60
60
|
}): Record<string, JSONSchema4>
|
|
@@ -98,7 +98,7 @@ function buildGroupsJsonSchema({
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function buildCustomGroupsArrayJsonSchema({
|
|
101
|
-
|
|
101
|
+
additionalCustomGroupMatchProperties,
|
|
102
102
|
allowedAdditionalTypeValues,
|
|
103
103
|
additionalSortProperties,
|
|
104
104
|
}) {
|
|
@@ -106,8 +106,10 @@ function buildCustomGroupsArrayJsonSchema({
|
|
|
106
106
|
allowedAdditionalTypeValues,
|
|
107
107
|
additionalSortProperties,
|
|
108
108
|
})
|
|
109
|
-
let
|
|
110
|
-
|
|
109
|
+
let populatedCustomGroupMatchOptionsJsonSchema =
|
|
110
|
+
buildPopulatedCustomGroupMatchPropertiesJsonSchema(
|
|
111
|
+
additionalCustomGroupMatchProperties,
|
|
112
|
+
)
|
|
111
113
|
return {
|
|
112
114
|
items: {
|
|
113
115
|
oneOf: [
|
|
@@ -116,7 +118,7 @@ function buildCustomGroupsArrayJsonSchema({
|
|
|
116
118
|
...commonCustomGroupJsonSchemas,
|
|
117
119
|
anyOf: {
|
|
118
120
|
items: {
|
|
119
|
-
properties:
|
|
121
|
+
properties: populatedCustomGroupMatchOptionsJsonSchema,
|
|
120
122
|
description: 'Custom group.',
|
|
121
123
|
additionalProperties: false,
|
|
122
124
|
type: 'object',
|
|
@@ -133,7 +135,7 @@ function buildCustomGroupsArrayJsonSchema({
|
|
|
133
135
|
{
|
|
134
136
|
properties: {
|
|
135
137
|
...commonCustomGroupJsonSchemas,
|
|
136
|
-
...
|
|
138
|
+
...populatedCustomGroupMatchOptionsJsonSchema,
|
|
137
139
|
},
|
|
138
140
|
description: 'Custom group.',
|
|
139
141
|
additionalProperties: false,
|
|
@@ -148,14 +150,14 @@ function buildCustomGroupsArrayJsonSchema({
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
function buildCommonGroupsJsonSchemas({
|
|
151
|
-
|
|
153
|
+
additionalCustomGroupMatchProperties,
|
|
152
154
|
allowedAdditionalTypeValues,
|
|
153
155
|
additionalSortProperties,
|
|
154
156
|
} = {}) {
|
|
155
157
|
return {
|
|
156
158
|
customGroups: buildCustomGroupsArrayJsonSchema({
|
|
159
|
+
additionalCustomGroupMatchProperties,
|
|
157
160
|
allowedAdditionalTypeValues,
|
|
158
|
-
singleCustomGroupJsonSchema,
|
|
159
161
|
additionalSortProperties,
|
|
160
162
|
}),
|
|
161
163
|
newlinesInside: {
|
|
@@ -209,12 +211,12 @@ function buildCommonCustomGroupJsonSchemas({
|
|
|
209
211
|
...additionalSortProperties,
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
+
function buildPopulatedCustomGroupMatchPropertiesJsonSchema(
|
|
215
|
+
customGroupMatchOptionsJsonSchema,
|
|
214
216
|
) {
|
|
215
217
|
return {
|
|
216
218
|
elementNamePattern: buildRegexJsonSchema(),
|
|
217
|
-
...
|
|
219
|
+
...customGroupMatchOptionsJsonSchema,
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
export {
|
|
@@ -58,13 +58,13 @@ export declare function buildUseConfigurationIfJsonSchema({
|
|
|
58
58
|
}?: {
|
|
59
59
|
additionalProperties?: Record<string, JSONSchema4>
|
|
60
60
|
}): JSONSchema4
|
|
61
|
-
export declare function buildRegexJsonSchema({
|
|
62
|
-
additionalProperties,
|
|
63
|
-
}?: {
|
|
64
|
-
additionalProperties?: Record<string, JSONSchema4>
|
|
65
|
-
}): JSONSchema4
|
|
66
61
|
export declare function buildTypeJsonSchema({
|
|
67
62
|
allowedAdditionalValues,
|
|
68
63
|
}: {
|
|
69
64
|
allowedAdditionalValues: undefined | string[]
|
|
70
65
|
}): JSONSchema4
|
|
66
|
+
export declare function buildRegexJsonSchema({
|
|
67
|
+
additionalProperties,
|
|
68
|
+
}?: {
|
|
69
|
+
additionalProperties?: Record<string, JSONSchema4>
|
|
70
|
+
}): JSONSchema4
|
|
@@ -83,18 +83,6 @@ function buildUseConfigurationIfJsonSchema({ additionalProperties } = {}) {
|
|
|
83
83
|
type: 'object',
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function buildRegexJsonSchema({ additionalProperties } = {}) {
|
|
87
|
-
return {
|
|
88
|
-
oneOf: [
|
|
89
|
-
{
|
|
90
|
-
items: buildSingleRegexJsonSchema({ additionalProperties }),
|
|
91
|
-
type: 'array',
|
|
92
|
-
},
|
|
93
|
-
buildSingleRegexJsonSchema({ additionalProperties }),
|
|
94
|
-
],
|
|
95
|
-
description: 'Regular expression.',
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
86
|
function buildTypeJsonSchema({ allowedAdditionalValues }) {
|
|
99
87
|
return {
|
|
100
88
|
enum: [
|
|
@@ -103,12 +91,25 @@ function buildTypeJsonSchema({ allowedAdditionalValues }) {
|
|
|
103
91
|
'line-length',
|
|
104
92
|
'custom',
|
|
105
93
|
'unsorted',
|
|
94
|
+
'subgroup-order',
|
|
106
95
|
...(allowedAdditionalValues ?? []),
|
|
107
96
|
],
|
|
108
97
|
description: 'Specifies the sorting method.',
|
|
109
98
|
type: 'string',
|
|
110
99
|
}
|
|
111
100
|
}
|
|
101
|
+
function buildRegexJsonSchema({ additionalProperties } = {}) {
|
|
102
|
+
return {
|
|
103
|
+
oneOf: [
|
|
104
|
+
{
|
|
105
|
+
items: buildSingleRegexJsonSchema({ additionalProperties }),
|
|
106
|
+
type: 'array',
|
|
107
|
+
},
|
|
108
|
+
buildSingleRegexJsonSchema({ additionalProperties }),
|
|
109
|
+
],
|
|
110
|
+
description: 'Regular expression.',
|
|
111
|
+
}
|
|
112
|
+
}
|
|
112
113
|
function buildSingleRegexJsonSchema({ additionalProperties }) {
|
|
113
114
|
return {
|
|
114
115
|
oneOf: [
|
|
@@ -5,7 +5,7 @@ import { SortingNode } from '../types/sorting-node.js'
|
|
|
5
5
|
interface MakeCommentAboveFixesParameters {
|
|
6
6
|
/** Configuration options containing groups and custom groups. */
|
|
7
7
|
options: Pick<
|
|
8
|
-
CommonGroupsOptions<
|
|
8
|
+
CommonGroupsOptions<string, unknown, unknown>,
|
|
9
9
|
'customGroups' | 'groups'
|
|
10
10
|
>
|
|
11
11
|
/** ESLint source code object for accessing comments and tokens. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
2
|
-
import {
|
|
2
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
3
|
import { NewlinesBetweenValueGetter } from './get-newlines-between-errors.js'
|
|
4
4
|
import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
5
5
|
import { SortingNode } from '../types/sorting-node.js'
|
|
@@ -10,10 +10,8 @@ import { SortingNode } from '../types/sorting-node.js'
|
|
|
10
10
|
*/
|
|
11
11
|
interface MakeFixesParameters<T extends SortingNode> {
|
|
12
12
|
/** Optional configuration for various sorting behaviors. */
|
|
13
|
-
options?:
|
|
14
|
-
|
|
15
|
-
partitionByComment?: PartitionByCommentOption
|
|
16
|
-
} & CommonGroupsOptions<unknown, unknown, string>
|
|
13
|
+
options?: Pick<CommonPartitionOptions, 'partitionByComment'> &
|
|
14
|
+
CommonGroupsOptions<string, unknown, unknown>
|
|
17
15
|
/** Optional function to customize newlines between specific nodes. */
|
|
18
16
|
newlinesBetweenValueGetter?: NewlinesBetweenValueGetter<T>
|
|
19
17
|
/**
|
|
@@ -14,7 +14,7 @@ interface MakeNewlinesBetweenFixesParameters<T extends SortingNode> {
|
|
|
14
14
|
*/
|
|
15
15
|
newlinesBetweenValueGetter?: NewlinesBetweenValueGetter<T>
|
|
16
16
|
/** Configuration options for groups and newlines. */
|
|
17
|
-
options: CommonGroupsOptions<
|
|
17
|
+
options: CommonGroupsOptions<string, unknown, unknown>
|
|
18
18
|
/** ESLint source code object for accessing text and locations. */
|
|
19
19
|
sourceCode: TSESLint.SourceCode
|
|
20
20
|
/** ESLint fixer object for creating fix operations. */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
2
|
-
import {
|
|
2
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
3
|
import { SortingNode } from '../types/sorting-node.js'
|
|
4
4
|
/** Parameters for generating order fixes. */
|
|
5
5
|
interface MakeOrderFixesParameters {
|
|
6
6
|
/** Optional configuration options. */
|
|
7
|
-
options?:
|
|
8
|
-
/** Configuration for partition comments that separate code sections. */
|
|
9
|
-
partitionByComment?: PartitionByCommentOption
|
|
10
|
-
}
|
|
7
|
+
options?: Pick<CommonPartitionOptions, 'partitionByComment'>
|
|
11
8
|
/**
|
|
12
9
|
* Whether to ignore the highest block comment for the first node. Useful
|
|
13
10
|
* for preserving file-level documentation comments.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
2
2
|
import { NewlinesBetweenValueGetter } from './get-newlines-between-errors.js'
|
|
3
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
4
|
import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
4
5
|
import { SortingNode } from '../types/sorting-node.js'
|
|
5
6
|
/**
|
|
@@ -44,6 +45,24 @@ interface ReportAllErrorsParameters<
|
|
|
44
45
|
/** Message for general ordering violations within a group. */
|
|
45
46
|
unexpectedOrder: MessageIds
|
|
46
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration options for sorting and grouping.
|
|
50
|
+
*
|
|
51
|
+
* Extends MakeFixesParameters options with groups configuration. Includes
|
|
52
|
+
* all sorting preferences, partition settings, newlines configuration, and
|
|
53
|
+
* custom group definitions.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* options: {
|
|
57
|
+
* type: 'alphabetical',
|
|
58
|
+
* order: 'asc',
|
|
59
|
+
* groups: ['static-property', 'property', 'constructor', 'method'],
|
|
60
|
+
* newlinesBetween: 1,
|
|
61
|
+
* partitionByComment: true
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
options: Pick<CommonPartitionOptions, 'partitionByComment'> &
|
|
65
|
+
CommonGroupsOptions<string, unknown, unknown>
|
|
47
66
|
/**
|
|
48
67
|
* Function to get sorted nodes with or without ESLint-disabled nodes.
|
|
49
68
|
*
|
|
@@ -86,23 +105,6 @@ interface ReportAllErrorsParameters<
|
|
|
86
105
|
* @returns Number of required newlines or 'ignore'.
|
|
87
106
|
*/
|
|
88
107
|
newlinesBetweenValueGetter?: NewlinesBetweenValueGetter<T>
|
|
89
|
-
/**
|
|
90
|
-
* Configuration options for sorting and grouping.
|
|
91
|
-
*
|
|
92
|
-
* Extends MakeFixesParameters options with groups configuration. Includes
|
|
93
|
-
* all sorting preferences, partition settings, newlines configuration, and
|
|
94
|
-
* custom group definitions.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* options: {
|
|
98
|
-
* type: 'alphabetical',
|
|
99
|
-
* order: 'asc',
|
|
100
|
-
* groups: ['static-property', 'property', 'constructor', 'method'],
|
|
101
|
-
* newlinesBetween: 1,
|
|
102
|
-
* partitionByComment: true
|
|
103
|
-
* }
|
|
104
|
-
*/
|
|
105
|
-
options: CommonGroupsOptions<unknown, unknown, string>
|
|
106
108
|
/**
|
|
107
109
|
* ESLint rule context for reporting errors.
|
|
108
110
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
2
2
|
import { NewlinesBetweenValueGetter } from './get-newlines-between-errors.js'
|
|
3
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
4
|
import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
4
5
|
import { SortingNode } from '../types/sorting-node.js'
|
|
5
6
|
export declare const RIGHT = 'right'
|
|
@@ -20,8 +21,9 @@ interface ReportErrorsParameters<
|
|
|
20
21
|
MessageIds extends string,
|
|
21
22
|
T extends SortingNode,
|
|
22
23
|
> {
|
|
24
|
+
options?: Pick<CommonPartitionOptions, 'partitionByComment'> &
|
|
25
|
+
CommonGroupsOptions<string, unknown, unknown>
|
|
23
26
|
newlinesBetweenValueGetter?: NewlinesBetweenValueGetter<T>
|
|
24
|
-
options?: CommonGroupsOptions<unknown, unknown, string>
|
|
25
27
|
context: TSESLint.RuleContext<MessageIds, unknown[]>
|
|
26
28
|
ignoreFirstNodeHighestBlockComment?: boolean
|
|
27
29
|
firstUnorderedNodeDependentOnRight?: T
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils'
|
|
2
|
-
import {
|
|
2
|
+
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
3
|
import { SortingNode } from '../types/sorting-node.js'
|
|
4
4
|
/** Parameters for determining if a new partition should start. */
|
|
5
5
|
interface ShouldPartitionParameters {
|
|
6
|
-
options: {
|
|
7
|
-
partitionByComment?: PartitionByCommentOption
|
|
8
|
-
partitionByNewLine: boolean
|
|
9
|
-
}
|
|
10
6
|
lastSortingNode: Pick<SortingNode, 'node'> | undefined
|
|
11
7
|
sortingNode: Pick<SortingNode, 'node'>
|
|
12
8
|
tokenValueToIgnoreBefore?: string
|
|
9
|
+
options: CommonPartitionOptions
|
|
13
10
|
sourceCode: TSESLint.SourceCode
|
|
14
11
|
}
|
|
15
12
|
/**
|
|
@@ -2,7 +2,7 @@ import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
|
2
2
|
import { CommonOptions } from '../types/common-options.js'
|
|
3
3
|
/** Options for custom sort configuration validation. */
|
|
4
4
|
type Options = {
|
|
5
|
-
groups?: CommonGroupsOptions<
|
|
5
|
+
groups?: CommonGroupsOptions<string, unknown, unknown>['groups']
|
|
6
6
|
} & Pick<CommonOptions, 'alphabet' | 'type'>
|
|
7
7
|
/**
|
|
8
8
|
* Validates configuration when using custom sort type.
|
|
@@ -2,7 +2,7 @@ import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
|
2
2
|
/** Parameters for validating generated groups configuration. */
|
|
3
3
|
interface ValidateGenerateGroupsConfigurationParameters {
|
|
4
4
|
options: Pick<
|
|
5
|
-
CommonGroupsOptions<
|
|
5
|
+
CommonGroupsOptions<string, unknown, unknown>,
|
|
6
6
|
'customGroups' | 'groups'
|
|
7
7
|
>
|
|
8
8
|
selectors: readonly string[]
|
|
@@ -2,7 +2,7 @@ import { CommonGroupsOptions } from '../types/common-groups-options.js'
|
|
|
2
2
|
import { CommonPartitionOptions } from '../types/common-partition-options.js'
|
|
3
3
|
/** Options for validating newlines and partition configuration. */
|
|
4
4
|
type Options = Pick<
|
|
5
|
-
CommonGroupsOptions<
|
|
5
|
+
CommonGroupsOptions<string, unknown, unknown>,
|
|
6
6
|
'newlinesBetween' | 'newlinesInside' | 'customGroups' | 'groups'
|
|
7
7
|
> &
|
|
8
8
|
Pick<CommonPartitionOptions, 'partitionByNewLine'>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-perfectionist",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"./dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@typescript-eslint/utils": "^8.
|
|
32
|
+
"@typescript-eslint/utils": "^8.52.0",
|
|
33
33
|
"natural-orderby": "^5.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/readme.md
CHANGED
|
@@ -147,7 +147,7 @@ export default [
|
|
|
147
147
|
]
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
### Legacy Config ([`.eslintrc`](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated))
|
|
150
|
+
### Legacy Config ([`.eslintrc.js`](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated))
|
|
151
151
|
|
|
152
152
|
<!-- prettier-ignore -->
|
|
153
153
|
```js
|
package/dist/types/join.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Joins an array of strings with a specified separator.
|
|
3
|
-
*
|
|
4
|
-
* @template T - The array of strings to join.
|
|
5
|
-
* @template Separator - The separator to use between joined strings.
|
|
6
|
-
*/
|
|
7
|
-
export type Join<T extends string[], Separator extends string> = T extends [
|
|
8
|
-
infer First extends string,
|
|
9
|
-
...infer Rest extends string[],
|
|
10
|
-
]
|
|
11
|
-
? Rest extends []
|
|
12
|
-
? `${First}`
|
|
13
|
-
: `${WithSeparatorOrEmpty<First, Separator>}${Join<Rest, Separator>}`
|
|
14
|
-
: never
|
|
15
|
-
/** Helper type to conditionally add a separator between strings. */
|
|
16
|
-
type WithSeparatorOrEmpty<T extends string, Separator extends string> =
|
|
17
|
-
| `${T}${Separator}`
|
|
18
|
-
| ''
|
|
19
|
-
export {}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function isNodeFunctionType(node) {
|
|
2
|
-
if (node.type === 'TSMethodSignature' || node.type === 'TSFunctionType') {
|
|
3
|
-
return true
|
|
4
|
-
}
|
|
5
|
-
if (node.type === 'TSUnionType' || node.type === 'TSIntersectionType') {
|
|
6
|
-
return node.types.every(isNodeFunctionType)
|
|
7
|
-
}
|
|
8
|
-
if (node.type === 'TSPropertySignature' && node.typeAnnotation) {
|
|
9
|
-
return isNodeFunctionType(node.typeAnnotation.typeAnnotation)
|
|
10
|
-
}
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
export { isNodeFunctionType }
|
|
File without changes
|