eslint-plugin-perfectionist 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +74 -32
- package/dist/index.js +7 -4
- package/dist/index.mjs +7 -4
- package/dist/rules/sort-array-includes.js +8 -0
- package/dist/rules/sort-array-includes.mjs +8 -0
- package/dist/rules/sort-astro-attributes.js +10 -0
- package/dist/rules/sort-astro-attributes.mjs +10 -0
- package/dist/rules/sort-classes-utils.js +58 -0
- package/dist/rules/sort-classes-utils.mjs +52 -0
- package/dist/rules/sort-classes.js +31 -50
- package/dist/rules/sort-classes.mjs +29 -44
- package/dist/rules/sort-classes.types.js +4 -0
- package/dist/rules/sort-classes.types.mjs +4 -0
- package/dist/rules/sort-enums.js +9 -0
- package/dist/rules/sort-enums.mjs +9 -0
- package/dist/rules/sort-exports.js +8 -0
- package/dist/rules/sort-exports.mjs +8 -0
- package/dist/rules/sort-imports.js +222 -254
- package/dist/rules/sort-imports.mjs +208 -238
- package/dist/rules/sort-interfaces.js +19 -2
- package/dist/rules/sort-interfaces.mjs +19 -2
- package/dist/rules/sort-intersection-types.js +8 -0
- package/dist/rules/sort-intersection-types.mjs +8 -0
- package/dist/rules/sort-jsx-props.js +8 -0
- package/dist/rules/sort-jsx-props.mjs +8 -0
- package/dist/rules/sort-maps.js +8 -0
- package/dist/rules/sort-maps.mjs +8 -0
- package/dist/rules/sort-named-exports.js +8 -0
- package/dist/rules/sort-named-exports.mjs +8 -0
- package/dist/rules/sort-named-imports.js +8 -0
- package/dist/rules/sort-named-imports.mjs +8 -0
- package/dist/rules/sort-object-types.js +20 -3
- package/dist/rules/sort-object-types.mjs +20 -3
- package/dist/rules/sort-objects.js +8 -0
- package/dist/rules/sort-objects.mjs +8 -0
- package/dist/rules/sort-sets.js +1 -0
- package/dist/rules/sort-sets.mjs +1 -0
- package/dist/rules/sort-svelte-attributes.js +10 -0
- package/dist/rules/sort-svelte-attributes.mjs +10 -0
- package/dist/rules/sort-switch-case.js +10 -1
- package/dist/rules/sort-switch-case.mjs +10 -1
- package/dist/rules/sort-union-types.js +8 -0
- package/dist/rules/sort-union-types.mjs +8 -0
- package/dist/rules/sort-variable-declarations.js +8 -0
- package/dist/rules/sort-variable-declarations.mjs +8 -0
- package/dist/rules/sort-vue-attributes.js +10 -0
- package/dist/rules/sort-vue-attributes.mjs +10 -0
- package/dist/utils/compare.js +17 -3
- package/dist/utils/compare.mjs +17 -3
- package/dist/utils/get-options-with-clean-groups.js +13 -0
- package/dist/utils/get-options-with-clean-groups.mjs +11 -0
- package/dist/utils/get-settings.js +9 -10
- package/dist/utils/get-settings.mjs +9 -10
- package/dist/utils/sort-nodes-by-groups.js +33 -7
- package/dist/utils/sort-nodes-by-groups.mjs +33 -7
- package/dist/utils/validate-groups-configuration.js +11 -0
- package/dist/utils/validate-groups-configuration.mjs +11 -1
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ const sortClassesUtils = require('./sort-classes-utils.js')
|
|
|
3
3
|
const sortClasses_types = require('./sort-classes.types.js')
|
|
4
4
|
const sortNodesByDependencies = require('../utils/sort-nodes-by-dependencies.js')
|
|
5
5
|
const isPartitionComment = require('../utils/is-partition-comment.js')
|
|
6
|
+
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
|
|
6
7
|
const getCommentsBefore = require('../utils/get-comments-before.js')
|
|
7
8
|
const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
8
9
|
const getGroupNumber = require('../utils/get-group-number.js')
|
|
@@ -11,7 +12,6 @@ const toSingleLine = require('../utils/to-single-line.js')
|
|
|
11
12
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
12
13
|
const getSettings = require('../utils/get-settings.js')
|
|
13
14
|
const useGroups = require('../utils/use-groups.js')
|
|
14
|
-
const sortNodes = require('../utils/sort-nodes.js')
|
|
15
15
|
const makeFixes = require('../utils/make-fixes.js')
|
|
16
16
|
const complete = require('../utils/complete.js')
|
|
17
17
|
const pairwise = require('../utils/pairwise.js')
|
|
@@ -48,6 +48,12 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
48
48
|
'Controls whether sorting should be case-sensitive or not.',
|
|
49
49
|
type: 'boolean',
|
|
50
50
|
},
|
|
51
|
+
specialCharacters: {
|
|
52
|
+
description:
|
|
53
|
+
'Controls how special characters should be handled before sorting.',
|
|
54
|
+
type: 'string',
|
|
55
|
+
enum: ['remove', 'trim', 'keep'],
|
|
56
|
+
},
|
|
51
57
|
partitionByComment: {
|
|
52
58
|
description:
|
|
53
59
|
'Allows to use comments to separate the class members into logical groups.',
|
|
@@ -159,6 +165,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
159
165
|
type: 'alphabetical',
|
|
160
166
|
order: 'asc',
|
|
161
167
|
ignoreCase: true,
|
|
168
|
+
specialCharacters: 'keep',
|
|
162
169
|
matcher: 'minimatch',
|
|
163
170
|
partitionByComment: false,
|
|
164
171
|
groups: [
|
|
@@ -204,9 +211,14 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
204
211
|
partitionByComment: false,
|
|
205
212
|
type: 'alphabetical',
|
|
206
213
|
ignoreCase: true,
|
|
214
|
+
specialCharacters: 'keep',
|
|
207
215
|
customGroups: [],
|
|
208
216
|
order: 'asc',
|
|
209
217
|
})
|
|
218
|
+
sortClassesUtils.validateGroupsConfiguration(
|
|
219
|
+
options.groups,
|
|
220
|
+
options.customGroups,
|
|
221
|
+
)
|
|
210
222
|
let sourceCode = getSourceCode.getSourceCode(context)
|
|
211
223
|
let className = (_a = node.parent.id) == null ? void 0 : _a.name
|
|
212
224
|
let getDependencyName = (nodeName, isStatic) =>
|
|
@@ -228,12 +240,6 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
228
240
|
let extractDependencies = (expression, isMemberStatic) => {
|
|
229
241
|
let dependencies = []
|
|
230
242
|
let checkNode = nodeValue => {
|
|
231
|
-
if (
|
|
232
|
-
nodeValue.type === 'ArrowFunctionExpression' ||
|
|
233
|
-
nodeValue.type === 'FunctionExpression'
|
|
234
|
-
) {
|
|
235
|
-
return
|
|
236
|
-
}
|
|
237
243
|
if (
|
|
238
244
|
nodeValue.type === 'MemberExpression' &&
|
|
239
245
|
(nodeValue.object.type === 'ThisExpression' ||
|
|
@@ -369,6 +375,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
377
|
}
|
|
378
|
+
let memberValue
|
|
372
379
|
let modifiers = []
|
|
373
380
|
let selectors = []
|
|
374
381
|
if (
|
|
@@ -479,6 +486,9 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
479
486
|
if (isFunctionProperty) {
|
|
480
487
|
selectors.push('function-property')
|
|
481
488
|
}
|
|
489
|
+
if (!isFunctionProperty && member.value) {
|
|
490
|
+
memberValue = sourceCode.getText(member.value)
|
|
491
|
+
}
|
|
482
492
|
selectors.push('property')
|
|
483
493
|
if (
|
|
484
494
|
member.type === 'PropertyDefinition' &&
|
|
@@ -500,6 +510,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
500
510
|
sortClassesUtils.customGroupMatches({
|
|
501
511
|
customGroup,
|
|
502
512
|
elementName: name,
|
|
513
|
+
elementValue: memberValue,
|
|
503
514
|
modifiers,
|
|
504
515
|
selectors,
|
|
505
516
|
decorators,
|
|
@@ -523,7 +534,7 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
523
534
|
)) == null
|
|
524
535
|
? void 0
|
|
525
536
|
: _d.at(-1)
|
|
526
|
-
let
|
|
537
|
+
let sortingNode = {
|
|
527
538
|
size: overloadSignatureGroupMember
|
|
528
539
|
? rangeToDiff.rangeToDiff(overloadSignatureGroupMember.range)
|
|
529
540
|
: rangeToDiff.rangeToDiff(member.range),
|
|
@@ -536,52 +547,22 @@ const sortClasses = createEslintRule.createEslintRule({
|
|
|
536
547
|
modifiers.includes('static'),
|
|
537
548
|
),
|
|
538
549
|
}
|
|
539
|
-
accumulator.at(-1).push(
|
|
550
|
+
accumulator.at(-1).push(sortingNode)
|
|
540
551
|
return accumulator
|
|
541
552
|
},
|
|
542
553
|
[[]],
|
|
543
554
|
)
|
|
544
|
-
let sortedNodes =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
)
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
continue
|
|
556
|
-
}
|
|
557
|
-
nodesByNonIgnoredGroupNumber[groupNum] =
|
|
558
|
-
nodesByNonIgnoredGroupNumber[groupNum] ?? []
|
|
559
|
-
nodesByNonIgnoredGroupNumber[groupNum].push(sortingNode)
|
|
560
|
-
}
|
|
561
|
-
for (let groupNumber of Object.keys(
|
|
562
|
-
nodesByNonIgnoredGroupNumber,
|
|
563
|
-
).sort((a, b) => Number(a) - Number(b))) {
|
|
564
|
-
let compareOptions = sortClassesUtils.getCompareOptions(
|
|
565
|
-
options,
|
|
566
|
-
Number(groupNumber),
|
|
567
|
-
)
|
|
568
|
-
if (!compareOptions) {
|
|
569
|
-
sortedNodes.push(
|
|
570
|
-
...nodesByNonIgnoredGroupNumber[Number(groupNumber)],
|
|
571
|
-
)
|
|
572
|
-
} else {
|
|
573
|
-
sortedNodes.push(
|
|
574
|
-
...sortNodes.sortNodes(
|
|
575
|
-
nodesByNonIgnoredGroupNumber[Number(groupNumber)],
|
|
576
|
-
compareOptions,
|
|
577
|
-
),
|
|
578
|
-
)
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
for (let ignoredIndex of ignoredNodeIndices) {
|
|
582
|
-
sortedNodes.splice(ignoredIndex, 0, nodes2[ignoredIndex])
|
|
583
|
-
}
|
|
584
|
-
}
|
|
555
|
+
let sortedNodes = formattedNodes
|
|
556
|
+
.map(nodes2 =>
|
|
557
|
+
sortNodesByGroups.sortNodesByGroups(nodes2, options, {
|
|
558
|
+
getGroupCompareOptions: groupNumber =>
|
|
559
|
+
sortClassesUtils.getCompareOptions(options, groupNumber),
|
|
560
|
+
isNodeIgnored: sortingNode =>
|
|
561
|
+
getGroupNumber.getGroupNumber(options.groups, sortingNode) ===
|
|
562
|
+
options.groups.length,
|
|
563
|
+
}),
|
|
564
|
+
)
|
|
565
|
+
.flat()
|
|
585
566
|
sortedNodes =
|
|
586
567
|
sortNodesByDependencies.sortNodesByDependencies(sortedNodes)
|
|
587
568
|
let nodes = formattedNodes.flat()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
validateGroupsConfiguration,
|
|
2
3
|
getOverloadSignatureGroups,
|
|
3
4
|
generateOfficialGroups,
|
|
4
5
|
customGroupMatches,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
getFirstUnorderedNodeDependentOn,
|
|
15
16
|
} from '../utils/sort-nodes-by-dependencies.mjs'
|
|
16
17
|
import { hasPartitionComment } from '../utils/is-partition-comment.mjs'
|
|
18
|
+
import { sortNodesByGroups } from '../utils/sort-nodes-by-groups.mjs'
|
|
17
19
|
import { getCommentsBefore } from '../utils/get-comments-before.mjs'
|
|
18
20
|
import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
19
21
|
import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
@@ -22,7 +24,6 @@ import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
|
22
24
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
23
25
|
import { getSettings } from '../utils/get-settings.mjs'
|
|
24
26
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
25
|
-
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
26
27
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
27
28
|
import { complete } from '../utils/complete.mjs'
|
|
28
29
|
import { pairwise } from '../utils/pairwise.mjs'
|
|
@@ -59,6 +60,12 @@ const sortClasses = createEslintRule({
|
|
|
59
60
|
'Controls whether sorting should be case-sensitive or not.',
|
|
60
61
|
type: 'boolean',
|
|
61
62
|
},
|
|
63
|
+
specialCharacters: {
|
|
64
|
+
description:
|
|
65
|
+
'Controls how special characters should be handled before sorting.',
|
|
66
|
+
type: 'string',
|
|
67
|
+
enum: ['remove', 'trim', 'keep'],
|
|
68
|
+
},
|
|
62
69
|
partitionByComment: {
|
|
63
70
|
description:
|
|
64
71
|
'Allows to use comments to separate the class members into logical groups.',
|
|
@@ -170,6 +177,7 @@ const sortClasses = createEslintRule({
|
|
|
170
177
|
type: 'alphabetical',
|
|
171
178
|
order: 'asc',
|
|
172
179
|
ignoreCase: true,
|
|
180
|
+
specialCharacters: 'keep',
|
|
173
181
|
matcher: 'minimatch',
|
|
174
182
|
partitionByComment: false,
|
|
175
183
|
groups: [
|
|
@@ -215,9 +223,11 @@ const sortClasses = createEslintRule({
|
|
|
215
223
|
partitionByComment: false,
|
|
216
224
|
type: 'alphabetical',
|
|
217
225
|
ignoreCase: true,
|
|
226
|
+
specialCharacters: 'keep',
|
|
218
227
|
customGroups: [],
|
|
219
228
|
order: 'asc',
|
|
220
229
|
})
|
|
230
|
+
validateGroupsConfiguration(options.groups, options.customGroups)
|
|
221
231
|
let sourceCode = getSourceCode(context)
|
|
222
232
|
let className = (_a = node.parent.id) == null ? void 0 : _a.name
|
|
223
233
|
let getDependencyName = (nodeName, isStatic) =>
|
|
@@ -239,12 +249,6 @@ const sortClasses = createEslintRule({
|
|
|
239
249
|
let extractDependencies = (expression, isMemberStatic) => {
|
|
240
250
|
let dependencies = []
|
|
241
251
|
let checkNode = nodeValue => {
|
|
242
|
-
if (
|
|
243
|
-
nodeValue.type === 'ArrowFunctionExpression' ||
|
|
244
|
-
nodeValue.type === 'FunctionExpression'
|
|
245
|
-
) {
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
252
|
if (
|
|
249
253
|
nodeValue.type === 'MemberExpression' &&
|
|
250
254
|
(nodeValue.object.type === 'ThisExpression' ||
|
|
@@ -375,6 +379,7 @@ const sortClasses = createEslintRule({
|
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
}
|
|
382
|
+
let memberValue
|
|
378
383
|
let modifiers = []
|
|
379
384
|
let selectors = []
|
|
380
385
|
if (
|
|
@@ -485,6 +490,9 @@ const sortClasses = createEslintRule({
|
|
|
485
490
|
if (isFunctionProperty) {
|
|
486
491
|
selectors.push('function-property')
|
|
487
492
|
}
|
|
493
|
+
if (!isFunctionProperty && member.value) {
|
|
494
|
+
memberValue = sourceCode.getText(member.value)
|
|
495
|
+
}
|
|
488
496
|
selectors.push('property')
|
|
489
497
|
if (
|
|
490
498
|
member.type === 'PropertyDefinition' &&
|
|
@@ -506,6 +514,7 @@ const sortClasses = createEslintRule({
|
|
|
506
514
|
customGroupMatches({
|
|
507
515
|
customGroup,
|
|
508
516
|
elementName: name,
|
|
517
|
+
elementValue: memberValue,
|
|
509
518
|
modifiers,
|
|
510
519
|
selectors,
|
|
511
520
|
decorators,
|
|
@@ -529,7 +538,7 @@ const sortClasses = createEslintRule({
|
|
|
529
538
|
)) == null
|
|
530
539
|
? void 0
|
|
531
540
|
: _d.at(-1)
|
|
532
|
-
let
|
|
541
|
+
let sortingNode = {
|
|
533
542
|
size: overloadSignatureGroupMember
|
|
534
543
|
? rangeToDiff(overloadSignatureGroupMember.range)
|
|
535
544
|
: rangeToDiff(member.range),
|
|
@@ -542,46 +551,22 @@ const sortClasses = createEslintRule({
|
|
|
542
551
|
modifiers.includes('static'),
|
|
543
552
|
),
|
|
544
553
|
}
|
|
545
|
-
accumulator.at(-1).push(
|
|
554
|
+
accumulator.at(-1).push(sortingNode)
|
|
546
555
|
return accumulator
|
|
547
556
|
},
|
|
548
557
|
[[]],
|
|
549
558
|
)
|
|
550
|
-
let sortedNodes =
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
nodesByNonIgnoredGroupNumber[groupNum] ?? []
|
|
562
|
-
nodesByNonIgnoredGroupNumber[groupNum].push(sortingNode)
|
|
563
|
-
}
|
|
564
|
-
for (let groupNumber of Object.keys(
|
|
565
|
-
nodesByNonIgnoredGroupNumber,
|
|
566
|
-
).sort((a, b) => Number(a) - Number(b))) {
|
|
567
|
-
let compareOptions = getCompareOptions(options, Number(groupNumber))
|
|
568
|
-
if (!compareOptions) {
|
|
569
|
-
sortedNodes.push(
|
|
570
|
-
...nodesByNonIgnoredGroupNumber[Number(groupNumber)],
|
|
571
|
-
)
|
|
572
|
-
} else {
|
|
573
|
-
sortedNodes.push(
|
|
574
|
-
...sortNodes(
|
|
575
|
-
nodesByNonIgnoredGroupNumber[Number(groupNumber)],
|
|
576
|
-
compareOptions,
|
|
577
|
-
),
|
|
578
|
-
)
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
for (let ignoredIndex of ignoredNodeIndices) {
|
|
582
|
-
sortedNodes.splice(ignoredIndex, 0, nodes2[ignoredIndex])
|
|
583
|
-
}
|
|
584
|
-
}
|
|
559
|
+
let sortedNodes = formattedNodes
|
|
560
|
+
.map(nodes2 =>
|
|
561
|
+
sortNodesByGroups(nodes2, options, {
|
|
562
|
+
getGroupCompareOptions: groupNumber =>
|
|
563
|
+
getCompareOptions(options, groupNumber),
|
|
564
|
+
isNodeIgnored: sortingNode =>
|
|
565
|
+
getGroupNumber(options.groups, sortingNode) ===
|
|
566
|
+
options.groups.length,
|
|
567
|
+
}),
|
|
568
|
+
)
|
|
569
|
+
.flat()
|
|
585
570
|
sortedNodes = sortNodesByDependencies(sortedNodes)
|
|
586
571
|
let nodes = formattedNodes.flat()
|
|
587
572
|
pairwise(nodes, (left, right) => {
|
|
@@ -59,6 +59,10 @@ const singleCustomGroupJsonSchema = {
|
|
|
59
59
|
description: 'Element name pattern filter.',
|
|
60
60
|
type: 'string',
|
|
61
61
|
},
|
|
62
|
+
elementValuePattern: {
|
|
63
|
+
description: 'Element value pattern filter for properties.',
|
|
64
|
+
type: 'string',
|
|
65
|
+
},
|
|
62
66
|
decoratorNamePattern: {
|
|
63
67
|
description: 'Decorator name pattern filter.',
|
|
64
68
|
type: 'string',
|
|
@@ -57,6 +57,10 @@ const singleCustomGroupJsonSchema = {
|
|
|
57
57
|
description: 'Element name pattern filter.',
|
|
58
58
|
type: 'string',
|
|
59
59
|
},
|
|
60
|
+
elementValuePattern: {
|
|
61
|
+
description: 'Element value pattern filter for properties.',
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
60
64
|
decoratorNamePattern: {
|
|
61
65
|
description: 'Decorator name pattern filter.',
|
|
62
66
|
type: 'string',
|
package/dist/rules/sort-enums.js
CHANGED
|
@@ -45,6 +45,12 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
45
45
|
'Controls whether sorting should be case-sensitive or not.',
|
|
46
46
|
type: 'boolean',
|
|
47
47
|
},
|
|
48
|
+
specialCharacters: {
|
|
49
|
+
description:
|
|
50
|
+
'Controls how special characters should be handled before sorting.',
|
|
51
|
+
type: 'string',
|
|
52
|
+
enum: ['remove', 'trim', 'keep'],
|
|
53
|
+
},
|
|
48
54
|
sortByValue: {
|
|
49
55
|
description: 'Compare enum values instead of names.',
|
|
50
56
|
type: 'boolean',
|
|
@@ -92,6 +98,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
92
98
|
type: 'alphabetical',
|
|
93
99
|
order: 'asc',
|
|
94
100
|
ignoreCase: true,
|
|
101
|
+
specialCharacters: 'keep',
|
|
95
102
|
matcher: 'minimatch',
|
|
96
103
|
sortByValue: false,
|
|
97
104
|
partitionByComment: false,
|
|
@@ -123,6 +130,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
123
130
|
type: 'alphabetical',
|
|
124
131
|
matcher: 'minimatch',
|
|
125
132
|
ignoreCase: true,
|
|
133
|
+
specialCharacters: 'keep',
|
|
126
134
|
order: 'asc',
|
|
127
135
|
sortByValue: false,
|
|
128
136
|
forceNumericSort: false,
|
|
@@ -213,6 +221,7 @@ const sortEnums = createEslintRule.createEslintRule({
|
|
|
213
221
|
: options.type,
|
|
214
222
|
order: options.order,
|
|
215
223
|
ignoreCase: options.ignoreCase,
|
|
224
|
+
specialCharacters: options.specialCharacters,
|
|
216
225
|
// Get the enum value rather than the name if needed
|
|
217
226
|
nodeValueGetter:
|
|
218
227
|
options.sortByValue || (isNumericEnum && options.forceNumericSort)
|
|
@@ -47,6 +47,12 @@ const sortEnums = createEslintRule({
|
|
|
47
47
|
'Controls whether sorting should be case-sensitive or not.',
|
|
48
48
|
type: 'boolean',
|
|
49
49
|
},
|
|
50
|
+
specialCharacters: {
|
|
51
|
+
description:
|
|
52
|
+
'Controls how special characters should be handled before sorting.',
|
|
53
|
+
type: 'string',
|
|
54
|
+
enum: ['remove', 'trim', 'keep'],
|
|
55
|
+
},
|
|
50
56
|
sortByValue: {
|
|
51
57
|
description: 'Compare enum values instead of names.',
|
|
52
58
|
type: 'boolean',
|
|
@@ -94,6 +100,7 @@ const sortEnums = createEslintRule({
|
|
|
94
100
|
type: 'alphabetical',
|
|
95
101
|
order: 'asc',
|
|
96
102
|
ignoreCase: true,
|
|
103
|
+
specialCharacters: 'keep',
|
|
97
104
|
matcher: 'minimatch',
|
|
98
105
|
sortByValue: false,
|
|
99
106
|
partitionByComment: false,
|
|
@@ -125,6 +132,7 @@ const sortEnums = createEslintRule({
|
|
|
125
132
|
type: 'alphabetical',
|
|
126
133
|
matcher: 'minimatch',
|
|
127
134
|
ignoreCase: true,
|
|
135
|
+
specialCharacters: 'keep',
|
|
128
136
|
order: 'asc',
|
|
129
137
|
sortByValue: false,
|
|
130
138
|
forceNumericSort: false,
|
|
@@ -211,6 +219,7 @@ const sortEnums = createEslintRule({
|
|
|
211
219
|
: options.type,
|
|
212
220
|
order: options.order,
|
|
213
221
|
ignoreCase: options.ignoreCase,
|
|
222
|
+
specialCharacters: options.specialCharacters,
|
|
214
223
|
// Get the enum value rather than the name if needed
|
|
215
224
|
nodeValueGetter:
|
|
216
225
|
options.sortByValue || (isNumericEnum && options.forceNumericSort)
|
|
@@ -43,6 +43,12 @@ const sortExports = createEslintRule.createEslintRule({
|
|
|
43
43
|
'Controls whether sorting should be case-sensitive or not.',
|
|
44
44
|
type: 'boolean',
|
|
45
45
|
},
|
|
46
|
+
specialCharacters: {
|
|
47
|
+
description:
|
|
48
|
+
'Controls how special characters should be handled before sorting.',
|
|
49
|
+
type: 'string',
|
|
50
|
+
enum: ['remove', 'trim', 'keep'],
|
|
51
|
+
},
|
|
46
52
|
partitionByComment: {
|
|
47
53
|
description:
|
|
48
54
|
'Allows you to use comments to separate the exports into logical groups.',
|
|
@@ -84,6 +90,7 @@ const sortExports = createEslintRule.createEslintRule({
|
|
|
84
90
|
type: 'alphabetical',
|
|
85
91
|
order: 'asc',
|
|
86
92
|
ignoreCase: true,
|
|
93
|
+
specialCharacters: 'keep',
|
|
87
94
|
matcher: 'minimatch',
|
|
88
95
|
partitionByComment: false,
|
|
89
96
|
partitionByNewLine: false,
|
|
@@ -95,6 +102,7 @@ const sortExports = createEslintRule.createEslintRule({
|
|
|
95
102
|
let options = complete.complete(context.options.at(0), settings, {
|
|
96
103
|
type: 'alphabetical',
|
|
97
104
|
ignoreCase: true,
|
|
105
|
+
specialCharacters: 'keep',
|
|
98
106
|
order: 'asc',
|
|
99
107
|
matcher: 'minimatch',
|
|
100
108
|
partitionByComment: false,
|
|
@@ -42,6 +42,12 @@ const sortExports = createEslintRule({
|
|
|
42
42
|
'Controls whether sorting should be case-sensitive or not.',
|
|
43
43
|
type: 'boolean',
|
|
44
44
|
},
|
|
45
|
+
specialCharacters: {
|
|
46
|
+
description:
|
|
47
|
+
'Controls how special characters should be handled before sorting.',
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: ['remove', 'trim', 'keep'],
|
|
50
|
+
},
|
|
45
51
|
partitionByComment: {
|
|
46
52
|
description:
|
|
47
53
|
'Allows you to use comments to separate the exports into logical groups.',
|
|
@@ -83,6 +89,7 @@ const sortExports = createEslintRule({
|
|
|
83
89
|
type: 'alphabetical',
|
|
84
90
|
order: 'asc',
|
|
85
91
|
ignoreCase: true,
|
|
92
|
+
specialCharacters: 'keep',
|
|
86
93
|
matcher: 'minimatch',
|
|
87
94
|
partitionByComment: false,
|
|
88
95
|
partitionByNewLine: false,
|
|
@@ -94,6 +101,7 @@ const sortExports = createEslintRule({
|
|
|
94
101
|
let options = complete(context.options.at(0), settings, {
|
|
95
102
|
type: 'alphabetical',
|
|
96
103
|
ignoreCase: true,
|
|
104
|
+
specialCharacters: 'keep',
|
|
97
105
|
order: 'asc',
|
|
98
106
|
matcher: 'minimatch',
|
|
99
107
|
partitionByComment: false,
|