eslint-plugin-perfectionist 5.11.0 → 5.12.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.js +5 -5
- package/dist/package.json.js +2 -2
- package/dist/rules/sort-array-includes.js +8 -8
- package/dist/rules/sort-arrays/compute-array-elements.js +1 -1
- package/dist/rules/sort-arrays/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-arrays/compute-node-name.js +1 -1
- package/dist/rules/sort-arrays/sort-array.js +1 -1
- package/dist/rules/sort-arrays/types.js +2 -2
- package/dist/rules/sort-arrays.js +8 -8
- package/dist/rules/sort-classes/compute-dependencies-by-sorting-node.js +2 -2
- package/dist/rules/sort-classes/compute-dependencies.js +1 -1
- package/dist/rules/sort-classes/compute-identifier-name-details.js +1 -1
- package/dist/rules/sort-classes/compute-matched-context-options.js +2 -18
- package/dist/rules/sort-classes/compute-overload-signature-groups.js +1 -1
- package/dist/rules/sort-classes/is-known-class-element.js +1 -1
- package/dist/rules/sort-classes/node-info/common-modifiers.js +1 -1
- package/dist/rules/sort-classes/node-info/compute-method-details.js +1 -1
- package/dist/rules/sort-classes/node-info/compute-method-or-property-name-details.js +1 -1
- package/dist/rules/sort-classes/node-info/is-function-expression.js +1 -1
- package/dist/rules/sort-classes/sort-class.js +5 -5
- package/dist/rules/sort-classes/types.js +8 -8
- package/dist/rules/sort-classes.js +1 -1
- package/dist/rules/sort-decorators.js +6 -6
- package/dist/rules/sort-enums/build-comparator-by-options-computer.js +7 -27
- package/dist/rules/sort-enums/compute-dependencies-by-sorting-node.js +1 -1
- package/dist/rules/sort-enums/compute-dependencies.js +1 -1
- package/dist/rules/sort-enums/compute-expression-number-value.js +1 -1
- package/dist/rules/sort-enums/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-enums/compute-node-name.js +1 -1
- package/dist/rules/sort-enums/sort-enum.js +2 -2
- package/dist/rules/sort-enums/types.js +6 -6
- package/dist/rules/sort-enums.js +1 -1
- package/dist/rules/sort-export-attributes.js +6 -6
- package/dist/rules/sort-exports/types.js +3 -3
- package/dist/rules/sort-exports.js +9 -9
- package/dist/rules/sort-heritage-clauses/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-heritage-clauses/compute-node-name.js +1 -1
- package/dist/rules/sort-heritage-clauses/sort-heritage-clause.js +2 -2
- package/dist/rules/sort-heritage-clauses/types.js +4 -4
- package/dist/rules/sort-heritage-clauses.js +1 -1
- package/dist/rules/sort-import-attributes/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-import-attributes/compute-node-name.js +1 -1
- package/dist/rules/sort-import-attributes.js +7 -7
- package/dist/rules/sort-imports/comparator-by-options-computer.js +7 -38
- package/dist/rules/sort-imports/compute-common-selectors.js +22 -21
- package/dist/rules/sort-imports/compute-dependencies.js +1 -1
- package/dist/rules/sort-imports/compute-dependency-names.js +1 -1
- package/dist/rules/sort-imports/compute-node-name.js +1 -1
- package/dist/rules/sort-imports/compute-specifier-modifiers.js +1 -1
- package/dist/rules/sort-imports/compute-specifier-name.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/matches-tsconfig-paths.js +1 -1
- package/dist/rules/sort-imports/types.js +5 -5
- package/dist/rules/sort-imports.js +10 -10
- package/dist/rules/sort-interfaces.js +5 -5
- package/dist/rules/sort-intersection-types.js +7 -7
- package/dist/rules/sort-jsx-props/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-jsx-props/compute-node-name.js +1 -1
- package/dist/rules/sort-jsx-props/sort-jsx-object.js +3 -3
- package/dist/rules/sort-jsx-props/types.js +7 -7
- package/dist/rules/sort-jsx-props.js +1 -1
- package/dist/rules/sort-maps/compute-matched-context-options.js +2 -18
- package/dist/rules/sort-maps/compute-node-name.js +1 -1
- package/dist/rules/sort-maps/sort-potential-map.js +2 -2
- package/dist/rules/sort-maps/types.js +4 -4
- package/dist/rules/sort-maps.js +1 -1
- package/dist/rules/sort-modules/compute-additional-module-statements.js +1 -1
- package/dist/rules/sort-modules/compute-dependencies.js +1 -1
- package/dist/rules/sort-modules/compute-node-details.js +1 -1
- package/dist/rules/sort-modules/compute-overload-signature-groups.js +1 -1
- package/dist/rules/sort-modules/dependencies/compute-dependencies-by-sorting-node.js +2 -2
- package/dist/rules/sort-modules/dependencies/is-identifier-in-decorator-metadata-type-position.js +2 -2
- 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.js +4 -4
- package/dist/rules/sort-modules.js +12 -10
- package/dist/rules/sort-named-exports/compute-node-name.js +1 -1
- package/dist/rules/sort-named-exports/sort-named-export.js +2 -2
- package/dist/rules/sort-named-exports/types.js +7 -7
- package/dist/rules/sort-named-exports.js +1 -1
- package/dist/rules/sort-named-imports/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-named-imports/compute-node-name.js +1 -1
- package/dist/rules/sort-named-imports/sort-named-import.js +3 -3
- package/dist/rules/sort-named-imports/types.js +7 -7
- package/dist/rules/sort-named-imports.js +1 -1
- package/dist/rules/sort-object-types/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-object-types/compute-node-name.js +1 -1
- package/dist/rules/sort-object-types/compute-node-parent-name.js +1 -1
- package/dist/rules/sort-object-types/is-member-optional.js +1 -1
- package/dist/rules/sort-object-types/is-node-function-type.js +1 -1
- package/dist/rules/sort-object-types/passes-declaration-comment-matches-filter.js +1 -1
- package/dist/rules/sort-object-types/sort-object-type-elements.js +4 -4
- package/dist/rules/sort-object-types/types.js +6 -6
- package/dist/rules/sort-object-types.js +7 -7
- package/dist/rules/sort-objects/compute-dependencies.js +1 -1
- package/dist/rules/sort-objects/compute-dependency-names.js +1 -1
- package/dist/rules/sort-objects/compute-matched-context-options.js +2 -2
- package/dist/rules/sort-objects/compute-node-value.js +1 -1
- package/dist/rules/sort-objects/compute-property-or-variable-declarator-name.js +1 -1
- package/dist/rules/sort-objects/is-style-component.js +1 -1
- package/dist/rules/sort-objects/passes-calling-function-name-pattern-filter.js +1 -1
- package/dist/rules/sort-objects/passes-declaration-comment-matches-filter.js +1 -1
- package/dist/rules/sort-objects/passes-declaration-matches-pattern-filter.js +2 -2
- package/dist/rules/sort-objects/sort-object.js +5 -5
- package/dist/rules/sort-objects/types.js +11 -11
- package/dist/rules/sort-objects.js +1 -1
- package/dist/rules/sort-sets.js +6 -6
- package/dist/rules/sort-switch-case/is-condition-expression.js +1 -1
- package/dist/rules/sort-switch-case.js +17 -12
- package/dist/rules/sort-union-or-intersection-types/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-union-or-intersection-types/compute-node-name.js +1 -1
- package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.js +1 -1
- package/dist/rules/sort-union-or-intersection-types/type-contains-callable-type.js +1 -1
- package/dist/rules/sort-union-types/types.js +2 -2
- package/dist/rules/sort-union-types.js +7 -7
- package/dist/rules/sort-variable-declarations/compute-dependencies.js +1 -1
- package/dist/rules/sort-variable-declarations/compute-matched-context-options.js +1 -17
- package/dist/rules/sort-variable-declarations/compute-node-name.js +1 -1
- package/dist/rules/sort-variable-declarations/sort-variable-declaration.js +2 -2
- package/dist/rules/sort-variable-declarations/types.js +9 -7
- package/dist/rules/sort-variable-declarations.js +1 -1
- package/dist/types/common-options.d.ts +3 -4
- package/dist/types/scoped-regex-option.js +1 -1
- package/dist/utils/compare/compare-by-custom-sort.js +1 -1
- package/dist/utils/compare/default-comparator-by-options-computer.d.ts +13 -0
- package/dist/utils/compare/default-comparator-by-options-computer.js +44 -23
- package/dist/utils/compare/name-or-value-comparator-by-options-computer.d.ts +23 -0
- package/dist/utils/compare/name-or-value-comparator-by-options-computer.js +27 -0
- package/dist/utils/compare/unsorted-comparator.js +1 -1
- package/dist/utils/context-matching/is-context-option-matching.d.ts +30 -0
- package/dist/utils/context-matching/is-context-option-matching.js +33 -0
- package/dist/utils/create-eslint-rule.d.ts +1 -1
- package/dist/utils/create-eslint-rule.js +2 -2
- package/dist/utils/create-fix-provider.d.ts +83 -0
- package/dist/utils/create-fix-provider.js +72 -0
- package/dist/utils/does-node-end-with-expression.d.ts +29 -0
- package/dist/utils/does-node-end-with-expression.js +40 -0
- package/dist/utils/get-eslint-disabled-rules.d.ts +13 -2
- package/dist/utils/get-eslint-disabled-rules.js +62 -14
- package/dist/utils/get-node-range.js +2 -2
- package/dist/utils/is-expression-continuation-token.d.ts +15 -0
- package/dist/utils/is-expression-continuation-token.js +29 -0
- package/dist/utils/is-node-immediately-called.js +1 -1
- package/dist/utils/is-node-inside-deferred-function.js +2 -2
- package/dist/utils/is-partition-comment.js +1 -1
- package/dist/utils/json-schemas/common-groups-json-schemas.js +2 -2
- package/dist/utils/json-schemas/common-json-schemas.js +7 -7
- package/dist/utils/json-schemas/common-partition-json-schemas.js +3 -3
- package/dist/utils/json-schemas/scoped-regex-json-schema.js +1 -1
- package/dist/utils/json-schemas/tsconfig-json-schema.js +1 -1
- package/dist/utils/make-fixes.d.ts +1 -2
- package/dist/utils/make-newlines-between-fixes.js +1 -1
- package/dist/utils/make-order-fixes.js +12 -2
- package/dist/utils/merge-fixes.d.ts +75 -0
- package/dist/utils/merge-fixes.js +80 -0
- package/dist/utils/report-all-errors.d.ts +2 -2
- package/dist/utils/report-all-errors.js +22 -12
- package/dist/utils/report-errors.d.ts +3 -16
- package/dist/utils/report-errors.js +14 -26
- package/dist/utils/should-partition.js +1 -1
- package/dist/utils/sort-nodes-by-dependencies.d.ts +2 -2
- package/dist/utils/sort-nodes-by-dependencies.js +2 -2
- package/dist/utils/tsconfig/get-typescript-import.js +3 -3
- package/dist/utils/tsconfig/read-closest-ts-config-by-path.js +3 -3
- package/dist/utils/unreachable-case-error.d.ts +1 -1
- package/dist/utils/unreachable-case-error.js +1 -1
- package/dist/utils/validate-newlines-and-partition-config.js +2 -2
- package/package.json +3 -2
- package/readme.md +2 -2
- package/dist/rules/sort-object-types/comparator-by-options-computer.d.ts +0 -6
- package/dist/rules/sort-object-types/comparator-by-options-computer.js +0 -39
- package/dist/rules/sort-objects/comparator-by-options-computer.d.ts +0 -6
- package/dist/rules/sort-objects/comparator-by-options-computer.js +0 -39
package/dist/index.js
CHANGED
|
@@ -22,8 +22,8 @@ import sort_arrays_default from './rules/sort-arrays.js'
|
|
|
22
22
|
import sort_enums_default from './rules/sort-enums.js'
|
|
23
23
|
import sort_maps_default from './rules/sort-maps.js'
|
|
24
24
|
import sort_sets_default from './rules/sort-sets.js'
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let pluginName = 'perfectionist'
|
|
26
|
+
let recommendedRules = {
|
|
27
27
|
'sort-variable-declarations': sort_variable_declarations_default,
|
|
28
28
|
'sort-intersection-types': sort_intersection_types_default,
|
|
29
29
|
'sort-import-attributes': sort_import_attributes_default,
|
|
@@ -47,11 +47,11 @@ var recommendedRules = {
|
|
|
47
47
|
'sort-sets': sort_sets_default,
|
|
48
48
|
'sort-maps': sort_maps_default,
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
let rules = {
|
|
51
51
|
...recommendedRules,
|
|
52
52
|
'sort-arrays': sort_arrays_default,
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
let plugin = {
|
|
55
55
|
meta: {
|
|
56
56
|
version,
|
|
57
57
|
name,
|
|
@@ -78,7 +78,7 @@ function createLegacyConfig(options) {
|
|
|
78
78
|
plugins: [pluginName],
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
let configs = {
|
|
82
82
|
'recommended-alphabetical-legacy': createLegacyConfig({
|
|
83
83
|
type: 'alphabetical',
|
|
84
84
|
order: 'asc',
|
package/dist/package.json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const name = 'eslint-plugin-perfectionist'
|
|
2
|
+
const version = '5.12.0'
|
|
3
3
|
export { name, version }
|
|
@@ -18,16 +18,16 @@ import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
|
18
18
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
19
19
|
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
20
20
|
import { sortArray } from './sort-arrays/sort-array.js'
|
|
21
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
21
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
22
22
|
/**
|
|
23
23
|
* Cache computed groups by modifiers and selectors for performance.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
26
|
+
const ORDER_ERROR_ID = 'unexpectedArrayIncludesOrder'
|
|
27
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedArrayIncludesGroupOrder'
|
|
28
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArrayIncludesMembers'
|
|
29
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenArrayIncludesMembers'
|
|
30
|
+
let defaultOptions = {
|
|
31
31
|
fallbackSort: { type: 'unsorted' },
|
|
32
32
|
newlinesInside: 'newlinesBetween',
|
|
33
33
|
specialCharacters: 'keep',
|
|
@@ -43,7 +43,7 @@ var defaultOptions = {
|
|
|
43
43
|
alphabet: '',
|
|
44
44
|
order: 'asc',
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
let jsonSchema = {
|
|
47
47
|
items: {
|
|
48
48
|
properties: {
|
|
49
49
|
...buildCommonJsonSchemas(),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { passesAstSelectorFilter } from '../../utils/context-matching/passes-ast-selector-filter.js'
|
|
1
|
+
import { isContextOptionMatching } from '../../utils/context-matching/is-context-option-matching.js'
|
|
3
2
|
import { computeNodeName } from './compute-node-name.js'
|
|
4
3
|
/**
|
|
5
4
|
* Computes the matched context options for a given array node.
|
|
@@ -33,19 +32,4 @@ function computeMatchedContextOptions({
|
|
|
33
32
|
}),
|
|
34
33
|
)
|
|
35
34
|
}
|
|
36
|
-
function isContextOptionMatching({ matchedAstSelectors, nodeNames, options }) {
|
|
37
|
-
if (!options.useConfigurationIf) {
|
|
38
|
-
return true
|
|
39
|
-
}
|
|
40
|
-
return (
|
|
41
|
-
passesAllNamesMatchPatternFilter({
|
|
42
|
-
allNamesMatchPattern: options.useConfigurationIf.allNamesMatchPattern,
|
|
43
|
-
nodeNames,
|
|
44
|
-
}) &&
|
|
45
|
-
passesAstSelectorFilter({
|
|
46
|
-
matchesAstSelector: options.useConfigurationIf.matchesAstSelector,
|
|
47
|
-
matchedAstSelectors,
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
35
|
export { computeMatchedContextOptions }
|
|
@@ -19,7 +19,7 @@ import { allSelectors } from './types.js'
|
|
|
19
19
|
import { computeNodeName } from './compute-node-name.js'
|
|
20
20
|
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
21
21
|
import { computeArrayElements } from './compute-array-elements.js'
|
|
22
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
22
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
23
23
|
function sortArray({
|
|
24
24
|
cachedGroupsByModifiersAndSelectors,
|
|
25
25
|
mustHaveMatchedContextOptions,
|
|
@@ -3,12 +3,12 @@ import { buildCustomGroupSelectorJsonSchema } from '../../utils/json-schemas/com
|
|
|
3
3
|
* Complete list of available selectors for array elements. Used for validation
|
|
4
4
|
* and JSON schema generation.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
let allSelectors = ['literal']
|
|
7
7
|
/**
|
|
8
8
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
9
9
|
* rule options at configuration time.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
12
12
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
13
13
|
}
|
|
14
14
|
export { additionalCustomGroupMatchOptionsJsonSchema, allSelectors }
|
|
@@ -18,16 +18,16 @@ import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
|
18
18
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
19
19
|
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
20
20
|
import { sortArray } from './sort-arrays/sort-array.js'
|
|
21
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
21
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
22
22
|
/**
|
|
23
23
|
* Cache computed groups by modifiers and selectors for performance.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
26
|
+
const ORDER_ERROR_ID = 'unexpectedArraysOrder'
|
|
27
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedArraysGroupOrder'
|
|
28
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArraysMembers'
|
|
29
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenArraysMembers'
|
|
30
|
+
let defaultOptions = {
|
|
31
31
|
fallbackSort: { type: 'unsorted' },
|
|
32
32
|
newlinesInside: 'newlinesBetween',
|
|
33
33
|
specialCharacters: 'keep',
|
|
@@ -43,7 +43,7 @@ var defaultOptions = {
|
|
|
43
43
|
alphabet: '',
|
|
44
44
|
order: 'asc',
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
let jsonSchema = {
|
|
47
47
|
items: {
|
|
48
48
|
properties: {
|
|
49
49
|
...buildCommonJsonSchemas(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
2
1
|
import { computeDependenciesBySortingNode as computeDependenciesBySortingNode$1 } from '../../utils/compute-dependencies-by-sorting-node.js'
|
|
3
2
|
import { isNodeInsideDeferredFunction } from '../../utils/is-node-inside-deferred-function.js'
|
|
3
|
+
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
4
4
|
import { computeIdentifierNameDetails } from './compute-identifier-name-details.js'
|
|
5
|
-
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/
|
|
5
|
+
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/types'
|
|
6
6
|
function computeDependenciesBySortingNode({
|
|
7
7
|
ignoreCallbackDependenciesPatterns,
|
|
8
8
|
sortingNodes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { matches } from '../../utils/matches.js'
|
|
2
2
|
import { computeIdentifierNameDetails } from './compute-identifier-name-details.js'
|
|
3
3
|
import { computeDependencyName } from './compute-dependency-name.js'
|
|
4
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
4
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
5
|
/**
|
|
6
6
|
* Computes the dependencies of a class member AST node.
|
|
7
7
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { passesAstSelectorFilter } from '../../utils/context-matching/passes-ast-selector-filter.js'
|
|
1
|
+
import { isContextOptionMatching } from '../../utils/context-matching/is-context-option-matching.js'
|
|
3
2
|
import { computeMethodOrPropertyNameDetails } from './node-info/compute-method-or-property-name-details.js'
|
|
4
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
3
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
4
|
/**
|
|
6
5
|
* Computes the matched context options for a given class node.
|
|
7
6
|
*
|
|
@@ -34,19 +33,4 @@ function computeMatchedContextOptions({
|
|
|
34
33
|
}),
|
|
35
34
|
)
|
|
36
35
|
}
|
|
37
|
-
function isContextOptionMatching({ matchedAstSelectors, nodeNames, options }) {
|
|
38
|
-
if (!options.useConfigurationIf) {
|
|
39
|
-
return true
|
|
40
|
-
}
|
|
41
|
-
return (
|
|
42
|
-
passesAllNamesMatchPatternFilter({
|
|
43
|
-
allNamesMatchPattern: options.useConfigurationIf.allNamesMatchPattern,
|
|
44
|
-
nodeNames,
|
|
45
|
-
}) &&
|
|
46
|
-
passesAstSelectorFilter({
|
|
47
|
-
matchesAstSelector: options.useConfigurationIf.matchesAstSelector,
|
|
48
|
-
matchedAstSelectors,
|
|
49
|
-
})
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
36
|
export { computeMatchedContextOptions }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
2
2
|
import { isSortable } from '../../utils/is-sortable.js'
|
|
3
3
|
import { OverloadSignatureGroup } from '../../utils/overload-signature/overload-signature-group.js'
|
|
4
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
4
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
5
|
/**
|
|
6
6
|
* Returns a list of groups of overload signatures.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnreachableCaseError } from '../../../utils/unreachable-case-error.js'
|
|
2
2
|
import '../../../utils/assert-is-never.js'
|
|
3
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
3
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
4
4
|
function computeAccessibilityModifier({ hasPrivateHash, node }) {
|
|
5
5
|
if (hasPrivateHash) {
|
|
6
6
|
return ['private']
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
computeStaticModifier,
|
|
10
10
|
} from './common-modifiers.js'
|
|
11
11
|
import { computeMethodOrPropertyNameDetails } from './compute-method-or-property-name-details.js'
|
|
12
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
12
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
13
13
|
/**
|
|
14
14
|
* Computes details related to a method.
|
|
15
15
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeIdentifierNameDetails } from '../compute-identifier-name-details.js'
|
|
2
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
2
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
3
3
|
/**
|
|
4
4
|
* Computes the name details of a method or property node.
|
|
5
5
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
2
|
-
import { getGroupIndex } from '../../utils/get-group-index.js'
|
|
3
1
|
import { populateSortingNodeGroupsWithDependencies } from '../../utils/populate-sorting-node-groups-with-dependencies.js'
|
|
2
|
+
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
4
3
|
import { defaultComparatorByOptionsComputer } from '../../utils/compare/default-comparator-by-options-computer.js'
|
|
5
4
|
import { validateNewlinesAndPartitionConfig } from '../../utils/validate-newlines-and-partition-config.js'
|
|
6
5
|
import { buildOptionsByGroupIndexComputer } from '../../utils/build-options-by-group-index-computer.js'
|
|
@@ -11,6 +10,7 @@ import { getEslintDisabledLines } from '../../utils/get-eslint-disabled-lines.js
|
|
|
11
10
|
import { doesCustomGroupMatch } from '../../utils/does-custom-group-match.js'
|
|
12
11
|
import { isNodeEslintDisabled } from '../../utils/is-node-eslint-disabled.js'
|
|
13
12
|
import { validateGroupsConfig } from '../../utils/validate-groups-config.js'
|
|
13
|
+
import { getGroupIndex } from '../../utils/get-group-index.js'
|
|
14
14
|
import { sortNodesByGroups } from '../../utils/sort-nodes-by-groups.js'
|
|
15
15
|
import { reportAllErrors } from '../../utils/report-all-errors.js'
|
|
16
16
|
import { shouldPartition } from '../../utils/should-partition.js'
|
|
@@ -41,12 +41,12 @@ import { computePropertyDetails } from './node-info/compute-property-details.js'
|
|
|
41
41
|
import { computeAccessorDetails } from './node-info/compute-accessor-details.js'
|
|
42
42
|
import { computeMethodDetails } from './node-info/compute-method-details.js'
|
|
43
43
|
import { isKnownClassElement } from './is-known-class-element.js'
|
|
44
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
44
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
45
45
|
/**
|
|
46
46
|
* Cache computed groups by modifiers and selectors for performance.
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
49
|
+
let defaultOptions = {
|
|
50
50
|
groups: [
|
|
51
51
|
'index-signature',
|
|
52
52
|
['static-property', 'static-accessor-property'],
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
buildCustomGroupModifiersJsonSchema,
|
|
4
4
|
buildCustomGroupSelectorJsonSchema,
|
|
5
5
|
} from '../../utils/json-schemas/common-groups-json-schemas.js'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const ORDER_ERROR_ID = 'unexpectedClassesOrder'
|
|
7
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedClassesGroupOrder'
|
|
8
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenClassMembers'
|
|
9
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenClassMembers'
|
|
10
|
+
const DEPENDENCY_ORDER_ERROR_ID = 'unexpectedClassesDependencyOrder'
|
|
11
11
|
/**
|
|
12
12
|
* Complete list of available class member selectors. Used for validation and
|
|
13
13
|
* JSON schema generation.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
let allSelectors = [
|
|
16
16
|
'accessor-property',
|
|
17
17
|
'index-signature',
|
|
18
18
|
'constructor',
|
|
@@ -27,7 +27,7 @@ var allSelectors = [
|
|
|
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
31
|
'async',
|
|
32
32
|
'protected',
|
|
33
33
|
'private',
|
|
@@ -47,7 +47,7 @@ var allModifiers = [
|
|
|
47
47
|
* Note: Ideally, we should generate as many schemas as there are selectors, and
|
|
48
48
|
* ensure that users do not enter invalid modifiers for a given selector.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
51
51
|
modifiers: buildCustomGroupModifiersJsonSchema(allModifiers),
|
|
52
52
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
53
53
|
decoratorNamePattern: buildRegexJsonSchema(),
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
additionalCustomGroupMatchOptionsJsonSchema,
|
|
32
32
|
} from './sort-classes/types.js'
|
|
33
33
|
import { defaultOptions, sortClass } from './sort-classes/sort-class.js'
|
|
34
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
34
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
35
35
|
var sort_classes_default = createEslintRule({
|
|
36
36
|
meta: {
|
|
37
37
|
schema: {
|
|
@@ -29,12 +29,12 @@ import { complete } from '../utils/complete.js'
|
|
|
29
29
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
30
30
|
import { getNodeDecorators } from '../utils/get-node-decorators.js'
|
|
31
31
|
import { getDecoratorName } from '../utils/get-decorator-name.js'
|
|
32
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
33
|
+
const ORDER_ERROR_ID = 'unexpectedDecoratorsOrder'
|
|
34
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedDecoratorsGroupOrder'
|
|
35
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenDecorators'
|
|
36
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenDecorators'
|
|
37
|
+
let defaultOptions = {
|
|
38
38
|
fallbackSort: { type: 'unsorted' },
|
|
39
39
|
newlinesInside: 'newlinesBetween',
|
|
40
40
|
specialCharacters: 'keep',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
|
|
2
|
-
import { buildLineLengthComparator } from '../../utils/compare/build-line-length-comparator.js'
|
|
3
|
-
import { compareAlphabetically } from '../../utils/compare/compare-alphabetically.js'
|
|
4
|
-
import { compareByCustomSort } from '../../utils/compare/compare-by-custom-sort.js'
|
|
5
2
|
import { unsortedComparator } from '../../utils/compare/unsorted-comparator.js'
|
|
6
3
|
import { compareNaturally } from '../../utils/compare/compare-naturally.js'
|
|
7
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
buildStringComparatorByOptionsComputer,
|
|
6
|
+
defaultComparatorByOptionsComputer,
|
|
7
|
+
} from '../../utils/compare/default-comparator-by-options-computer.js'
|
|
8
8
|
/**
|
|
9
9
|
* Builds a comparator computer function for sorting enum members.
|
|
10
10
|
*
|
|
@@ -37,29 +37,9 @@ function buildComparatorByOptionsComputer(isNumericEnum) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
case 'subgroup-order':
|
|
44
|
-
return defaultComparatorByOptionsComputer(options)
|
|
45
|
-
case 'alphabetical':
|
|
46
|
-
return (a, b) =>
|
|
47
|
-
compareAlphabetically(a.value ?? '', b.value ?? '', options)
|
|
48
|
-
case 'line-length':
|
|
49
|
-
return buildLineLengthComparator(options)
|
|
50
|
-
case 'unsorted':
|
|
51
|
-
return unsortedComparator
|
|
52
|
-
case 'natural':
|
|
53
|
-
return (a, b) => compareNaturally(a.value ?? '', b.value ?? '', options)
|
|
54
|
-
case 'custom':
|
|
55
|
-
return (a, b) =>
|
|
56
|
-
compareByCustomSort(a.value ?? '', b.value ?? '', options)
|
|
57
|
-
/* v8 ignore next 2 -- @preserve Exhaustive guard. */
|
|
58
|
-
default:
|
|
59
|
-
throw new UnreachableCaseError(options.type)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
var byNumericValueComparatorComputer = options => {
|
|
40
|
+
let byNonNumericValueComparatorComputer =
|
|
41
|
+
buildStringComparatorByOptionsComputer(node => node.value ?? '')
|
|
42
|
+
let byNumericValueComparatorComputer = options => {
|
|
63
43
|
switch (options.type) {
|
|
64
44
|
/* v8 ignore next 2 -- @preserve Untested for now as not a relevant sort for this rule. */
|
|
65
45
|
case 'subgroup-order':
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computeDependenciesBySortingNode as computeDependenciesBySortingNode$1 } from '../../utils/compute-dependencies-by-sorting-node.js'
|
|
2
2
|
import { computeParentNodesWithTypes } from '../../utils/compute-parent-nodes-with-types.js'
|
|
3
3
|
import { doesSortingNodeHaveOneOfDependencyNames } from '../../utils/does-sorting-node-have-one-of-dependency-names.js'
|
|
4
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
4
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
5
5
|
function computeDependenciesBySortingNode({
|
|
6
6
|
sortingNodes,
|
|
7
7
|
sourceCode,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { passesAstSelectorFilter } from '../../utils/context-matching/passes-ast-selector-filter.js'
|
|
1
|
+
import { isContextOptionMatching } from '../../utils/context-matching/is-context-option-matching.js'
|
|
3
2
|
import { computeNodeName } from './compute-node-name.js'
|
|
4
3
|
/**
|
|
5
4
|
* Computes the matched context options for a given enum node.
|
|
@@ -30,19 +29,4 @@ function computeMatchedContextOptions({
|
|
|
30
29
|
}),
|
|
31
30
|
)
|
|
32
31
|
}
|
|
33
|
-
function isContextOptionMatching({ matchedAstSelectors, nodeNames, options }) {
|
|
34
|
-
if (!options.useConfigurationIf) {
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
return (
|
|
38
|
-
passesAllNamesMatchPatternFilter({
|
|
39
|
-
allNamesMatchPattern: options.useConfigurationIf.allNamesMatchPattern,
|
|
40
|
-
nodeNames,
|
|
41
|
-
}) &&
|
|
42
|
-
passesAstSelectorFilter({
|
|
43
|
-
matchesAstSelector: options.useConfigurationIf.matchesAstSelector,
|
|
44
|
-
matchedAstSelectors,
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
32
|
export { computeMatchedContextOptions }
|
|
@@ -29,8 +29,8 @@ import { computeExpressionNumberValue } from './compute-expression-number-value.
|
|
|
29
29
|
import { computeNodeName } from './compute-node-name.js'
|
|
30
30
|
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
31
31
|
import { computeDependencies } from './compute-dependencies.js'
|
|
32
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
33
|
-
|
|
32
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
33
|
+
let defaultOptions = {
|
|
34
34
|
useExperimentalDependencyDetection: true,
|
|
35
35
|
fallbackSort: { type: 'unsorted' },
|
|
36
36
|
newlinesInside: 'newlinesBetween',
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { buildRegexJsonSchema } from '../../utils/json-schemas/common-json-schemas.js'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const ORDER_ERROR_ID = 'unexpectedEnumsOrder'
|
|
3
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedEnumsGroupOrder'
|
|
4
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenEnumsMembers'
|
|
5
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenEnumsMembers'
|
|
6
|
+
const DEPENDENCY_ORDER_ERROR_ID = 'unexpectedEnumsDependencyOrder'
|
|
7
7
|
/**
|
|
8
8
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
9
9
|
* rule options at configuration time.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
12
12
|
elementValuePattern: buildRegexJsonSchema(),
|
|
13
13
|
}
|
|
14
14
|
export {
|
package/dist/rules/sort-enums.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
additionalCustomGroupMatchOptionsJsonSchema,
|
|
28
28
|
} from './sort-enums/types.js'
|
|
29
29
|
import { defaultOptions, sortEnum } from './sort-enums/sort-enum.js'
|
|
30
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
30
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
31
31
|
var sort_enums_default = createEslintRule({
|
|
32
32
|
meta: {
|
|
33
33
|
schema: {
|
|
@@ -8,12 +8,12 @@ import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
|
8
8
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
9
9
|
import { sortImportOrExportAttributes } from './sort-import-attributes/sort-import-or-export-attributes.js'
|
|
10
10
|
import { jsonSchema } from './sort-import-attributes.js'
|
|
11
|
-
import { AST_NODE_TYPES } from '@typescript-eslint/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types'
|
|
12
|
+
const ORDER_ERROR_ID = 'unexpectedExportAttributesOrder'
|
|
13
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedExportAttributesGroupOrder'
|
|
14
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenExportAttributes'
|
|
15
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenExportAttributes'
|
|
16
|
+
let defaultOptions = {
|
|
17
17
|
fallbackSort: { type: 'unsorted' },
|
|
18
18
|
newlinesInside: 'newlinesBetween',
|
|
19
19
|
specialCharacters: 'keep',
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
* Complete list of available export selectors. Used for validation and JSON
|
|
7
7
|
* schema generation.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
let allSelectors = ['export']
|
|
10
10
|
/**
|
|
11
11
|
* Complete list of available export modifiers. Used for validation and JSON
|
|
12
12
|
* schema generation.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
let allModifiers = [
|
|
15
15
|
'value',
|
|
16
16
|
'type',
|
|
17
17
|
'named',
|
|
@@ -23,7 +23,7 @@ var allModifiers = [
|
|
|
23
23
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
24
24
|
* rule options at configuration time.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
27
27
|
modifiers: buildCustomGroupModifiersJsonSchema(allModifiers),
|
|
28
28
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
29
29
|
}
|