eslint-plugin-perfectionist 5.13.0 → 5.14.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.js +7 -12
- package/dist/rules/sort-arrays/sort-array.d.ts +0 -4
- package/dist/rules/sort-arrays/sort-array.js +17 -21
- package/dist/rules/sort-arrays/types.d.ts +1 -0
- package/dist/rules/sort-arrays/types.js +6 -1
- package/dist/rules/sort-arrays.js +7 -12
- package/dist/rules/sort-classes/compute-dependencies-by-sorting-node.js +1 -1
- package/dist/rules/sort-classes/compute-dependencies.js +1 -1
- package/dist/rules/sort-classes/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-classes/compute-overload-signature-groups.js +1 -1
- package/dist/rules/sort-classes/node-info/compute-accessor-details.js +2 -2
- package/dist/rules/sort-classes/node-info/compute-method-details.js +1 -1
- package/dist/rules/sort-classes/node-info/compute-property-details.js +2 -2
- package/dist/rules/sort-classes/sort-class.js +30 -35
- package/dist/rules/sort-classes/types.d.ts +10 -10
- package/dist/rules/sort-classes/types.js +11 -11
- package/dist/rules/sort-classes.js +16 -16
- package/dist/rules/sort-constructor-parameters/sort-constructor-parameters.d.ts +0 -2
- package/dist/rules/sort-constructor-parameters/sort-constructor-parameters.js +14 -16
- package/dist/rules/sort-constructor-parameters/types.js +1 -1
- package/dist/rules/sort-constructor-parameters.js +2 -7
- package/dist/rules/sort-decorators/types.d.ts +5 -1
- package/dist/rules/sort-decorators/types.js +3 -0
- package/dist/rules/sort-decorators.js +104 -79
- package/dist/rules/sort-enums/build-comparator-by-options-computer.js +3 -3
- package/dist/rules/sort-enums/compute-dependencies-by-sorting-node.js +1 -1
- package/dist/rules/sort-enums/sort-enum.js +31 -22
- package/dist/rules/sort-enums/types.d.ts +4 -0
- package/dist/rules/sort-enums/types.js +4 -0
- package/dist/rules/sort-enums.js +15 -15
- package/dist/rules/sort-export-attributes.js +1 -1
- package/dist/rules/sort-exports.js +22 -27
- package/dist/rules/sort-heritage-clauses/sort-heritage-clause.js +27 -18
- package/dist/rules/sort-heritage-clauses/types.d.ts +4 -0
- package/dist/rules/sort-heritage-clauses/types.js +4 -0
- package/dist/rules/sort-heritage-clauses.js +13 -13
- package/dist/rules/sort-import-attributes/sort-import-or-export-attributes.js +19 -11
- package/dist/rules/sort-import-attributes/types.d.ts +4 -0
- package/dist/rules/sort-import-attributes/types.js +3 -0
- package/dist/rules/sort-import-attributes.js +7 -7
- package/dist/rules/sort-imports/comparator-by-options-computer.js +2 -2
- package/dist/rules/sort-imports/compute-common-selectors.js +1 -1
- package/dist/rules/sort-imports/is-side-effect-only-group.js +1 -1
- package/dist/rules/sort-imports/types.d.ts +14 -14
- package/dist/rules/sort-imports/types.js +15 -15
- package/dist/rules/sort-imports/validate-side-effects-config.js +1 -1
- package/dist/rules/sort-imports.js +48 -67
- package/dist/rules/sort-interfaces.js +2 -2
- package/dist/rules/sort-intersection-types.js +2 -7
- package/dist/rules/sort-jsx-props/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-jsx-props/sort-jsx-object.js +21 -26
- package/dist/rules/sort-jsx-props/types.js +1 -1
- package/dist/rules/sort-jsx-props.js +14 -14
- package/dist/rules/sort-maps/sort-potential-map.js +26 -17
- package/dist/rules/sort-maps/types.d.ts +4 -0
- package/dist/rules/sort-maps/types.js +4 -0
- package/dist/rules/sort-maps.js +9 -9
- package/dist/rules/sort-modules/build-comparator-by-options-computer.js +1 -1
- package/dist/rules/sort-modules/build-usage-comparator.js +2 -2
- package/dist/rules/sort-modules/compute-arrow-function-declarator.d.ts +16 -0
- package/dist/rules/sort-modules/compute-arrow-function-declarator.js +29 -0
- package/dist/rules/sort-modules/compute-node-details.d.ts +4 -0
- package/dist/rules/sort-modules/compute-node-details.js +30 -4
- package/dist/rules/sort-modules/compute-overload-signature-groups.js +1 -1
- package/dist/rules/sort-modules/dependencies/compute-dependencies-by-sorting-node.js +58 -34
- package/dist/rules/sort-modules/limit-dependencies-to-blocks.d.ts +14 -0
- package/dist/rules/sort-modules/limit-dependencies-to-blocks.js +30 -0
- package/dist/rules/sort-modules/split-groups-at-arrow-functions.d.ts +31 -0
- package/dist/rules/sort-modules/split-groups-at-arrow-functions.js +59 -0
- package/dist/rules/sort-modules/types.d.ts +13 -13
- package/dist/rules/sort-modules/types.js +12 -5
- package/dist/rules/sort-modules.js +74 -43
- package/dist/rules/sort-named-exports/sort-named-export.js +23 -28
- package/dist/rules/sort-named-exports.js +14 -14
- package/dist/rules/sort-named-imports/sort-named-import.js +23 -28
- package/dist/rules/sort-named-imports.js +14 -14
- package/dist/rules/sort-object-types/compute-matched-context-options.js +2 -2
- package/dist/rules/sort-object-types/passes-declaration-comment-matches-filter.js +1 -1
- package/dist/rules/sort-object-types/passes-declaration-matches-pattern-filter.js +1 -1
- package/dist/rules/sort-object-types/sort-object-type-elements.js +19 -24
- package/dist/rules/sort-object-types/types.d.ts +2 -2
- package/dist/rules/sort-object-types/types.js +6 -6
- package/dist/rules/sort-object-types.js +13 -13
- package/dist/rules/sort-objects/compute-matched-context-options.js +4 -4
- package/dist/rules/sort-objects/passes-declaration-comment-matches-filter.js +1 -1
- package/dist/rules/sort-objects/passes-declaration-matches-pattern-filter.js +1 -1
- package/dist/rules/sort-objects/sort-object.js +29 -34
- package/dist/rules/sort-objects/types.d.ts +1 -1
- package/dist/rules/sort-objects/types.js +5 -5
- package/dist/rules/sort-objects.js +18 -18
- package/dist/rules/sort-sets.js +1 -6
- package/dist/rules/sort-switch-case.js +9 -9
- package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.d.ts +0 -4
- package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.js +17 -20
- package/dist/rules/sort-union-types/types.d.ts +2 -0
- package/dist/rules/sort-union-types/types.js +6 -1
- package/dist/rules/sort-union-types.js +2 -7
- package/dist/rules/sort-variable-declarations/sort-variable-declaration.js +24 -28
- package/dist/rules/sort-variable-declarations/types.d.ts +1 -0
- package/dist/rules/sort-variable-declarations/types.js +2 -0
- package/dist/rules/sort-variable-declarations.js +17 -17
- package/dist/types/common-groups-options.d.ts +29 -28
- package/dist/utils/can-report-errors.js +1 -1
- package/dist/utils/compare/compare-alphabetically.js +1 -1
- package/dist/utils/compare/compare-by-custom-sort.js +2 -2
- package/dist/utils/compare/compare-naturally.js +1 -1
- package/dist/utils/compare/default-comparator-by-options-computer.js +1 -1
- package/dist/utils/compare/name-or-value-comparator-by-options-computer.js +1 -1
- package/dist/utils/compute-deep-scope-references.js +18 -1
- package/dist/utils/compute-dependencies-by-sorting-node.d.ts +4 -1
- package/dist/utils/compute-dependencies-by-sorting-node.js +11 -4
- package/dist/utils/does-custom-group-match.d.ts +13 -8
- package/dist/utils/does-node-end-with-expression.js +4 -0
- package/dist/utils/get-eslint-disabled-lines.js +1 -1
- package/dist/utils/get-node-range.js +1 -1
- package/dist/utils/get-settings.js +1 -1
- package/dist/utils/group-matcher.d.ts +76 -0
- package/dist/utils/group-matcher.js +202 -0
- package/dist/utils/is-partition-comment.js +1 -1
- package/dist/utils/json-schemas/scoped-regex-json-schema.js +1 -1
- package/dist/utils/make-comment-above-fixes.js +2 -2
- package/dist/utils/make-newlines-between-fixes.js +1 -1
- package/dist/utils/make-order-fixes.js +7 -2
- package/dist/utils/parse-predefined-group.d.ts +53 -0
- package/dist/utils/parse-predefined-group.js +101 -0
- package/dist/utils/report-all-errors.js +3 -3
- package/dist/utils/scoped-regex/matches-scoped-expressions.js +1 -1
- package/dist/utils/should-partition.js +1 -1
- package/dist/utils/validate-groups-config.js +8 -139
- package/package.json +3 -3
- package/dist/utils/compute-group.d.ts +0 -72
- package/dist/utils/compute-group.js +0 -64
- package/dist/utils/generate-predefined-groups.d.ts +0 -25
- package/dist/utils/generate-predefined-groups.js +0 -75
- package/dist/utils/get-array-combinations.d.ts +0 -11
- package/dist/utils/get-array-combinations.js +0 -24
package/dist/package.json.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EXTRA_SPACING_ERROR,
|
|
3
|
-
GROUP_ORDER_ERROR,
|
|
4
|
-
MISSED_SPACING_ERROR,
|
|
5
|
-
ORDER_ERROR,
|
|
6
|
-
} from '../utils/report-errors.js'
|
|
7
1
|
import {
|
|
8
2
|
buildCommonJsonSchemas,
|
|
9
3
|
buildUseConfigIfJsonSchema,
|
|
@@ -13,16 +7,18 @@ import {
|
|
|
13
7
|
partitionByCommentJsonSchema,
|
|
14
8
|
partitionByNewlineJsonSchema,
|
|
15
9
|
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
10
|
+
import {
|
|
11
|
+
EXTRA_SPACING_ERROR,
|
|
12
|
+
GROUP_ORDER_ERROR,
|
|
13
|
+
MISSED_SPACING_ERROR,
|
|
14
|
+
ORDER_ERROR,
|
|
15
|
+
} from '../utils/report-errors.js'
|
|
16
16
|
import { buildCommonGroupsJsonSchemas } from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
17
|
+
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
17
18
|
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
18
19
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
19
|
-
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
20
20
|
import { sortArray } from './sort-arrays/sort-array.js'
|
|
21
21
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
22
|
-
/**
|
|
23
|
-
* Cache computed groups by modifiers and selectors for performance.
|
|
24
|
-
*/
|
|
25
|
-
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
26
22
|
const ORDER_ERROR_ID = 'unexpectedArrayIncludesOrder'
|
|
27
23
|
const GROUP_ORDER_ERROR_ID = 'unexpectedArrayIncludesGroupOrder'
|
|
28
24
|
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArrayIncludesMembers'
|
|
@@ -103,7 +99,6 @@ function sortPotentiallyValidArray({ matchedAstSelectors, context, node }) {
|
|
|
103
99
|
unexpectedOrder: ORDER_ERROR_ID,
|
|
104
100
|
},
|
|
105
101
|
mustHaveMatchedContextOptions: false,
|
|
106
|
-
cachedGroupsByModifiersAndSelectors,
|
|
107
102
|
matchedAstSelectors,
|
|
108
103
|
defaultOptions,
|
|
109
104
|
context,
|
|
@@ -5,8 +5,6 @@ import { Options } from './types.js'
|
|
|
5
5
|
* Sorts the elements of an array-like expression.
|
|
6
6
|
*
|
|
7
7
|
* @param params - Parameters.
|
|
8
|
-
* @param params.cachedGroupsByModifiersAndSelectors - Cache of predefined
|
|
9
|
-
* groups.
|
|
10
8
|
* @param params.mustHaveMatchedContextOptions - Whether to skip nodes matching
|
|
11
9
|
* no option.
|
|
12
10
|
* @param params.availableMessageIds - The message IDs to report with.
|
|
@@ -16,7 +14,6 @@ import { Options } from './types.js'
|
|
|
16
14
|
* @param params.node - Array or `new` expression whose elements are sorted.
|
|
17
15
|
*/
|
|
18
16
|
export declare function sortArray<MessageIds extends string>({
|
|
19
|
-
cachedGroupsByModifiersAndSelectors,
|
|
20
17
|
mustHaveMatchedContextOptions,
|
|
21
18
|
availableMessageIds,
|
|
22
19
|
matchedAstSelectors,
|
|
@@ -30,7 +27,6 @@ export declare function sortArray<MessageIds extends string>({
|
|
|
30
27
|
unexpectedGroupOrder: MessageIds
|
|
31
28
|
unexpectedOrder: MessageIds
|
|
32
29
|
}
|
|
33
|
-
cachedGroupsByModifiersAndSelectors: Map<string, string[]>
|
|
34
30
|
node: TSESTree.ArrayExpression | TSESTree.NewExpression
|
|
35
31
|
context: Readonly<RuleContext<MessageIds, Options>>
|
|
36
32
|
defaultOptions: Required<Options[number]>
|
|
@@ -2,31 +2,28 @@ import { defaultComparatorByOptionsComputer } from '../../utils/compare/default-
|
|
|
2
2
|
import { validateNewlinesAndPartitionConfig } from '../../utils/validate-newlines-and-partition-config.js'
|
|
3
3
|
import { buildOptionsByGroupIndexComputer } from '../../utils/build-options-by-group-index-computer.js'
|
|
4
4
|
import { validateCustomSortConfig } from '../../utils/validate-custom-sort-config.js'
|
|
5
|
-
import {
|
|
5
|
+
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
6
6
|
import { getEslintDisabledLines } from '../../utils/get-eslint-disabled-lines.js'
|
|
7
7
|
import { doesCustomGroupMatch } from '../../utils/does-custom-group-match.js'
|
|
8
8
|
import { isNodeEslintDisabled } from '../../utils/is-node-eslint-disabled.js'
|
|
9
9
|
import { validateGroupsConfig } from '../../utils/validate-groups-config.js'
|
|
10
10
|
import { sortNodesByGroups } from '../../utils/sort-nodes-by-groups.js'
|
|
11
|
+
import { computeArrayElements } from './compute-array-elements.js'
|
|
11
12
|
import { reportAllErrors } from '../../utils/report-all-errors.js'
|
|
13
|
+
import { canReportErrors } from '../../utils/can-report-errors.js'
|
|
12
14
|
import { shouldPartition } from '../../utils/should-partition.js'
|
|
13
|
-
import {
|
|
15
|
+
import { GroupMatcher } from '../../utils/group-matcher.js'
|
|
14
16
|
import { rangeToDiff } from '../../utils/range-to-diff.js'
|
|
15
17
|
import { getSettings } from '../../utils/get-settings.js'
|
|
18
|
+
import { computeNodeName } from './compute-node-name.js'
|
|
16
19
|
import { isSortable } from '../../utils/is-sortable.js'
|
|
20
|
+
import { allModifiers, allSelectors } from './types.js'
|
|
17
21
|
import { complete } from '../../utils/complete.js'
|
|
18
|
-
import { canReportErrors } from '../../utils/can-report-errors.js'
|
|
19
|
-
import { allSelectors } from './types.js'
|
|
20
|
-
import { computeNodeName } from './compute-node-name.js'
|
|
21
|
-
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
22
|
-
import { computeArrayElements } from './compute-array-elements.js'
|
|
23
22
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
24
23
|
/**
|
|
25
24
|
* Sorts the elements of an array-like expression.
|
|
26
25
|
*
|
|
27
26
|
* @param params - Parameters.
|
|
28
|
-
* @param params.cachedGroupsByModifiersAndSelectors - Cache of predefined
|
|
29
|
-
* groups.
|
|
30
27
|
* @param params.mustHaveMatchedContextOptions - Whether to skip nodes matching
|
|
31
28
|
* no option.
|
|
32
29
|
* @param params.availableMessageIds - The message IDs to report with.
|
|
@@ -36,7 +33,6 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
|
36
33
|
* @param params.node - Array or `new` expression whose elements are sorted.
|
|
37
34
|
*/
|
|
38
35
|
function sortArray({
|
|
39
|
-
cachedGroupsByModifiersAndSelectors,
|
|
40
36
|
mustHaveMatchedContextOptions,
|
|
41
37
|
availableMessageIds,
|
|
42
38
|
matchedAstSelectors,
|
|
@@ -69,7 +65,7 @@ function sortArray({
|
|
|
69
65
|
validateCustomSortConfig(options)
|
|
70
66
|
validateGroupsConfig({
|
|
71
67
|
selectors: allSelectors,
|
|
72
|
-
modifiers:
|
|
68
|
+
modifiers: allModifiers,
|
|
73
69
|
options,
|
|
74
70
|
})
|
|
75
71
|
validateNewlinesAndPartitionConfig(options)
|
|
@@ -84,6 +80,11 @@ function sortArray({
|
|
|
84
80
|
) {
|
|
85
81
|
return
|
|
86
82
|
}
|
|
83
|
+
let groupMatcher = new GroupMatcher({
|
|
84
|
+
allModifiers,
|
|
85
|
+
allSelectors,
|
|
86
|
+
options,
|
|
87
|
+
})
|
|
87
88
|
let eslintDisabledLines = getEslintDisabledLines({
|
|
88
89
|
ruleName: id,
|
|
89
90
|
sourceCode,
|
|
@@ -102,22 +103,17 @@ function sortArray({
|
|
|
102
103
|
node: element,
|
|
103
104
|
sourceCode,
|
|
104
105
|
})
|
|
105
|
-
let
|
|
106
|
-
let
|
|
107
|
-
cache: cachedGroupsByModifiersAndSelectors,
|
|
108
|
-
selectors: [selector],
|
|
109
|
-
modifiers: [],
|
|
110
|
-
})
|
|
111
|
-
let group = computeGroup({
|
|
106
|
+
let selectors = ['literal']
|
|
107
|
+
let group = groupMatcher.computeGroup({
|
|
112
108
|
customGroupMatcher: customGroup =>
|
|
113
109
|
doesCustomGroupMatch({
|
|
114
|
-
selectors: [selector],
|
|
115
110
|
elementName: name,
|
|
116
111
|
modifiers: [],
|
|
117
112
|
customGroup,
|
|
113
|
+
selectors,
|
|
118
114
|
}),
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
modifiers: [],
|
|
116
|
+
selectors,
|
|
121
117
|
})
|
|
122
118
|
let sortingNode = {
|
|
123
119
|
isEslintDisabled: isNodeEslintDisabled(element, eslintDisabledLines),
|
|
@@ -63,6 +63,7 @@ type AdditionalSortOptions = object
|
|
|
63
63
|
* and JSON schema generation.
|
|
64
64
|
*/
|
|
65
65
|
export declare let allSelectors: readonly ['literal']
|
|
66
|
+
export declare let allModifiers: readonly []
|
|
66
67
|
/**
|
|
67
68
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
68
69
|
* rule options at configuration time.
|
|
@@ -4,6 +4,7 @@ import { buildCustomGroupSelectorJsonSchema } from '../../utils/json-schemas/com
|
|
|
4
4
|
* and JSON schema generation.
|
|
5
5
|
*/
|
|
6
6
|
let allSelectors = ['literal']
|
|
7
|
+
let allModifiers = []
|
|
7
8
|
/**
|
|
8
9
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
9
10
|
* rule options at configuration time.
|
|
@@ -11,4 +12,8 @@ let allSelectors = ['literal']
|
|
|
11
12
|
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
12
13
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
13
14
|
}
|
|
14
|
-
export {
|
|
15
|
+
export {
|
|
16
|
+
additionalCustomGroupMatchOptionsJsonSchema,
|
|
17
|
+
allModifiers,
|
|
18
|
+
allSelectors,
|
|
19
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EXTRA_SPACING_ERROR,
|
|
3
|
-
GROUP_ORDER_ERROR,
|
|
4
|
-
MISSED_SPACING_ERROR,
|
|
5
|
-
ORDER_ERROR,
|
|
6
|
-
} from '../utils/report-errors.js'
|
|
7
1
|
import {
|
|
8
2
|
buildCommonJsonSchemas,
|
|
9
3
|
buildUseConfigIfJsonSchema,
|
|
@@ -13,16 +7,18 @@ import {
|
|
|
13
7
|
partitionByCommentJsonSchema,
|
|
14
8
|
partitionByNewlineJsonSchema,
|
|
15
9
|
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
10
|
+
import {
|
|
11
|
+
EXTRA_SPACING_ERROR,
|
|
12
|
+
GROUP_ORDER_ERROR,
|
|
13
|
+
MISSED_SPACING_ERROR,
|
|
14
|
+
ORDER_ERROR,
|
|
15
|
+
} from '../utils/report-errors.js'
|
|
16
16
|
import { buildCommonGroupsJsonSchemas } from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
17
|
+
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
17
18
|
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
18
19
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
19
|
-
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
20
20
|
import { sortArray } from './sort-arrays/sort-array.js'
|
|
21
21
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
22
|
-
/**
|
|
23
|
-
* Cache computed groups by modifiers and selectors for performance.
|
|
24
|
-
*/
|
|
25
|
-
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
26
22
|
const ORDER_ERROR_ID = 'unexpectedArraysOrder'
|
|
27
23
|
const GROUP_ORDER_ERROR_ID = 'unexpectedArraysGroupOrder'
|
|
28
24
|
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArraysMembers'
|
|
@@ -101,7 +97,6 @@ function sorter({ matchedAstSelectors, context, node }) {
|
|
|
101
97
|
unexpectedGroupOrder: GROUP_ORDER_ERROR_ID,
|
|
102
98
|
unexpectedOrder: ORDER_ERROR_ID,
|
|
103
99
|
},
|
|
104
|
-
cachedGroupsByModifiersAndSelectors,
|
|
105
100
|
mustHaveMatchedContextOptions: true,
|
|
106
101
|
matchedAstSelectors,
|
|
107
102
|
defaultOptions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computeDependenciesBySortingNode as computeDependenciesBySortingNode$1 } from '../../utils/compute-dependencies-by-sorting-node.js'
|
|
2
2
|
import { isNodeInsideDeferredFunction } from '../../utils/is-node-inside-deferred-function.js'
|
|
3
|
-
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
4
3
|
import { computeIdentifierNameDetails } from './compute-identifier-name-details.js'
|
|
4
|
+
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
5
5
|
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/types'
|
|
6
6
|
function computeDependenciesBySortingNode({
|
|
7
7
|
ignoreCallbackDependenciesPatterns,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { matches } from '../../utils/matches.js'
|
|
2
1
|
import { computeIdentifierNameDetails } from './compute-identifier-name-details.js'
|
|
3
2
|
import { computeDependencyName } from './compute-dependency-name.js'
|
|
3
|
+
import { matches } from '../../utils/matches.js'
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
5
|
/**
|
|
6
6
|
* Computes the dependencies of a class member AST node.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isContextOptionMatching } from '../../utils/context-matching/is-context-option-matching.js'
|
|
2
1
|
import { computeMethodOrPropertyNameDetails } from './node-info/compute-method-or-property-name-details.js'
|
|
2
|
+
import { isContextOptionMatching } from '../../utils/context-matching/is-context-option-matching.js'
|
|
3
3
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
4
4
|
/**
|
|
5
5
|
* Computes the matched context options for a given class node.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { OverloadSignatureGroup } from '../../utils/overload-signature/overload-signature-group.js'
|
|
1
2
|
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
2
3
|
import { isSortable } from '../../utils/is-sortable.js'
|
|
3
|
-
import { OverloadSignatureGroup } from '../../utils/overload-signature/overload-signature-group.js'
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
5
|
/**
|
|
6
6
|
* Returns a list of groups of overload signatures.
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
computeOverrideModifier,
|
|
6
6
|
computeStaticModifier,
|
|
7
7
|
} from './common-modifiers.js'
|
|
8
|
-
import { computeDependencyName } from '../compute-dependency-name.js'
|
|
9
|
-
import { computeDependencies } from '../compute-dependencies.js'
|
|
10
8
|
import { computeMethodOrPropertyNameDetails } from './compute-method-or-property-name-details.js'
|
|
9
|
+
import { computeDependencyName } from '../compute-dependency-name.js'
|
|
11
10
|
import { isFunctionExpression } from './is-function-expression.js'
|
|
11
|
+
import { computeDependencies } from '../compute-dependencies.js'
|
|
12
12
|
/**
|
|
13
13
|
* Computes details related to an accessor property.
|
|
14
14
|
*
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { UnreachableCaseError } from '../../../utils/unreachable-case-error.js'
|
|
2
1
|
import {
|
|
3
2
|
computeAbstractModifier,
|
|
4
3
|
computeAccessibilityModifier,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
computeStaticModifier,
|
|
10
9
|
} from './common-modifiers.js'
|
|
11
10
|
import { computeMethodOrPropertyNameDetails } from './compute-method-or-property-name-details.js'
|
|
11
|
+
import { UnreachableCaseError } from '../../../utils/unreachable-case-error.js'
|
|
12
12
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
13
13
|
/**
|
|
14
14
|
* Computes details related to a method.
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
computeReadonlyModifier,
|
|
9
9
|
computeStaticModifier,
|
|
10
10
|
} from './common-modifiers.js'
|
|
11
|
-
import { computeDependencyName } from '../compute-dependency-name.js'
|
|
12
|
-
import { computeDependencies } from '../compute-dependencies.js'
|
|
13
11
|
import { computeMethodOrPropertyNameDetails } from './compute-method-or-property-name-details.js'
|
|
12
|
+
import { computeDependencyName } from '../compute-dependency-name.js'
|
|
14
13
|
import { isFunctionExpression } from './is-function-expression.js'
|
|
14
|
+
import { computeDependencies } from '../compute-dependencies.js'
|
|
15
15
|
/**
|
|
16
16
|
* Computes details related to a property.
|
|
17
17
|
*
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
import { populateSortingNodeGroupsWithDependencies } from '../../utils/populate-sorting-node-groups-with-dependencies.js'
|
|
2
|
-
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
3
|
-
import { defaultComparatorByOptionsComputer } from '../../utils/compare/default-comparator-by-options-computer.js'
|
|
4
|
-
import { validateNewlinesAndPartitionConfig } from '../../utils/validate-newlines-and-partition-config.js'
|
|
5
|
-
import { buildOptionsByGroupIndexComputer } from '../../utils/build-options-by-group-index-computer.js'
|
|
6
|
-
import { validateCustomSortConfig } from '../../utils/validate-custom-sort-config.js'
|
|
7
|
-
import { generatePredefinedGroups } from '../../utils/generate-predefined-groups.js'
|
|
8
|
-
import { sortNodesByDependencies } from '../../utils/sort-nodes-by-dependencies.js'
|
|
9
|
-
import { getEslintDisabledLines } from '../../utils/get-eslint-disabled-lines.js'
|
|
10
|
-
import { doesCustomGroupMatch } from '../../utils/does-custom-group-match.js'
|
|
11
|
-
import { isNodeEslintDisabled } from '../../utils/is-node-eslint-disabled.js'
|
|
12
|
-
import { validateGroupsConfig } from '../../utils/validate-groups-config.js'
|
|
13
|
-
import { getNodeDecorators } from '../../utils/get-node-decorators.js'
|
|
14
|
-
import { getGroupIndex } from '../../utils/get-group-index.js'
|
|
15
|
-
import { sortNodesByGroups } from '../../utils/sort-nodes-by-groups.js'
|
|
16
|
-
import { getDecoratorName } from '../../utils/get-decorator-name.js'
|
|
17
|
-
import { reportAllErrors } from '../../utils/report-all-errors.js'
|
|
18
|
-
import { shouldPartition } from '../../utils/should-partition.js'
|
|
19
|
-
import { computeGroup } from '../../utils/compute-group.js'
|
|
20
|
-
import { rangeToDiff } from '../../utils/range-to-diff.js'
|
|
21
|
-
import { getSettings } from '../../utils/get-settings.js'
|
|
22
|
-
import { isSortable } from '../../utils/is-sortable.js'
|
|
23
|
-
import { complete } from '../../utils/complete.js'
|
|
24
1
|
import {
|
|
25
2
|
DEPENDENCY_ORDER_ERROR_ID,
|
|
26
3
|
EXTRA_SPACING_ERROR_ID,
|
|
@@ -32,20 +9,38 @@ import {
|
|
|
32
9
|
} from './types.js'
|
|
33
10
|
import { buildOverloadSignatureNewlinesBetweenValueGetter } from '../../utils/overload-signature/build-overload-signature-newlines-between-value-getter.js'
|
|
34
11
|
import { populateSortingNodeGroupsWithOverloadSignature } from '../../utils/overload-signature/populate-sorting-node-groups-with-overload-signature.js'
|
|
12
|
+
import { populateSortingNodeGroupsWithDependencies } from '../../utils/populate-sorting-node-groups-with-dependencies.js'
|
|
13
|
+
import { defaultComparatorByOptionsComputer } from '../../utils/compare/default-comparator-by-options-computer.js'
|
|
14
|
+
import { validateNewlinesAndPartitionConfig } from '../../utils/validate-newlines-and-partition-config.js'
|
|
15
|
+
import { buildOptionsByGroupIndexComputer } from '../../utils/build-options-by-group-index-computer.js'
|
|
35
16
|
import { computeIndexSignatureDetails } from './node-info/compute-index-signature-details.js'
|
|
36
17
|
import { computeDependenciesBySortingNode } from './compute-dependencies-by-sorting-node.js'
|
|
37
18
|
import { computeStaticBlockDetails } from './node-info/compute-static-block-details.js'
|
|
38
19
|
import { computeOverloadSignatureGroups } from './compute-overload-signature-groups.js'
|
|
20
|
+
import { validateCustomSortConfig } from '../../utils/validate-custom-sort-config.js'
|
|
21
|
+
import { sortNodesByDependencies } from '../../utils/sort-nodes-by-dependencies.js'
|
|
39
22
|
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
23
|
+
import { getEslintDisabledLines } from '../../utils/get-eslint-disabled-lines.js'
|
|
40
24
|
import { computePropertyDetails } from './node-info/compute-property-details.js'
|
|
41
25
|
import { computeAccessorDetails } from './node-info/compute-accessor-details.js'
|
|
26
|
+
import { doesCustomGroupMatch } from '../../utils/does-custom-group-match.js'
|
|
27
|
+
import { isNodeEslintDisabled } from '../../utils/is-node-eslint-disabled.js'
|
|
28
|
+
import { validateGroupsConfig } from '../../utils/validate-groups-config.js'
|
|
42
29
|
import { computeMethodDetails } from './node-info/compute-method-details.js'
|
|
30
|
+
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
31
|
+
import { sortNodesByGroups } from '../../utils/sort-nodes-by-groups.js'
|
|
32
|
+
import { getNodeDecorators } from '../../utils/get-node-decorators.js'
|
|
33
|
+
import { getDecoratorName } from '../../utils/get-decorator-name.js'
|
|
34
|
+
import { reportAllErrors } from '../../utils/report-all-errors.js'
|
|
43
35
|
import { isKnownClassElement } from './is-known-class-element.js'
|
|
36
|
+
import { shouldPartition } from '../../utils/should-partition.js'
|
|
37
|
+
import { getGroupIndex } from '../../utils/get-group-index.js'
|
|
38
|
+
import { GroupMatcher } from '../../utils/group-matcher.js'
|
|
39
|
+
import { rangeToDiff } from '../../utils/range-to-diff.js'
|
|
40
|
+
import { getSettings } from '../../utils/get-settings.js'
|
|
41
|
+
import { isSortable } from '../../utils/is-sortable.js'
|
|
42
|
+
import { complete } from '../../utils/complete.js'
|
|
44
43
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
45
|
-
/**
|
|
46
|
-
* Cache computed groups by modifiers and selectors for performance.
|
|
47
|
-
*/
|
|
48
|
-
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
49
44
|
let defaultOptions = {
|
|
50
45
|
groups: [
|
|
51
46
|
'index-signature',
|
|
@@ -112,6 +107,11 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
112
107
|
})
|
|
113
108
|
validateNewlinesAndPartitionConfig(options)
|
|
114
109
|
let { sourceCode, id } = context
|
|
110
|
+
let groupMatcher = new GroupMatcher({
|
|
111
|
+
allModifiers,
|
|
112
|
+
allSelectors,
|
|
113
|
+
options,
|
|
114
|
+
})
|
|
115
115
|
let eslintDisabledLines = getEslintDisabledLines({
|
|
116
116
|
ruleName: id,
|
|
117
117
|
sourceCode,
|
|
@@ -236,12 +236,7 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
236
236
|
default:
|
|
237
237
|
throw new UnreachableCaseError(member)
|
|
238
238
|
}
|
|
239
|
-
let
|
|
240
|
-
cache: cachedGroupsByModifiersAndSelectors,
|
|
241
|
-
selectors,
|
|
242
|
-
modifiers,
|
|
243
|
-
})
|
|
244
|
-
let group = computeGroup({
|
|
239
|
+
let group = groupMatcher.computeGroup({
|
|
245
240
|
customGroupMatcher: customGroup =>
|
|
246
241
|
doesCustomGroupMatch({
|
|
247
242
|
elementValue: memberValue,
|
|
@@ -251,8 +246,8 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
251
246
|
modifiers,
|
|
252
247
|
selectors,
|
|
253
248
|
}),
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
selectors,
|
|
250
|
+
modifiers,
|
|
256
251
|
})
|
|
257
252
|
let sortingNode = {
|
|
258
253
|
isEslintDisabled: isNodeEslintDisabled(member, eslintDisabledLines),
|
|
@@ -112,32 +112,32 @@ type AdditionalSortOptions = object
|
|
|
112
112
|
* JSON schema generation.
|
|
113
113
|
*/
|
|
114
114
|
export declare let allSelectors: readonly [
|
|
115
|
+
'function-property',
|
|
115
116
|
'accessor-property',
|
|
116
|
-
'
|
|
117
|
+
'property',
|
|
117
118
|
'constructor',
|
|
118
|
-
'static-block',
|
|
119
119
|
'get-method',
|
|
120
120
|
'set-method',
|
|
121
|
-
'function-property',
|
|
122
|
-
'property',
|
|
123
121
|
'method',
|
|
122
|
+
'index-signature',
|
|
123
|
+
'static-block',
|
|
124
124
|
]
|
|
125
125
|
/**
|
|
126
126
|
* Complete list of available class member modifiers. Used for validation and
|
|
127
127
|
* JSON schema generation.
|
|
128
128
|
*/
|
|
129
129
|
export declare let allModifiers: readonly [
|
|
130
|
-
'async',
|
|
131
|
-
'protected',
|
|
132
|
-
'private',
|
|
133
|
-
'public',
|
|
134
130
|
'static',
|
|
131
|
+
'declare',
|
|
135
132
|
'abstract',
|
|
133
|
+
'decorated',
|
|
136
134
|
'override',
|
|
137
135
|
'readonly',
|
|
138
|
-
'
|
|
139
|
-
'
|
|
136
|
+
'protected',
|
|
137
|
+
'private',
|
|
138
|
+
'public',
|
|
140
139
|
'optional',
|
|
140
|
+
'async',
|
|
141
141
|
]
|
|
142
142
|
/**
|
|
143
143
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildRegexJsonSchema } from '../../utils/json-schemas/common-json-schemas.js'
|
|
2
1
|
import {
|
|
3
2
|
buildCustomGroupModifiersJsonSchema,
|
|
4
3
|
buildCustomGroupSelectorJsonSchema,
|
|
5
4
|
} from '../../utils/json-schemas/common-groups-json-schemas.js'
|
|
5
|
+
import { buildRegexJsonSchema } from '../../utils/json-schemas/common-json-schemas.js'
|
|
6
6
|
const ORDER_ERROR_ID = 'unexpectedClassesOrder'
|
|
7
7
|
const GROUP_ORDER_ERROR_ID = 'unexpectedClassesGroupOrder'
|
|
8
8
|
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenClassMembers'
|
|
@@ -13,32 +13,32 @@ const DEPENDENCY_ORDER_ERROR_ID = 'unexpectedClassesDependencyOrder'
|
|
|
13
13
|
* JSON schema generation.
|
|
14
14
|
*/
|
|
15
15
|
let allSelectors = [
|
|
16
|
+
'function-property',
|
|
16
17
|
'accessor-property',
|
|
17
|
-
'
|
|
18
|
+
'property',
|
|
18
19
|
'constructor',
|
|
19
|
-
'static-block',
|
|
20
20
|
'get-method',
|
|
21
21
|
'set-method',
|
|
22
|
-
'function-property',
|
|
23
|
-
'property',
|
|
24
22
|
'method',
|
|
23
|
+
'index-signature',
|
|
24
|
+
'static-block',
|
|
25
25
|
]
|
|
26
26
|
/**
|
|
27
27
|
* Complete list of available class member modifiers. Used for validation and
|
|
28
28
|
* JSON schema generation.
|
|
29
29
|
*/
|
|
30
30
|
let allModifiers = [
|
|
31
|
-
'async',
|
|
32
|
-
'protected',
|
|
33
|
-
'private',
|
|
34
|
-
'public',
|
|
35
31
|
'static',
|
|
32
|
+
'declare',
|
|
36
33
|
'abstract',
|
|
34
|
+
'decorated',
|
|
37
35
|
'override',
|
|
38
36
|
'readonly',
|
|
39
|
-
'
|
|
40
|
-
'
|
|
37
|
+
'protected',
|
|
38
|
+
'private',
|
|
39
|
+
'public',
|
|
41
40
|
'optional',
|
|
41
|
+
'async',
|
|
42
42
|
]
|
|
43
43
|
/**
|
|
44
44
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEPENDENCY_ORDER_ERROR,
|
|
3
|
-
EXTRA_SPACING_ERROR,
|
|
4
|
-
GROUP_ORDER_ERROR,
|
|
5
|
-
MISSED_SPACING_ERROR,
|
|
6
|
-
ORDER_ERROR,
|
|
7
|
-
} from '../utils/report-errors.js'
|
|
8
1
|
import {
|
|
9
2
|
buildCommonJsonSchemas,
|
|
10
3
|
buildRegexJsonSchema,
|
|
@@ -12,6 +5,21 @@ import {
|
|
|
12
5
|
matchesAstSelectorJsonSchema,
|
|
13
6
|
useExperimentalDependencyDetectionJsonSchema,
|
|
14
7
|
} from '../utils/json-schemas/common-json-schemas.js'
|
|
8
|
+
import {
|
|
9
|
+
DEPENDENCY_ORDER_ERROR_ID,
|
|
10
|
+
EXTRA_SPACING_ERROR_ID,
|
|
11
|
+
GROUP_ORDER_ERROR_ID,
|
|
12
|
+
MISSED_SPACING_ERROR_ID,
|
|
13
|
+
ORDER_ERROR_ID,
|
|
14
|
+
additionalCustomGroupMatchOptionsJsonSchema,
|
|
15
|
+
} from './sort-classes/types.js'
|
|
16
|
+
import {
|
|
17
|
+
DEPENDENCY_ORDER_ERROR,
|
|
18
|
+
EXTRA_SPACING_ERROR,
|
|
19
|
+
GROUP_ORDER_ERROR,
|
|
20
|
+
MISSED_SPACING_ERROR,
|
|
21
|
+
ORDER_ERROR,
|
|
22
|
+
} from '../utils/report-errors.js'
|
|
15
23
|
import {
|
|
16
24
|
partitionByCommentJsonSchema,
|
|
17
25
|
partitionByNewlineJsonSchema,
|
|
@@ -20,17 +28,9 @@ import {
|
|
|
20
28
|
buildCommonGroupsJsonSchemas,
|
|
21
29
|
newlinesBetweenJsonSchema,
|
|
22
30
|
} from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
31
|
+
import { defaultOptions, sortClass } from './sort-classes/sort-class.js'
|
|
23
32
|
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
24
33
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
25
|
-
import {
|
|
26
|
-
DEPENDENCY_ORDER_ERROR_ID,
|
|
27
|
-
EXTRA_SPACING_ERROR_ID,
|
|
28
|
-
GROUP_ORDER_ERROR_ID,
|
|
29
|
-
MISSED_SPACING_ERROR_ID,
|
|
30
|
-
ORDER_ERROR_ID,
|
|
31
|
-
additionalCustomGroupMatchOptionsJsonSchema,
|
|
32
|
-
} from './sort-classes/types.js'
|
|
33
|
-
import { defaultOptions, sortClass } from './sort-classes/sort-class.js'
|
|
34
34
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
35
35
|
var sort_classes_default = createEslintRule({
|
|
36
36
|
meta: {
|
|
@@ -2,7 +2,6 @@ import { RuleContext } from '@typescript-eslint/utils/ts-eslint'
|
|
|
2
2
|
import { TSESTree } from '@typescript-eslint/types'
|
|
3
3
|
import { Options } from './types.js'
|
|
4
4
|
export declare function sortConstructorParameters<MessageIds extends string>({
|
|
5
|
-
cachedGroupsByModifiersAndSelectors,
|
|
6
5
|
mustHaveMatchedContextOptions,
|
|
7
6
|
availableMessageIds,
|
|
8
7
|
matchedAstSelectors,
|
|
@@ -17,7 +16,6 @@ export declare function sortConstructorParameters<MessageIds extends string>({
|
|
|
17
16
|
unexpectedGroupOrder: MessageIds
|
|
18
17
|
unexpectedOrder: MessageIds
|
|
19
18
|
}
|
|
20
|
-
cachedGroupsByModifiersAndSelectors: Map<string, string[]>
|
|
21
19
|
context: Readonly<RuleContext<MessageIds, Options>>
|
|
22
20
|
defaultOptions: Required<Options[number]>
|
|
23
21
|
matchedAstSelectors: ReadonlySet<string>
|