eslint-plugin-perfectionist 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alphabet.d.ts +176 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/rules/sort-array-includes.js +2 -0
- package/dist/rules/sort-classes.js +6 -2
- package/dist/rules/sort-decorators.js +4 -0
- package/dist/rules/sort-enums.js +5 -0
- package/dist/rules/sort-exports.js +4 -0
- package/dist/rules/sort-heritage-clauses.js +4 -0
- package/dist/rules/sort-imports.js +5 -0
- package/dist/rules/sort-interfaces.js +1 -0
- package/dist/rules/sort-intersection-types.js +4 -0
- package/dist/rules/sort-jsx-props.js +4 -0
- package/dist/rules/sort-maps.js +4 -0
- package/dist/rules/sort-modules.js +6 -2
- package/dist/rules/sort-named-exports.js +4 -0
- package/dist/rules/sort-named-imports.js +4 -0
- package/dist/rules/sort-object-types.js +10 -11
- package/dist/rules/sort-objects.js +32 -5
- package/dist/rules/sort-switch-case.js +4 -0
- package/dist/rules/sort-union-types.js +4 -0
- package/dist/rules/sort-variable-declarations.js +4 -0
- package/dist/utils/alphabet.js +385 -0
- package/dist/utils/common-json-schemas.js +16 -1
- package/dist/utils/compare.js +88 -38
- package/dist/utils/convert-boolean-to-sign.js +4 -0
- package/dist/{rules → utils}/get-custom-groups-compare-options.js +1 -0
- package/dist/utils/get-matching-context-options.js +18 -0
- package/dist/utils/get-settings.js +1 -0
- package/dist/utils/is-node-function-type.js +15 -0
- package/dist/utils/validate-custom-sort-configuration.js +11 -0
- package/dist/{rules → utils}/validate-generated-groups-configuration.js +1 -1
- package/package.json +7 -3
- package/readme.md +4 -3
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class to build alphabets
|
|
3
|
+
*/
|
|
4
|
+
export declare class Alphabet {
|
|
5
|
+
private _characters
|
|
6
|
+
private constructor()
|
|
7
|
+
/**
|
|
8
|
+
* Generates an alphabet from the given characters.
|
|
9
|
+
* @param {string|string[]} values - The characters to generate the alphabet from
|
|
10
|
+
* @returns {Alphabet} - The wrapped alphabet
|
|
11
|
+
*/
|
|
12
|
+
static generateFrom(values: string[] | string): Alphabet
|
|
13
|
+
/**
|
|
14
|
+
* Generates an alphabet containing relevant characters from the Unicode
|
|
15
|
+
* standard. Contains the Unicode planes 0 and 1.
|
|
16
|
+
* @returns {Alphabet} - The generated alphabet
|
|
17
|
+
*/
|
|
18
|
+
static generateRecommendedAlphabet(): Alphabet
|
|
19
|
+
/**
|
|
20
|
+
* Generates an alphabet containing all characters from the Unicode standard
|
|
21
|
+
* except for irrelevant Unicode planes.
|
|
22
|
+
* Contains the Unicode planes 0, 1, 2 and 3.
|
|
23
|
+
* @returns {Alphabet} - The generated alphabet
|
|
24
|
+
*/
|
|
25
|
+
static generateCompleteAlphabet(): Alphabet
|
|
26
|
+
private static _convertCodepointToCharacter
|
|
27
|
+
/**
|
|
28
|
+
* Generates an alphabet containing relevant characters from the Unicode
|
|
29
|
+
* standard.
|
|
30
|
+
* @param {number} maxCodePoint - The maximum code point to generate the
|
|
31
|
+
* alphabet to
|
|
32
|
+
* @returns {Alphabet} - The generated alphabet
|
|
33
|
+
*/
|
|
34
|
+
private static _generateAlphabetToRange
|
|
35
|
+
/**
|
|
36
|
+
* For each character with a lower and upper case, permutes the two cases
|
|
37
|
+
* so that the alphabet is ordered by the case priority entered.
|
|
38
|
+
* @param {string} casePriority - The case to prioritize
|
|
39
|
+
* @returns {Alphabet} - The same alphabet instance with the cases prioritized
|
|
40
|
+
* @example
|
|
41
|
+
* Alphabet.generateFrom('aAbBcdCD')
|
|
42
|
+
* .prioritizeCase('uppercase')
|
|
43
|
+
* // Returns 'AaBbCDcd'
|
|
44
|
+
*/
|
|
45
|
+
prioritizeCase(casePriority: 'lowercase' | 'uppercase'): this
|
|
46
|
+
/**
|
|
47
|
+
* Adds specific characters to the end of the alphabet.
|
|
48
|
+
* @param {string|string[]} values - The characters to push to the alphabet
|
|
49
|
+
* @returns {Alphabet} - The same alphabet instance without the specified
|
|
50
|
+
* characters
|
|
51
|
+
* @example
|
|
52
|
+
* Alphabet.generateFrom('ab')
|
|
53
|
+
* .pushCharacters('cd')
|
|
54
|
+
* // Returns 'abcd'
|
|
55
|
+
*/
|
|
56
|
+
pushCharacters(values: string[] | string): this
|
|
57
|
+
/**
|
|
58
|
+
* Permutes characters with cases so that all characters with the entered case
|
|
59
|
+
* are put before the other characters.
|
|
60
|
+
* @param {string} caseToComeFirst - The case to put before the other
|
|
61
|
+
* characters
|
|
62
|
+
* @returns {Alphabet} - The same alphabet instance with all characters with
|
|
63
|
+
* case before all the characters with the other case
|
|
64
|
+
*/
|
|
65
|
+
placeAllWithCaseBeforeAllWithOtherCase(
|
|
66
|
+
caseToComeFirst: 'uppercase' | 'lowercase',
|
|
67
|
+
): this
|
|
68
|
+
/**
|
|
69
|
+
* Places a specific character right before another character in the alphabet.
|
|
70
|
+
* @param {object} params - The parameters for the operation
|
|
71
|
+
* @param {string} params.characterBefore - The character to come before
|
|
72
|
+
* characterAfter
|
|
73
|
+
* @param {string} params.characterAfter - The target character
|
|
74
|
+
* @returns {Alphabet} - The same alphabet instance with the specific
|
|
75
|
+
* character prioritized
|
|
76
|
+
* @example
|
|
77
|
+
* Alphabet.generateFrom('ab-cd/')
|
|
78
|
+
* .placeCharacterBefore({ characterBefore: '/', characterAfter: '-' })
|
|
79
|
+
* // Returns 'ab/-cd'
|
|
80
|
+
*/
|
|
81
|
+
placeCharacterBefore({
|
|
82
|
+
characterBefore,
|
|
83
|
+
characterAfter,
|
|
84
|
+
}: {
|
|
85
|
+
characterBefore: string
|
|
86
|
+
characterAfter: string
|
|
87
|
+
}): this
|
|
88
|
+
/**
|
|
89
|
+
* Places a specific character right after another character in the alphabet.
|
|
90
|
+
* @param {object} params - The parameters for the operation
|
|
91
|
+
* @param {string} params.characterBefore - The target character
|
|
92
|
+
* @param {string} params.characterAfter - The character to come after
|
|
93
|
+
* characterBefore
|
|
94
|
+
* @returns {Alphabet} - The same alphabet instance with the specific
|
|
95
|
+
* character prioritized
|
|
96
|
+
* @example
|
|
97
|
+
* Alphabet.generateFrom('ab-cd/')
|
|
98
|
+
* .placeCharacterAfter({ characterBefore: '/', characterAfter: '-' })
|
|
99
|
+
* // Returns 'abcd/-'
|
|
100
|
+
*/
|
|
101
|
+
placeCharacterAfter({
|
|
102
|
+
characterBefore,
|
|
103
|
+
characterAfter,
|
|
104
|
+
}: {
|
|
105
|
+
characterBefore: string
|
|
106
|
+
characterAfter: string
|
|
107
|
+
}): this
|
|
108
|
+
/**
|
|
109
|
+
* Removes specific characters from the alphabet by their range.
|
|
110
|
+
* @param {object} range - The Unicode range to remove characters from
|
|
111
|
+
* @param {number} range.start - The starting Unicode codepoint
|
|
112
|
+
* @param {number} range.end - The ending Unicode codepoint
|
|
113
|
+
* @returns {Alphabet} - The same alphabet instance without the characters
|
|
114
|
+
* from the specified range
|
|
115
|
+
*/
|
|
116
|
+
removeUnicodeRange({ start, end }: { start: number; end: number }): this
|
|
117
|
+
/**
|
|
118
|
+
* Sorts the alphabet by the sorting function provided.
|
|
119
|
+
* @param {Function} sortingFunction - The sorting function to use
|
|
120
|
+
* @returns {Alphabet} - The same alphabet instance sorted by the sorting function provided
|
|
121
|
+
*/
|
|
122
|
+
sortBy(
|
|
123
|
+
sortingFunction: (characterA: string, characterB: string) => number,
|
|
124
|
+
): this
|
|
125
|
+
/**
|
|
126
|
+
* Removes specific characters from the alphabet.
|
|
127
|
+
* @param {string|string[]} values - The characters to remove from the
|
|
128
|
+
* alphabet
|
|
129
|
+
* @returns {Alphabet} - The same alphabet instance without the specified
|
|
130
|
+
* characters
|
|
131
|
+
* @example
|
|
132
|
+
* Alphabet.generateFrom('abcd')
|
|
133
|
+
* .removeCharacters('dcc')
|
|
134
|
+
* // Returns 'ab'
|
|
135
|
+
*/
|
|
136
|
+
removeCharacters(values: string[] | string): this
|
|
137
|
+
/**
|
|
138
|
+
* Sorts the alphabet by the natural order of the characters using
|
|
139
|
+
* `natural-orderby`.
|
|
140
|
+
* @param {string} locale - The locale to use for sorting
|
|
141
|
+
* @returns {Alphabet} - The same alphabet instance sorted by the natural
|
|
142
|
+
* order of the characters
|
|
143
|
+
*/
|
|
144
|
+
sortByNaturalSort(locale?: string): this
|
|
145
|
+
/**
|
|
146
|
+
* Sorts the alphabet by the character code point.
|
|
147
|
+
* @returns {Alphabet} - The same alphabet instance sorted by the character
|
|
148
|
+
* code point
|
|
149
|
+
*/
|
|
150
|
+
sortByCharCodeAt(): this
|
|
151
|
+
/**
|
|
152
|
+
* Sorts the alphabet by the locale order of the characters.
|
|
153
|
+
* @param {Intl.LocalesArgument} locales - The locales to use for sorting
|
|
154
|
+
* @returns {Alphabet} - The same alphabet instance sorted by the locale
|
|
155
|
+
* order of the characters
|
|
156
|
+
*/
|
|
157
|
+
sortByLocaleCompare(locales?: Intl.LocalesArgument): this
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the characters from the alphabet.
|
|
160
|
+
* @returns {string} The characters from the alphabet
|
|
161
|
+
*/
|
|
162
|
+
getCharacters(): string
|
|
163
|
+
/**
|
|
164
|
+
* Reverses the alphabet.
|
|
165
|
+
* @returns {Alphabet} - The same alphabet instance reversed
|
|
166
|
+
* @example
|
|
167
|
+
* Alphabet.generateFrom('ab')
|
|
168
|
+
* .reverse()
|
|
169
|
+
* // Returns 'ba'
|
|
170
|
+
*/
|
|
171
|
+
reverse(): this
|
|
172
|
+
private _placeCharacterBeforeOrAfter
|
|
173
|
+
private _getCharactersWithCase
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,9 +30,11 @@ declare interface PluginConfig {
|
|
|
30
30
|
'recommended-alphabetical-legacy': Linter.LegacyConfig
|
|
31
31
|
'recommended-line-length-legacy': Linter.LegacyConfig
|
|
32
32
|
'recommended-natural-legacy': Linter.LegacyConfig
|
|
33
|
+
'recommended-custom-legacy': Linter.LegacyConfig
|
|
33
34
|
'recommended-alphabetical': Linter.Config
|
|
34
35
|
'recommended-line-length': Linter.Config
|
|
35
36
|
'recommended-natural': Linter.Config
|
|
37
|
+
'recommended-custom': Linter.Config
|
|
36
38
|
}
|
|
37
39
|
name: string
|
|
38
40
|
}
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,10 @@ const index = {
|
|
|
77
77
|
type: 'natural',
|
|
78
78
|
order: 'asc',
|
|
79
79
|
}),
|
|
80
|
+
'recommended-custom-legacy': createLegacyConfig({
|
|
81
|
+
type: 'custom',
|
|
82
|
+
order: 'asc',
|
|
83
|
+
}),
|
|
80
84
|
'recommended-alphabetical': createConfig({
|
|
81
85
|
type: 'alphabetical',
|
|
82
86
|
order: 'asc',
|
|
@@ -89,6 +93,10 @@ const index = {
|
|
|
89
93
|
type: 'natural',
|
|
90
94
|
order: 'asc',
|
|
91
95
|
}),
|
|
96
|
+
'recommended-custom': createConfig({
|
|
97
|
+
type: 'custom',
|
|
98
|
+
order: 'asc',
|
|
99
|
+
}),
|
|
92
100
|
},
|
|
93
101
|
}
|
|
94
102
|
module.exports = index
|
|
@@ -27,6 +27,7 @@ let defaultOptions = {
|
|
|
27
27
|
type: 'alphabetical',
|
|
28
28
|
ignoreCase: true,
|
|
29
29
|
locales: 'en-US',
|
|
30
|
+
alphabet: '',
|
|
30
31
|
order: 'asc',
|
|
31
32
|
}
|
|
32
33
|
let jsonSchema = {
|
|
@@ -48,6 +49,7 @@ let jsonSchema = {
|
|
|
48
49
|
},
|
|
49
50
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
50
51
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
52
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
51
53
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
52
54
|
order: commonJsonSchemas.orderJsonSchema,
|
|
53
55
|
type: commonJsonSchemas.typeJsonSchema,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
3
|
const sortNodesByDependencies = require('../utils/sort-nodes-by-dependencies.js')
|
|
4
4
|
const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
|
|
5
|
+
const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
|
|
5
6
|
const sortClasses_types = require('./sort-classes.types.js')
|
|
6
|
-
const
|
|
7
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
7
8
|
const sortClassesUtils = require('./sort-classes-utils.js')
|
|
8
|
-
const getCustomGroupsCompareOptions = require('
|
|
9
|
+
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
|
|
9
10
|
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
|
|
10
11
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
11
12
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -62,6 +63,7 @@ let defaultOptions = {
|
|
|
62
63
|
ignoreCase: true,
|
|
63
64
|
customGroups: [],
|
|
64
65
|
locales: 'en-US',
|
|
66
|
+
alphabet: '',
|
|
65
67
|
order: 'asc',
|
|
66
68
|
}
|
|
67
69
|
const sortClasses = createEslintRule.createEslintRule({
|
|
@@ -77,6 +79,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
77
79
|
settings,
|
|
78
80
|
defaultOptions,
|
|
79
81
|
)
|
|
82
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
80
83
|
validateGeneratedGroupsConfiguration.validateGeneratedGroupsConfiguration(
|
|
81
84
|
{
|
|
82
85
|
customGroups: options.customGroups,
|
|
@@ -594,6 +597,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
594
597
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
595
598
|
newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
|
|
596
599
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
600
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
597
601
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
598
602
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
599
603
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
|
|
4
5
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
5
6
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -31,6 +32,7 @@ let defaultOptions = {
|
|
|
31
32
|
ignoreCase: true,
|
|
32
33
|
customGroups: {},
|
|
33
34
|
locales: 'en-US',
|
|
35
|
+
alphabet: '',
|
|
34
36
|
order: 'asc',
|
|
35
37
|
groups: [],
|
|
36
38
|
}
|
|
@@ -72,6 +74,7 @@ const sortDecorators = createEslintRule.createEslintRule({
|
|
|
72
74
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
73
75
|
customGroups: commonJsonSchemas.customGroupsJsonSchema,
|
|
74
76
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
77
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
75
78
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
76
79
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
77
80
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -102,6 +105,7 @@ const sortDecorators = createEslintRule.createEslintRule({
|
|
|
102
105
|
settings,
|
|
103
106
|
defaultOptions,
|
|
104
107
|
)
|
|
108
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
105
109
|
validateGroupsConfiguration.validateGroupsConfiguration(
|
|
106
110
|
options.groups,
|
|
107
111
|
['unknown'],
|
package/dist/rules/sort-enums.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
3
|
const sortNodesByDependencies = require('../utils/sort-nodes-by-dependencies.js')
|
|
4
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
4
5
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
5
6
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
6
7
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
@@ -26,6 +27,7 @@ let defaultOptions = {
|
|
|
26
27
|
sortByValue: false,
|
|
27
28
|
ignoreCase: true,
|
|
28
29
|
locales: 'en-US',
|
|
30
|
+
alphabet: '',
|
|
29
31
|
order: 'asc',
|
|
30
32
|
}
|
|
31
33
|
const sortEnums = createEslintRule.createEslintRule({
|
|
@@ -44,6 +46,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
44
46
|
settings,
|
|
45
47
|
defaultOptions,
|
|
46
48
|
)
|
|
49
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
47
50
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
48
51
|
let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
|
|
49
52
|
ruleName: context.id,
|
|
@@ -165,6 +168,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
165
168
|
: options.type,
|
|
166
169
|
specialCharacters: options.specialCharacters,
|
|
167
170
|
ignoreCase: options.ignoreCase,
|
|
171
|
+
alphabet: options.alphabet,
|
|
168
172
|
locales: options.locales,
|
|
169
173
|
order: options.order,
|
|
170
174
|
}
|
|
@@ -244,6 +248,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
244
248
|
partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
|
|
245
249
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
246
250
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
251
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
247
252
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
248
253
|
order: commonJsonSchemas.orderJsonSchema,
|
|
249
254
|
type: commonJsonSchemas.typeJsonSchema,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
4
5
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
5
6
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
@@ -21,6 +22,7 @@ let defaultOptions = {
|
|
|
21
22
|
groupKind: 'mixed',
|
|
22
23
|
ignoreCase: true,
|
|
23
24
|
locales: 'en-US',
|
|
25
|
+
alphabet: '',
|
|
24
26
|
order: 'asc',
|
|
25
27
|
}
|
|
26
28
|
const sortExports = createEslintRule.createEslintRule({
|
|
@@ -31,6 +33,7 @@ const sortExports = createEslintRule.createEslintRule({
|
|
|
31
33
|
settings,
|
|
32
34
|
defaultOptions,
|
|
33
35
|
)
|
|
36
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
34
37
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
35
38
|
let partitionComment = options.partitionByComment
|
|
36
39
|
let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
|
|
@@ -150,6 +153,7 @@ const sortExports = createEslintRule.createEslintRule({
|
|
|
150
153
|
partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
|
|
151
154
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
152
155
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
156
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
153
157
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
154
158
|
order: commonJsonSchemas.orderJsonSchema,
|
|
155
159
|
type: commonJsonSchemas.typeJsonSchema,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
|
|
4
5
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
5
6
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -21,6 +22,7 @@ let defaultOptions = {
|
|
|
21
22
|
ignoreCase: true,
|
|
22
23
|
customGroups: {},
|
|
23
24
|
locales: 'en-US',
|
|
25
|
+
alphabet: '',
|
|
24
26
|
order: 'asc',
|
|
25
27
|
groups: [],
|
|
26
28
|
}
|
|
@@ -32,6 +34,7 @@ const sortHeritageClauses = createEslintRule.createEslintRule({
|
|
|
32
34
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
33
35
|
customGroups: commonJsonSchemas.customGroupsJsonSchema,
|
|
34
36
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
37
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
35
38
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
36
39
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
37
40
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -62,6 +65,7 @@ const sortHeritageClauses = createEslintRule.createEslintRule({
|
|
|
62
65
|
settings,
|
|
63
66
|
defaultOptions,
|
|
64
67
|
)
|
|
68
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
65
69
|
validateGroupsConfiguration.validateGroupsConfiguration(
|
|
66
70
|
options.groups,
|
|
67
71
|
['unknown'],
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const node_module = require('node:module')
|
|
3
3
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
4
4
|
const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
|
|
5
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
5
6
|
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
|
|
6
7
|
const readClosestTsConfigByPath = require('../utils/read-closest-ts-config-by-path.js')
|
|
7
8
|
const getOptionsWithCleanGroups = require('../utils/get-options-with-clean-groups.js')
|
|
@@ -52,6 +53,7 @@ const sortImports = createEslintRule.createEslintRule({
|
|
|
52
53
|
environment: 'node',
|
|
53
54
|
ignoreCase: true,
|
|
54
55
|
locales: 'en-US',
|
|
56
|
+
alphabet: '',
|
|
55
57
|
order: 'asc',
|
|
56
58
|
}),
|
|
57
59
|
)
|
|
@@ -82,6 +84,7 @@ const sortImports = createEslintRule.createEslintRule({
|
|
|
82
84
|
...Object.keys(options.customGroups.value ?? {}),
|
|
83
85
|
],
|
|
84
86
|
)
|
|
87
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
85
88
|
validateNewlinesAndPartitionConfiguration.validateNewlinesAndPartitionConfiguration(
|
|
86
89
|
options,
|
|
87
90
|
)
|
|
@@ -513,6 +516,7 @@ const sortImports = createEslintRule.createEslintRule({
|
|
|
513
516
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
514
517
|
newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
|
|
515
518
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
519
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
516
520
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
517
521
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
518
522
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -594,6 +598,7 @@ const sortImports = createEslintRule.createEslintRule({
|
|
|
594
598
|
environment: 'node',
|
|
595
599
|
ignoreCase: true,
|
|
596
600
|
locales: 'en-US',
|
|
601
|
+
alphabet: '',
|
|
597
602
|
order: 'asc',
|
|
598
603
|
},
|
|
599
604
|
],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
3
|
const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
|
|
4
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
4
5
|
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
|
|
5
6
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
6
7
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -28,6 +29,7 @@ let defaultOptions = {
|
|
|
28
29
|
type: 'alphabetical',
|
|
29
30
|
ignoreCase: true,
|
|
30
31
|
locales: 'en-US',
|
|
32
|
+
alphabet: '',
|
|
31
33
|
order: 'asc',
|
|
32
34
|
groups: [],
|
|
33
35
|
}
|
|
@@ -40,6 +42,7 @@ const sortIntersectionTypes = createEslintRule.createEslintRule({
|
|
|
40
42
|
settings,
|
|
41
43
|
defaultOptions,
|
|
42
44
|
)
|
|
45
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
43
46
|
validateGroupsConfiguration.validateGroupsConfiguration(
|
|
44
47
|
options.groups,
|
|
45
48
|
[
|
|
@@ -249,6 +252,7 @@ const sortIntersectionTypes = createEslintRule.createEslintRule({
|
|
|
249
252
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
250
253
|
newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
|
|
251
254
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
255
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
252
256
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
253
257
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
254
258
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
|
|
4
5
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
5
6
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -22,6 +23,7 @@ let defaultOptions = {
|
|
|
22
23
|
ignoreCase: true,
|
|
23
24
|
customGroups: {},
|
|
24
25
|
locales: 'en-US',
|
|
26
|
+
alphabet: '',
|
|
25
27
|
order: 'asc',
|
|
26
28
|
groups: [],
|
|
27
29
|
}
|
|
@@ -37,6 +39,7 @@ const sortJsxProps = createEslintRule.createEslintRule({
|
|
|
37
39
|
settings,
|
|
38
40
|
defaultOptions,
|
|
39
41
|
)
|
|
42
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
40
43
|
validateGroupsConfiguration.validateGroupsConfiguration(
|
|
41
44
|
options.groups,
|
|
42
45
|
['multiline', 'shorthand', 'unknown'],
|
|
@@ -154,6 +157,7 @@ const sortJsxProps = createEslintRule.createEslintRule({
|
|
|
154
157
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
155
158
|
customGroups: commonJsonSchemas.customGroupsJsonSchema,
|
|
156
159
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
160
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
157
161
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
158
162
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
159
163
|
order: commonJsonSchemas.orderJsonSchema,
|
package/dist/rules/sort-maps.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
4
5
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
5
6
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
@@ -22,6 +23,7 @@ let defaultOptions = {
|
|
|
22
23
|
type: 'alphabetical',
|
|
23
24
|
ignoreCase: true,
|
|
24
25
|
locales: 'en-US',
|
|
26
|
+
alphabet: '',
|
|
25
27
|
order: 'asc',
|
|
26
28
|
}
|
|
27
29
|
const sortMaps = createEslintRule.createEslintRule({
|
|
@@ -47,6 +49,7 @@ const sortMaps = createEslintRule.createEslintRule({
|
|
|
47
49
|
settings,
|
|
48
50
|
defaultOptions,
|
|
49
51
|
)
|
|
52
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
50
53
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
51
54
|
let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
|
|
52
55
|
ruleName: context.id,
|
|
@@ -161,6 +164,7 @@ const sortMaps = createEslintRule.createEslintRule({
|
|
|
161
164
|
partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
|
|
162
165
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
163
166
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
167
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
164
168
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
165
169
|
order: commonJsonSchemas.orderJsonSchema,
|
|
166
170
|
type: commonJsonSchemas.typeJsonSchema,
|
|
@@ -3,9 +3,10 @@ const utils = require('@typescript-eslint/utils')
|
|
|
3
3
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
4
4
|
const sortNodesByDependencies = require('../utils/sort-nodes-by-dependencies.js')
|
|
5
5
|
const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
|
|
6
|
+
const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
|
|
6
7
|
const sortModules_types = require('./sort-modules.types.js')
|
|
7
|
-
const
|
|
8
|
-
const getCustomGroupsCompareOptions = require('
|
|
8
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
9
|
+
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
|
|
9
10
|
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
|
|
10
11
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
11
12
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
@@ -53,6 +54,7 @@ let defaultOptions = {
|
|
|
53
54
|
ignoreCase: true,
|
|
54
55
|
customGroups: [],
|
|
55
56
|
locales: 'en-US',
|
|
57
|
+
alphabet: '',
|
|
56
58
|
order: 'asc',
|
|
57
59
|
}
|
|
58
60
|
const sortModules = createEslintRule.createEslintRule({
|
|
@@ -73,6 +75,7 @@ const sortModules = createEslintRule.createEslintRule({
|
|
|
73
75
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
74
76
|
newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
|
|
75
77
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
78
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
76
79
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
77
80
|
groups: commonJsonSchemas.groupsJsonSchema,
|
|
78
81
|
order: commonJsonSchemas.orderJsonSchema,
|
|
@@ -108,6 +111,7 @@ const sortModules = createEslintRule.createEslintRule({
|
|
|
108
111
|
settings,
|
|
109
112
|
defaultOptions,
|
|
110
113
|
)
|
|
114
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
111
115
|
validateGeneratedGroupsConfiguration.validateGeneratedGroupsConfiguration({
|
|
112
116
|
customGroups: options.customGroups,
|
|
113
117
|
modifiers: sortModules_types.allModifiers,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
4
5
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
5
6
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
@@ -22,6 +23,7 @@ let defaultOptions = {
|
|
|
22
23
|
groupKind: 'mixed',
|
|
23
24
|
ignoreCase: true,
|
|
24
25
|
locales: 'en-US',
|
|
26
|
+
alphabet: '',
|
|
25
27
|
order: 'asc',
|
|
26
28
|
}
|
|
27
29
|
const sortNamedExports = createEslintRule.createEslintRule({
|
|
@@ -37,6 +39,7 @@ const sortNamedExports = createEslintRule.createEslintRule({
|
|
|
37
39
|
settings,
|
|
38
40
|
defaultOptions,
|
|
39
41
|
)
|
|
42
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
40
43
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
41
44
|
let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
|
|
42
45
|
ruleName: context.id,
|
|
@@ -156,6 +159,7 @@ const sortNamedExports = createEslintRule.createEslintRule({
|
|
|
156
159
|
partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
|
|
157
160
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
158
161
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
162
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
159
163
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
160
164
|
order: commonJsonSchemas.orderJsonSchema,
|
|
161
165
|
type: commonJsonSchemas.typeJsonSchema,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const commonJsonSchemas = require('../utils/common-json-schemas.js')
|
|
3
|
+
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
|
|
3
4
|
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
|
|
4
5
|
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
|
|
5
6
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
@@ -23,6 +24,7 @@ let defaultOptions = {
|
|
|
23
24
|
groupKind: 'mixed',
|
|
24
25
|
ignoreCase: true,
|
|
25
26
|
locales: 'en-US',
|
|
27
|
+
alphabet: '',
|
|
26
28
|
order: 'asc',
|
|
27
29
|
}
|
|
28
30
|
const sortNamedImports = createEslintRule.createEslintRule({
|
|
@@ -41,6 +43,7 @@ const sortNamedImports = createEslintRule.createEslintRule({
|
|
|
41
43
|
settings,
|
|
42
44
|
defaultOptions,
|
|
43
45
|
)
|
|
46
|
+
validateCustomSortConfiguration.validateCustomSortConfiguration(options)
|
|
44
47
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
45
48
|
let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
|
|
46
49
|
ruleName: context.id,
|
|
@@ -169,6 +172,7 @@ const sortNamedImports = createEslintRule.createEslintRule({
|
|
|
169
172
|
partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
|
|
170
173
|
specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
|
|
171
174
|
ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
|
|
175
|
+
alphabet: commonJsonSchemas.alphabetJsonSchema,
|
|
172
176
|
locales: commonJsonSchemas.localesJsonSchema,
|
|
173
177
|
order: commonJsonSchemas.orderJsonSchema,
|
|
174
178
|
type: commonJsonSchemas.typeJsonSchema,
|