eslint-plugin-perfectionist 5.12.1 → 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/index.d.ts +1 -0
- package/dist/index.js +9 -5
- package/dist/package.json.js +1 -1
- package/dist/rules/sort-array-includes.js +6 -11
- package/dist/rules/sort-arrays/sort-array.d.ts +12 -2
- package/dist/rules/sort-arrays/sort-array.js +45 -19
- 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 +6 -11
- 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 +35 -36
- 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 +12 -12
- package/dist/rules/sort-constructor-parameters/compute-matched-context-options.d.ts +25 -0
- package/dist/rules/sort-constructor-parameters/compute-matched-context-options.js +53 -0
- package/dist/rules/sort-constructor-parameters/compute-node-name.d.ts +17 -0
- package/dist/rules/sort-constructor-parameters/compute-node-name.js +38 -0
- package/dist/rules/sort-constructor-parameters/compute-parameter-modifiers.d.ts +18 -0
- package/dist/rules/sort-constructor-parameters/compute-parameter-modifiers.js +59 -0
- package/dist/rules/sort-constructor-parameters/is-constructor-overloaded.d.ts +11 -0
- package/dist/rules/sort-constructor-parameters/is-constructor-overloaded.js +26 -0
- package/dist/rules/sort-constructor-parameters/sort-constructor-parameters.d.ts +24 -0
- package/dist/rules/sort-constructor-parameters/sort-constructor-parameters.js +175 -0
- package/dist/rules/sort-constructor-parameters/types.d.ts +102 -0
- package/dist/rules/sort-constructor-parameters/types.js +36 -0
- package/dist/rules/sort-constructor-parameters.d.ts +26 -0
- package/dist/rules/sort-constructor-parameters.js +117 -0
- 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 +105 -76
- 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 +36 -23
- 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 +10 -10
- package/dist/rules/sort-export-attributes.js +1 -1
- package/dist/rules/sort-exports.js +27 -28
- package/dist/rules/sort-heritage-clauses/sort-heritage-clause.d.ts +8 -0
- package/dist/rules/sort-heritage-clauses/sort-heritage-clause.js +58 -24
- 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/compute-matched-context-options.js +1 -3
- package/dist/rules/sort-import-attributes/compute-node-name.d.ts +1 -4
- package/dist/rules/sort-import-attributes/compute-node-name.js +3 -4
- package/dist/rules/sort-import-attributes/sort-import-or-export-attributes.d.ts +10 -0
- package/dist/rules/sort-import-attributes/sort-import-or-export-attributes.js +46 -12
- 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 +6 -6
- package/dist/rules/sort-imports/comparator-by-options-computer.js +2 -2
- package/dist/rules/sort-imports/compute-common-selectors.js +5 -6
- package/dist/rules/sort-imports/is-side-effect-only-group.js +1 -1
- package/dist/rules/sort-imports/types.d.ts +19 -14
- package/dist/rules/sort-imports/types.js +24 -14
- package/dist/rules/sort-imports/validate-side-effects-config.js +1 -1
- package/dist/rules/sort-imports.js +74 -71
- 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.d.ts +8 -0
- package/dist/rules/sort-jsx-props/sort-jsx-object.js +52 -32
- package/dist/rules/sort-jsx-props/types.js +1 -1
- package/dist/rules/sort-jsx-props.js +10 -10
- package/dist/rules/sort-maps/sort-potential-map.d.ts +8 -0
- package/dist/rules/sort-maps/sort-potential-map.js +59 -23
- 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 +18 -13
- package/dist/rules/sort-modules/types.js +20 -2
- package/dist/rules/sort-modules.js +91 -49
- package/dist/rules/sort-named-exports/sort-named-export.d.ts +8 -0
- package/dist/rules/sort-named-exports/sort-named-export.js +54 -34
- package/dist/rules/sort-named-exports.js +14 -14
- package/dist/rules/sort-named-imports/sort-named-import.d.ts +8 -0
- package/dist/rules/sort-named-imports/sort-named-import.js +54 -34
- 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.d.ts +10 -0
- package/dist/rules/sort-object-types/sort-object-type-elements.js +44 -22
- package/dist/rules/sort-object-types/types.d.ts +7 -2
- package/dist/rules/sort-object-types/types.js +14 -3
- package/dist/rules/sort-object-types.js +16 -18
- package/dist/rules/sort-objects/can-have-property-dependencies.d.ts +11 -0
- package/dist/rules/sort-objects/can-have-property-dependencies.js +54 -0
- 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.d.ts +8 -0
- package/dist/rules/sort-objects/sort-object.js +64 -40
- package/dist/rules/sort-objects/types.d.ts +6 -1
- package/dist/rules/sort-objects/types.js +13 -2
- package/dist/rules/sort-objects.js +14 -16
- package/dist/rules/sort-sets.js +1 -6
- package/dist/rules/sort-switch-case/build-case-block-comparator-by-options-computer.d.ts +26 -0
- package/dist/rules/sort-switch-case/build-case-block-comparator-by-options-computer.js +36 -0
- package/dist/rules/sort-switch-case.js +40 -49
- package/dist/rules/sort-union-or-intersection-types/build-json-schema.js +1 -1
- package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.d.ts +12 -2
- package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.js +45 -18
- 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 +19 -19
- 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 +8 -8
- package/dist/types/common-groups-options.d.ts +29 -28
- package/dist/utils/alphabet.d.ts +13 -0
- package/dist/utils/alphabet.js +16 -0
- package/dist/utils/can-report-errors.d.ts +41 -0
- package/dist/utils/can-report-errors.js +51 -0
- 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 +9 -2
- 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/complete.d.ts +28 -13
- package/dist/utils/complete.js +24 -9
- package/dist/utils/compute-deep-scope-references.d.ts +6 -4
- package/dist/utils/compute-deep-scope-references.js +75 -9
- package/dist/utils/compute-dependencies-by-sorting-node.d.ts +4 -1
- package/dist/utils/compute-dependencies-by-sorting-node.js +13 -6
- 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.d.ts +3 -3
- package/dist/utils/get-eslint-disabled-lines.js +37 -4
- package/dist/utils/get-eslint-disabled-rules.js +26 -2
- package/dist/utils/get-node-range.js +1 -1
- package/dist/utils/get-settings.d.ts +54 -1
- package/dist/utils/get-settings.js +94 -26
- package/dist/utils/group-matcher.d.ts +76 -0
- package/dist/utils/group-matcher.js +202 -0
- package/dist/utils/is-node-eslint-disabled.d.ts +3 -3
- package/dist/utils/is-node-eslint-disabled.js +3 -3
- package/dist/utils/is-partition-comment.js +1 -1
- package/dist/utils/json-schemas/common-groups-json-schemas.d.ts +4 -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/matches-json-schema.d.ts +33 -0
- package/dist/utils/matches-json-schema.js +99 -0
- 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.d.ts +1 -2
- 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/tsconfig/read-closest-ts-config-by-path.js +9 -1
- package/dist/utils/validate-groups-config.js +8 -139
- package/package.json +3 -3
- package/readme.md +29 -25
- 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/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const _default: {
|
|
|
18
18
|
configs: PluginConfigs
|
|
19
19
|
} & ESLint.Plugin
|
|
20
20
|
export default _default
|
|
21
|
+
export type { Options as SortConstructorParametersOptions } from './rules/sort-constructor-parameters/types.js'
|
|
21
22
|
export type { Options as SortVariableDeclarationsOptions } from './rules/sort-variable-declarations/types.js'
|
|
22
23
|
export type { Options as SortIntersectionTypesOptions } from './rules/sort-intersection-types/types.js'
|
|
23
24
|
export type { Options as SortImportAttributesOptions } from './rules/sort-import-attributes/types.js'
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { name, version } from './package.json.js'
|
|
2
|
+
import sort_constructor_parameters_default from './rules/sort-constructor-parameters.js'
|
|
2
3
|
import sort_variable_declarations_default from './rules/sort-variable-declarations.js'
|
|
3
4
|
import sort_intersection_types_default from './rules/sort-intersection-types.js'
|
|
4
5
|
import sort_import_attributes_default from './rules/sort-import-attributes.js'
|
|
@@ -49,6 +50,7 @@ let recommendedRules = {
|
|
|
49
50
|
}
|
|
50
51
|
let rules = {
|
|
51
52
|
...recommendedRules,
|
|
53
|
+
'sort-constructor-parameters': sort_constructor_parameters_default,
|
|
52
54
|
'sort-arrays': sort_arrays_default,
|
|
53
55
|
}
|
|
54
56
|
let plugin = {
|
|
@@ -112,8 +114,10 @@ let configs = {
|
|
|
112
114
|
order: 'asc',
|
|
113
115
|
}),
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
/**
|
|
118
|
+
* The configs register `plugin` under its name, so the default export must be
|
|
119
|
+
* the same object. ESLint compares plugins by reference and throws "Cannot
|
|
120
|
+
* redefine plugin" when a user config registers a copy.
|
|
121
|
+
*/
|
|
122
|
+
plugin.configs = configs
|
|
123
|
+
export { configs, plugin as default, rules }
|
package/dist/package.json.js
CHANGED
|
@@ -3,26 +3,22 @@ import {
|
|
|
3
3
|
buildUseConfigIfJsonSchema,
|
|
4
4
|
matchesAstSelectorJsonSchema,
|
|
5
5
|
} from '../utils/json-schemas/common-json-schemas.js'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
partitionByCommentJsonSchema,
|
|
8
|
+
partitionByNewlineJsonSchema,
|
|
9
|
+
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
7
10
|
import {
|
|
8
11
|
EXTRA_SPACING_ERROR,
|
|
9
12
|
GROUP_ORDER_ERROR,
|
|
10
13
|
MISSED_SPACING_ERROR,
|
|
11
14
|
ORDER_ERROR,
|
|
12
15
|
} from '../utils/report-errors.js'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
partitionByNewlineJsonSchema,
|
|
16
|
-
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
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,
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { RuleContext } from '@typescript-eslint/utils/ts-eslint'
|
|
2
2
|
import { TSESTree } from '@typescript-eslint/types'
|
|
3
3
|
import { Options } from './types.js'
|
|
4
|
+
/**
|
|
5
|
+
* Sorts the elements of an array-like expression.
|
|
6
|
+
*
|
|
7
|
+
* @param params - Parameters.
|
|
8
|
+
* @param params.mustHaveMatchedContextOptions - Whether to skip nodes matching
|
|
9
|
+
* no option.
|
|
10
|
+
* @param params.availableMessageIds - The message IDs to report with.
|
|
11
|
+
* @param params.matchedAstSelectors - The AST selectors the node matched.
|
|
12
|
+
* @param params.defaultOptions - The rule default options.
|
|
13
|
+
* @param params.context - The rule context.
|
|
14
|
+
* @param params.node - Array or `new` expression whose elements are sorted.
|
|
15
|
+
*/
|
|
4
16
|
export declare function sortArray<MessageIds extends string>({
|
|
5
|
-
cachedGroupsByModifiersAndSelectors,
|
|
6
17
|
mustHaveMatchedContextOptions,
|
|
7
18
|
availableMessageIds,
|
|
8
19
|
matchedAstSelectors,
|
|
@@ -16,7 +27,6 @@ export declare function sortArray<MessageIds extends string>({
|
|
|
16
27
|
unexpectedGroupOrder: MessageIds
|
|
17
28
|
unexpectedOrder: MessageIds
|
|
18
29
|
}
|
|
19
|
-
cachedGroupsByModifiersAndSelectors: Map<string, string[]>
|
|
20
30
|
node: TSESTree.ArrayExpression | TSESTree.NewExpression
|
|
21
31
|
context: Readonly<RuleContext<MessageIds, Options>>
|
|
22
32
|
defaultOptions: Required<Options[number]>
|
|
@@ -2,26 +2,37 @@ 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 { allSelectors } from './types.js'
|
|
19
|
-
import { computeNodeName } from './compute-node-name.js'
|
|
20
|
-
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
21
|
-
import { computeArrayElements } from './compute-array-elements.js'
|
|
22
22
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
23
|
+
/**
|
|
24
|
+
* Sorts the elements of an array-like expression.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Parameters.
|
|
27
|
+
* @param params.mustHaveMatchedContextOptions - Whether to skip nodes matching
|
|
28
|
+
* no option.
|
|
29
|
+
* @param params.availableMessageIds - The message IDs to report with.
|
|
30
|
+
* @param params.matchedAstSelectors - The AST selectors the node matched.
|
|
31
|
+
* @param params.defaultOptions - The rule default options.
|
|
32
|
+
* @param params.context - The rule context.
|
|
33
|
+
* @param params.node - Array or `new` expression whose elements are sorted.
|
|
34
|
+
*/
|
|
23
35
|
function sortArray({
|
|
24
|
-
cachedGroupsByModifiersAndSelectors,
|
|
25
36
|
mustHaveMatchedContextOptions,
|
|
26
37
|
availableMessageIds,
|
|
27
38
|
matchedAstSelectors,
|
|
@@ -46,14 +57,34 @@ function sortArray({
|
|
|
46
57
|
if (mustHaveMatchedContextOptions && !matchedContextOptions) {
|
|
47
58
|
return
|
|
48
59
|
}
|
|
49
|
-
let options = complete(
|
|
60
|
+
let options = complete({
|
|
61
|
+
options: matchedContextOptions,
|
|
62
|
+
defaults: defaultOptions,
|
|
63
|
+
settings,
|
|
64
|
+
})
|
|
50
65
|
validateCustomSortConfig(options)
|
|
51
66
|
validateGroupsConfig({
|
|
52
67
|
selectors: allSelectors,
|
|
53
|
-
modifiers:
|
|
68
|
+
modifiers: allModifiers,
|
|
54
69
|
options,
|
|
55
70
|
})
|
|
56
71
|
validateNewlinesAndPartitionConfig(options)
|
|
72
|
+
if (
|
|
73
|
+
!canReportErrors({
|
|
74
|
+
comparatorByOptionsComputer: defaultComparatorByOptionsComputer,
|
|
75
|
+
newlinesBetweenValueGetter: void 0,
|
|
76
|
+
canHaveDependencies: false,
|
|
77
|
+
availableMessageIds,
|
|
78
|
+
options,
|
|
79
|
+
})
|
|
80
|
+
) {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
let groupMatcher = new GroupMatcher({
|
|
84
|
+
allModifiers,
|
|
85
|
+
allSelectors,
|
|
86
|
+
options,
|
|
87
|
+
})
|
|
57
88
|
let eslintDisabledLines = getEslintDisabledLines({
|
|
58
89
|
ruleName: id,
|
|
59
90
|
sourceCode,
|
|
@@ -72,22 +103,17 @@ function sortArray({
|
|
|
72
103
|
node: element,
|
|
73
104
|
sourceCode,
|
|
74
105
|
})
|
|
75
|
-
let
|
|
76
|
-
let
|
|
77
|
-
cache: cachedGroupsByModifiersAndSelectors,
|
|
78
|
-
selectors: [selector],
|
|
79
|
-
modifiers: [],
|
|
80
|
-
})
|
|
81
|
-
let group = computeGroup({
|
|
106
|
+
let selectors = ['literal']
|
|
107
|
+
let group = groupMatcher.computeGroup({
|
|
82
108
|
customGroupMatcher: customGroup =>
|
|
83
109
|
doesCustomGroupMatch({
|
|
84
|
-
selectors: [selector],
|
|
85
110
|
elementName: name,
|
|
86
111
|
modifiers: [],
|
|
87
112
|
customGroup,
|
|
113
|
+
selectors,
|
|
88
114
|
}),
|
|
89
|
-
|
|
90
|
-
|
|
115
|
+
modifiers: [],
|
|
116
|
+
selectors,
|
|
91
117
|
})
|
|
92
118
|
let sortingNode = {
|
|
93
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
|
+
}
|
|
@@ -3,26 +3,22 @@ import {
|
|
|
3
3
|
buildUseConfigIfJsonSchema,
|
|
4
4
|
matchesAstSelectorJsonSchema,
|
|
5
5
|
} from '../utils/json-schemas/common-json-schemas.js'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
partitionByCommentJsonSchema,
|
|
8
|
+
partitionByNewlineJsonSchema,
|
|
9
|
+
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
7
10
|
import {
|
|
8
11
|
EXTRA_SPACING_ERROR,
|
|
9
12
|
GROUP_ORDER_ERROR,
|
|
10
13
|
MISSED_SPACING_ERROR,
|
|
11
14
|
ORDER_ERROR,
|
|
12
15
|
} from '../utils/report-errors.js'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
partitionByNewlineJsonSchema,
|
|
16
|
-
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
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 { getGroupIndex } from '../../utils/get-group-index.js'
|
|
14
|
-
import { sortNodesByGroups } from '../../utils/sort-nodes-by-groups.js'
|
|
15
|
-
import { reportAllErrors } from '../../utils/report-all-errors.js'
|
|
16
|
-
import { shouldPartition } from '../../utils/should-partition.js'
|
|
17
|
-
import { computeGroup } from '../../utils/compute-group.js'
|
|
18
|
-
import { rangeToDiff } from '../../utils/range-to-diff.js'
|
|
19
|
-
import { getSettings } from '../../utils/get-settings.js'
|
|
20
|
-
import { isSortable } from '../../utils/is-sortable.js'
|
|
21
|
-
import { complete } from '../../utils/complete.js'
|
|
22
|
-
import { getNodeDecorators } from '../../utils/get-node-decorators.js'
|
|
23
|
-
import { getDecoratorName } from '../../utils/get-decorator-name.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',
|
|
@@ -99,7 +94,11 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
99
94
|
classElements,
|
|
100
95
|
context,
|
|
101
96
|
})
|
|
102
|
-
let options = complete(
|
|
97
|
+
let options = complete({
|
|
98
|
+
options: matchedContextOptions,
|
|
99
|
+
defaults: defaultOptions,
|
|
100
|
+
settings,
|
|
101
|
+
})
|
|
103
102
|
validateCustomSortConfig(options)
|
|
104
103
|
validateGroupsConfig({
|
|
105
104
|
modifiers: allModifiers,
|
|
@@ -108,6 +107,11 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
108
107
|
})
|
|
109
108
|
validateNewlinesAndPartitionConfig(options)
|
|
110
109
|
let { sourceCode, id } = context
|
|
110
|
+
let groupMatcher = new GroupMatcher({
|
|
111
|
+
allModifiers,
|
|
112
|
+
allSelectors,
|
|
113
|
+
options,
|
|
114
|
+
})
|
|
111
115
|
let eslintDisabledLines = getEslintDisabledLines({
|
|
112
116
|
ruleName: id,
|
|
113
117
|
sourceCode,
|
|
@@ -232,12 +236,7 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
232
236
|
default:
|
|
233
237
|
throw new UnreachableCaseError(member)
|
|
234
238
|
}
|
|
235
|
-
let
|
|
236
|
-
cache: cachedGroupsByModifiersAndSelectors,
|
|
237
|
-
selectors,
|
|
238
|
-
modifiers,
|
|
239
|
-
})
|
|
240
|
-
let group = computeGroup({
|
|
239
|
+
let group = groupMatcher.computeGroup({
|
|
241
240
|
customGroupMatcher: customGroup =>
|
|
242
241
|
doesCustomGroupMatch({
|
|
243
242
|
elementValue: memberValue,
|
|
@@ -247,8 +246,8 @@ function sortClass({ matchedAstSelectors, context, node }) {
|
|
|
247
246
|
modifiers,
|
|
248
247
|
selectors,
|
|
249
248
|
}),
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
selectors,
|
|
250
|
+
modifiers,
|
|
252
251
|
})
|
|
253
252
|
let sortingNode = {
|
|
254
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
|
|
@@ -6,9 +6,13 @@ import {
|
|
|
6
6
|
useExperimentalDependencyDetectionJsonSchema,
|
|
7
7
|
} from '../utils/json-schemas/common-json-schemas.js'
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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'
|
|
12
16
|
import {
|
|
13
17
|
DEPENDENCY_ORDER_ERROR,
|
|
14
18
|
EXTRA_SPACING_ERROR,
|
|
@@ -20,17 +24,13 @@ import {
|
|
|
20
24
|
partitionByCommentJsonSchema,
|
|
21
25
|
partitionByNewlineJsonSchema,
|
|
22
26
|
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
23
|
-
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
24
|
-
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
25
27
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
MISSED_SPACING_ERROR_ID,
|
|
30
|
-
ORDER_ERROR_ID,
|
|
31
|
-
additionalCustomGroupMatchOptionsJsonSchema,
|
|
32
|
-
} from './sort-classes/types.js'
|
|
28
|
+
buildCommonGroupsJsonSchemas,
|
|
29
|
+
newlinesBetweenJsonSchema,
|
|
30
|
+
} from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
33
31
|
import { defaultOptions, sortClass } from './sort-classes/sort-class.js'
|
|
32
|
+
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
33
|
+
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
34
34
|
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
35
35
|
var sort_classes_default = createEslintRule({
|
|
36
36
|
meta: {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RuleContext } from '@typescript-eslint/utils/ts-eslint'
|
|
2
|
+
import { TSESTree } from '@typescript-eslint/types'
|
|
3
|
+
import { Options } from './types.js'
|
|
4
|
+
/**
|
|
5
|
+
* Computes the matched context options for a given constructor node.
|
|
6
|
+
*
|
|
7
|
+
* @param params - Parameters.
|
|
8
|
+
* @param params.matchedAstSelectors - The matched AST selectors for a
|
|
9
|
+
* constructor node.
|
|
10
|
+
* @param params.params - The constructor parameters to compute the context
|
|
11
|
+
* options for.
|
|
12
|
+
* @param params.context - The rule context.
|
|
13
|
+
* @returns The matched context options or undefined if none match.
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeMatchedContextOptions<
|
|
16
|
+
MessageIds extends string,
|
|
17
|
+
>({
|
|
18
|
+
matchedAstSelectors,
|
|
19
|
+
context,
|
|
20
|
+
params,
|
|
21
|
+
}: {
|
|
22
|
+
context: Readonly<RuleContext<MessageIds, Options>>
|
|
23
|
+
matchedAstSelectors: ReadonlySet<string>
|
|
24
|
+
params: TSESTree.Parameter[]
|
|
25
|
+
}): Options[number] | undefined
|