eslint-plugin-perfectionist 5.11.0 → 5.11.1
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 +7 -7
- package/dist/rules/sort-arrays/types.js +2 -2
- package/dist/rules/sort-arrays.js +7 -7
- package/dist/rules/sort-classes/compute-dependencies-by-sorting-node.js +1 -1
- package/dist/rules/sort-classes/sort-class.js +4 -4
- package/dist/rules/sort-classes/types.js +8 -8
- package/dist/rules/sort-decorators.js +5 -5
- package/dist/rules/sort-enums/build-comparator-by-options-computer.js +2 -2
- package/dist/rules/sort-enums/sort-enum.js +1 -1
- package/dist/rules/sort-enums/types.js +6 -6
- package/dist/rules/sort-export-attributes.js +5 -5
- package/dist/rules/sort-exports/types.js +3 -3
- package/dist/rules/sort-exports.js +8 -8
- package/dist/rules/sort-heritage-clauses/sort-heritage-clause.js +1 -1
- package/dist/rules/sort-heritage-clauses/types.js +4 -4
- 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 +3 -3
- 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 +9 -9
- package/dist/rules/sort-interfaces.js +4 -4
- package/dist/rules/sort-intersection-types.js +6 -6
- package/dist/rules/sort-jsx-props/sort-jsx-object.js +2 -2
- package/dist/rules/sort-jsx-props/types.js +7 -7
- package/dist/rules/sort-maps/sort-potential-map.js +1 -1
- package/dist/rules/sort-maps/types.js +4 -4
- package/dist/rules/sort-modules/compute-additional-module-statements.js +1 -1
- package/dist/rules/sort-modules/dependencies/compute-dependencies-by-sorting-node.js +1 -1
- package/dist/rules/sort-modules/dependencies/is-identifier-in-decorator-metadata-type-position.js +1 -1
- package/dist/rules/sort-modules/types.js +4 -4
- package/dist/rules/sort-modules.js +11 -9
- 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-imports/sort-named-import.js +2 -2
- package/dist/rules/sort-named-imports/types.js +7 -7
- package/dist/rules/sort-object-types/comparator-by-options-computer.js +2 -2
- package/dist/rules/sort-object-types/sort-object-type-elements.js +1 -1
- package/dist/rules/sort-object-types/types.js +5 -5
- package/dist/rules/sort-object-types.js +6 -6
- package/dist/rules/sort-objects/comparator-by-options-computer.js +2 -2
- package/dist/rules/sort-objects/compute-matched-context-options.js +1 -1
- package/dist/rules/sort-objects/passes-declaration-matches-pattern-filter.js +1 -1
- package/dist/rules/sort-objects/sort-object.js +2 -2
- package/dist/rules/sort-objects/types.js +10 -10
- package/dist/rules/sort-sets.js +5 -5
- package/dist/rules/sort-switch-case.js +16 -11
- package/dist/rules/sort-union-types/types.js +2 -2
- package/dist/rules/sort-union-types.js +6 -6
- package/dist/rules/sort-variable-declarations/sort-variable-declaration.js +2 -2
- package/dist/rules/sort-variable-declarations/types.js +9 -7
- 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.js +1 -1
- package/dist/utils/compare/unsorted-comparator.js +1 -1
- package/dist/utils/create-eslint-rule.js +1 -1
- 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.js +1 -1
- package/dist/utils/get-node-range.js +1 -1
- 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-inside-deferred-function.js +1 -1
- 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.js +12 -8
- 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/tsconfig/get-typescript-import.js +3 -3
- package/dist/utils/tsconfig/read-closest-ts-config-by-path.js +3 -3
- package/dist/utils/validate-newlines-and-partition-config.js +2 -2
- package/package.json +2 -2
- package/readme.md +2 -2
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.11.1'
|
|
3
3
|
export { name, version }
|
|
@@ -22,12 +22,12 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
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(),
|
|
@@ -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 }
|
|
@@ -22,12 +22,12 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
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,6 +1,6 @@
|
|
|
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
5
|
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils'
|
|
6
6
|
function computeDependenciesBySortingNode({
|
|
@@ -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'
|
|
@@ -45,8 +45,8 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
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(),
|
|
@@ -30,11 +30,11 @@ 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
32
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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',
|
|
@@ -37,7 +37,7 @@ function buildComparatorByOptionsComputer(isNumericEnum) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
let byNonNumericValueComparatorComputer = options => {
|
|
41
41
|
switch (options.type) {
|
|
42
42
|
/* v8 ignore next 2 -- @preserve Untested for now as not a relevant sort for this rule. */
|
|
43
43
|
case 'subgroup-order':
|
|
@@ -59,7 +59,7 @@ var byNonNumericValueComparatorComputer = options => {
|
|
|
59
59
|
throw new UnreachableCaseError(options.type)
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
let byNumericValueComparatorComputer = options => {
|
|
63
63
|
switch (options.type) {
|
|
64
64
|
/* v8 ignore next 2 -- @preserve Untested for now as not a relevant sort for this rule. */
|
|
65
65
|
case 'subgroup-order':
|
|
@@ -30,7 +30,7 @@ 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
32
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
33
|
-
|
|
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 {
|
|
@@ -9,11 +9,11 @@ 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
11
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { buildCommonJsonSchemas } from '../utils/json-schemas/common-json-schemas.js'
|
|
2
2
|
import { buildCommonGroupsJsonSchemas } from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
3
|
-
import { UnreachableCaseError } from '../utils/unreachable-case-error.js'
|
|
4
3
|
import {
|
|
5
4
|
EXTRA_SPACING_ERROR,
|
|
6
5
|
GROUP_ORDER_ERROR,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
partitionByCommentJsonSchema,
|
|
13
12
|
partitionByNewlineJsonSchema,
|
|
14
13
|
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
14
|
+
import { UnreachableCaseError } from '../utils/unreachable-case-error.js'
|
|
15
15
|
import { defaultComparatorByOptionsComputer } from '../utils/compare/default-comparator-by-options-computer.js'
|
|
16
16
|
import { validateNewlinesAndPartitionConfig } from '../utils/validate-newlines-and-partition-config.js'
|
|
17
17
|
import { buildOptionsByGroupIndexComputer } from '../utils/build-options-by-group-index-computer.js'
|
|
@@ -39,13 +39,13 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
39
39
|
/**
|
|
40
40
|
* Cache computed groups by modifiers and selectors for performance.
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
43
|
+
const ORDER_ERROR_ID = 'unexpectedExportsOrder'
|
|
44
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedExportsGroupOrder'
|
|
45
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenExports'
|
|
46
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenExports'
|
|
47
|
+
const MISSED_COMMENT_ABOVE_ERROR_ID = 'missedCommentAboveExport'
|
|
48
|
+
let defaultOptions = {
|
|
49
49
|
fallbackSort: { type: 'unsorted' },
|
|
50
50
|
newlinesInside: 'newlinesBetween',
|
|
51
51
|
specialCharacters: 'keep',
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { computeNodeName } from './compute-node-name.js'
|
|
24
24
|
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
25
25
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
26
|
-
|
|
26
|
+
let defaultOptions = {
|
|
27
27
|
fallbackSort: { type: 'unsorted' },
|
|
28
28
|
newlinesInside: 'newlinesBetween',
|
|
29
29
|
specialCharacters: 'keep',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const ORDER_ERROR_ID = 'unexpectedHeritageClausesOrder'
|
|
2
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedHeritageClausesGroupOrder'
|
|
3
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenHeritageClauses'
|
|
4
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenHeritageClauses'
|
|
5
5
|
export {
|
|
6
6
|
EXTRA_SPACING_ERROR_ID,
|
|
7
7
|
GROUP_ORDER_ERROR_ID,
|
|
@@ -18,11 +18,11 @@ import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
|
18
18
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
19
19
|
import { sortImportOrExportAttributes } from './sort-import-attributes/sort-import-or-export-attributes.js'
|
|
20
20
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const ORDER_ERROR_ID = 'unexpectedImportAttributesOrder'
|
|
22
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedImportAttributesGroupOrder'
|
|
23
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenImportAttributes'
|
|
24
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenImportAttributes'
|
|
25
|
+
let defaultOptions = {
|
|
26
26
|
fallbackSort: { type: 'unsorted' },
|
|
27
27
|
newlinesInside: 'newlinesBetween',
|
|
28
28
|
specialCharacters: 'keep',
|
|
@@ -38,7 +38,7 @@ var defaultOptions = {
|
|
|
38
38
|
order: 'asc',
|
|
39
39
|
groups: [],
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
let jsonSchema = {
|
|
42
42
|
items: {
|
|
43
43
|
properties: {
|
|
44
44
|
...buildCommonJsonSchemas(),
|
|
@@ -6,7 +6,7 @@ import { compareByCustomSort } from '../../utils/compare/compare-by-custom-sort.
|
|
|
6
6
|
import { unsortedComparator } from '../../utils/compare/unsorted-comparator.js'
|
|
7
7
|
import { compareNaturally } from '../../utils/compare/compare-naturally.js'
|
|
8
8
|
import { defaultComparatorByOptionsComputer } from '../../utils/compare/default-comparator-by-options-computer.js'
|
|
9
|
-
|
|
9
|
+
let comparatorByOptionsComputer = options => {
|
|
10
10
|
switch (options.type) {
|
|
11
11
|
case 'type-import-first':
|
|
12
12
|
return (a, b) => compareTypeImportFirst(a, b, options)
|
|
@@ -56,7 +56,7 @@ function compareTypeImportFirst(a, b, options) {
|
|
|
56
56
|
}
|
|
57
57
|
return computeOrderedValue(a.isTypeImport ? -1 : 1, options.order)
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
let bySpecifierComparatorByOptionsComputer = options => {
|
|
60
60
|
switch (options.type) {
|
|
61
61
|
/* v8 ignore next 2 -- @preserve Untested for now as not a relevant sort for this rule. */
|
|
62
62
|
case 'subgroup-order':
|
|
@@ -63,7 +63,7 @@ function computeCommonSelectors({ tsConfigOutput, filename, options, name }) {
|
|
|
63
63
|
}
|
|
64
64
|
return commonSelectors
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
let bunModules = /* @__PURE__ */ new Set([
|
|
67
67
|
'detect-libc',
|
|
68
68
|
'bun:sqlite',
|
|
69
69
|
'bun:test',
|
|
@@ -74,8 +74,8 @@ var bunModules = /* @__PURE__ */ new Set([
|
|
|
74
74
|
'bun',
|
|
75
75
|
'ws',
|
|
76
76
|
])
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let nodeBuiltinModules = new Set(builtinModules)
|
|
78
|
+
let builtinPrefixOnlyModules = /* @__PURE__ */ new Set([
|
|
79
79
|
'node:sqlite',
|
|
80
80
|
'node:test',
|
|
81
81
|
'node:sea',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Cache for compiled regex patterns from tsconfig paths. Avoids recompiling the
|
|
3
3
|
* same path patterns repeatedly.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
let regexByTsconfigPathCache = /* @__PURE__ */ new Map()
|
|
6
6
|
/**
|
|
7
7
|
* Checks if an import matches any of the path mappings in tsconfig.json.
|
|
8
8
|
*
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
* Complete list of available active import selectors. Used for validation and
|
|
7
7
|
* JSON schema generation.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
let allSelectors = [
|
|
10
10
|
'side-effect-style',
|
|
11
11
|
'tsconfig-path',
|
|
12
12
|
'side-effect',
|
|
@@ -25,7 +25,7 @@ var allSelectors = [
|
|
|
25
25
|
* Complete list of available import modifiers. Used for validation and JSON
|
|
26
26
|
* schema generation.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
let allModifiers = [
|
|
29
29
|
'default',
|
|
30
30
|
'multiline',
|
|
31
31
|
'named',
|
|
@@ -41,17 +41,17 @@ var allModifiers = [
|
|
|
41
41
|
* Ideally, we should generate as many schemas as there are selectors, and
|
|
42
42
|
* ensure that users do not enter invalid modifiers for a given selector.
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
45
45
|
modifiers: buildCustomGroupModifiersJsonSchema(allModifiers),
|
|
46
46
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
let additionalSortOptionsJsonSchema = {
|
|
49
49
|
sortBy: {
|
|
50
50
|
enum: [...['specifier', 'path']],
|
|
51
51
|
type: 'string',
|
|
52
52
|
},
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
const TYPE_IMPORT_FIRST_TYPE_OPTION = 'type-import-first'
|
|
55
55
|
export {
|
|
56
56
|
TYPE_IMPORT_FIRST_TYPE_OPTION,
|
|
57
57
|
additionalCustomGroupMatchOptionsJsonSchema,
|
|
@@ -62,14 +62,14 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
62
62
|
/**
|
|
63
63
|
* Cache computed groups by modifiers and selectors for performance.
|
|
64
64
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
66
|
+
const ORDER_ERROR_ID = 'unexpectedImportsOrder'
|
|
67
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedImportsGroupOrder'
|
|
68
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenImports'
|
|
69
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenImports'
|
|
70
|
+
const MISSED_COMMENT_ABOVE_ERROR_ID = 'missedCommentAboveImport'
|
|
71
|
+
const DEPENDENCY_ORDER_ERROR_ID = 'unexpectedImportsDependencyOrder'
|
|
72
|
+
let defaultOptions = {
|
|
73
73
|
groups: [
|
|
74
74
|
'type-import',
|
|
75
75
|
['value-builtin', 'value-external'],
|
|
@@ -431,7 +431,7 @@ function computeGroupExceptUnknown({ selectors, modifiers, options, name }) {
|
|
|
431
431
|
}
|
|
432
432
|
return computedCustomGroup
|
|
433
433
|
}
|
|
434
|
-
|
|
434
|
+
let styleExtensions = [
|
|
435
435
|
'.less',
|
|
436
436
|
'.scss',
|
|
437
437
|
'.sass',
|
|
@@ -9,10 +9,10 @@ import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
|
9
9
|
import { sortObjectTypeElements } from './sort-object-types/sort-object-type-elements.js'
|
|
10
10
|
import { defaultOptions, jsonSchema } from './sort-object-types.js'
|
|
11
11
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const ORDER_ERROR_ID = 'unexpectedInterfacePropertiesOrder'
|
|
13
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedInterfacePropertiesGroupOrder'
|
|
14
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenInterfaceMembers'
|
|
15
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenInterfaceMembers'
|
|
16
16
|
var sort_interfaces_default = createEslintRule({
|
|
17
17
|
meta: {
|
|
18
18
|
messages: {
|
|
@@ -12,12 +12,12 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
12
12
|
/**
|
|
13
13
|
* Cache computed groups by modifiers and selectors for performance.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
16
|
+
const ORDER_ERROR_ID = 'unexpectedIntersectionTypesOrder'
|
|
17
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedIntersectionTypesGroupOrder'
|
|
18
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenIntersectionTypes'
|
|
19
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenIntersectionTypes'
|
|
20
|
+
let defaultOptions = {
|
|
21
21
|
fallbackSort: { type: 'unsorted' },
|
|
22
22
|
newlinesInside: 'newlinesBetween',
|
|
23
23
|
ignoreCallableTypes: true,
|
|
@@ -30,8 +30,8 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
|
30
30
|
/**
|
|
31
31
|
* Cache computed groups by modifiers and selectors for performance.
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
34
|
+
let defaultOptions = {
|
|
35
35
|
fallbackSort: { type: 'unsorted' },
|
|
36
36
|
newlinesInside: 'newlinesBetween',
|
|
37
37
|
specialCharacters: 'keep',
|
|
@@ -3,25 +3,25 @@ import {
|
|
|
3
3
|
buildCustomGroupModifiersJsonSchema,
|
|
4
4
|
buildCustomGroupSelectorJsonSchema,
|
|
5
5
|
} from '../../utils/json-schemas/common-groups-json-schemas.js'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const ORDER_ERROR_ID = 'unexpectedJSXPropsOrder'
|
|
7
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedJSXPropsGroupOrder'
|
|
8
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenJSXPropsMembers'
|
|
9
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenJSXPropsMembers'
|
|
10
10
|
/**
|
|
11
11
|
* Complete list of available JSX prop selectors. Used for validation and JSON
|
|
12
12
|
* schema generation.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
let allSelectors = ['prop']
|
|
15
15
|
/**
|
|
16
16
|
* Complete list of available JSX prop modifiers. Used for validation and JSON
|
|
17
17
|
* schema generation.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
let allModifiers = ['shorthand', 'multiline']
|
|
20
20
|
/**
|
|
21
21
|
* Additional custom group match options JSON schema. Used by ESLint to validate
|
|
22
22
|
* rule options at configuration time.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
let additionalCustomGroupMatchOptionsJsonSchema = {
|
|
25
25
|
modifiers: buildCustomGroupModifiersJsonSchema(allModifiers),
|
|
26
26
|
selector: buildCustomGroupSelectorJsonSchema(allSelectors),
|
|
27
27
|
elementValuePattern: buildRegexJsonSchema(),
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
import { computeNodeName } from './compute-node-name.js'
|
|
23
23
|
import { computeMatchedContextOptions } from './compute-matched-context-options.js'
|
|
24
24
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
25
|
-
|
|
25
|
+
let defaultOptions = {
|
|
26
26
|
fallbackSort: { type: 'unsorted' },
|
|
27
27
|
newlinesInside: 'newlinesBetween',
|
|
28
28
|
specialCharacters: 'keep',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const ORDER_ERROR_ID = 'unexpectedMapElementsOrder'
|
|
2
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedMapElementsGroupOrder'
|
|
3
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenMapElementsMembers'
|
|
4
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenMapElementsMembers'
|
|
5
5
|
export {
|
|
6
6
|
EXTRA_SPACING_ERROR_ID,
|
|
7
7
|
GROUP_ORDER_ERROR_ID,
|