eslint-plugin-perfectionist 4.1.2 → 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.
Files changed (44) hide show
  1. package/dist/alphabet.d.ts +176 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +9 -1
  4. package/dist/rules/sort-array-includes.js +6 -1
  5. package/dist/rules/sort-classes-utils.js +0 -23
  6. package/dist/rules/sort-classes.js +19 -43
  7. package/dist/rules/sort-classes.types.js +5 -37
  8. package/dist/rules/sort-decorators.js +9 -1
  9. package/dist/rules/sort-enums.js +11 -1
  10. package/dist/rules/sort-exports.js +8 -1
  11. package/dist/rules/sort-heritage-clauses.js +4 -0
  12. package/dist/rules/sort-imports.js +8 -3
  13. package/dist/rules/sort-interfaces.js +17 -260
  14. package/dist/rules/sort-intersection-types.js +9 -1
  15. package/dist/rules/sort-jsx-props.js +4 -0
  16. package/dist/rules/sort-maps.js +8 -1
  17. package/dist/rules/sort-modules-utils.js +0 -23
  18. package/dist/rules/sort-modules.js +20 -44
  19. package/dist/rules/sort-modules.types.js +5 -41
  20. package/dist/rules/sort-named-exports.js +8 -1
  21. package/dist/rules/sort-named-imports.js +8 -1
  22. package/dist/rules/sort-object-types-utils.js +37 -0
  23. package/dist/rules/sort-object-types.js +345 -223
  24. package/dist/rules/sort-object-types.types.js +20 -0
  25. package/dist/rules/sort-objects.js +36 -10
  26. package/dist/rules/sort-switch-case.js +4 -0
  27. package/dist/rules/sort-union-types.js +9 -1
  28. package/dist/rules/sort-variable-declarations.js +8 -1
  29. package/dist/utils/alphabet.js +385 -0
  30. package/dist/utils/common-json-schemas.js +94 -1
  31. package/dist/utils/compare.js +88 -39
  32. package/dist/utils/convert-boolean-to-sign.js +4 -0
  33. package/dist/utils/get-comments-before.js +4 -4
  34. package/dist/utils/get-custom-groups-compare-options.js +29 -0
  35. package/dist/utils/get-matching-context-options.js +18 -0
  36. package/dist/utils/get-node-range.js +18 -7
  37. package/dist/utils/get-settings.js +1 -0
  38. package/dist/utils/is-node-function-type.js +15 -0
  39. package/dist/utils/make-fixes.js +24 -3
  40. package/dist/utils/make-newlines-fixes.js +7 -4
  41. package/dist/utils/validate-custom-sort-configuration.js +11 -0
  42. package/dist/{rules → utils}/validate-generated-groups-configuration.js +4 -2
  43. package/package.json +9 -5
  44. 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
@@ -28,7 +28,7 @@ let plugin = {
28
28
  'sort-array-includes': sortArrayIncludes.default,
29
29
  'sort-named-imports': sortNamedImports,
30
30
  'sort-named-exports': sortNamedExports,
31
- 'sort-object-types': sortObjectTypes,
31
+ 'sort-object-types': sortObjectTypes.default,
32
32
  'sort-union-types': sortUnionTypes,
33
33
  'sort-switch-case': sortSwitchCase,
34
34
  'sort-decorators': sortDecorators,
@@ -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,
@@ -129,7 +131,10 @@ let sortArray = (context, messageId, elements) => {
129
131
  (options.partitionByComment &&
130
132
  isPartitionComment.hasPartitionComment(
131
133
  options.partitionByComment,
132
- getCommentsBefore.getCommentsBefore(element, sourceCode),
134
+ getCommentsBefore.getCommentsBefore({
135
+ node: element,
136
+ sourceCode,
137
+ }),
133
138
  )) ||
134
139
  (options.partitionByNewLine &&
135
140
  lastSortingNode &&
@@ -89,28 +89,5 @@ let customGroupMatches = props => {
89
89
  }
90
90
  return true
91
91
  }
92
- let getCompareOptions = (options, groupNumber) => {
93
- let group = options.groups[groupNumber]
94
- let customGroup =
95
- typeof group === 'string'
96
- ? options.customGroups.find(
97
- currentGroup => group === currentGroup.groupName,
98
- )
99
- : null
100
- if ((customGroup == null ? void 0 : customGroup.type) === 'unsorted') {
101
- return null
102
- }
103
- return {
104
- order:
105
- customGroup && 'order' in customGroup && customGroup.order
106
- ? customGroup.order
107
- : options.order,
108
- specialCharacters: options.specialCharacters,
109
- type: (customGroup == null ? void 0 : customGroup.type) ?? options.type,
110
- ignoreCase: options.ignoreCase,
111
- locales: options.locales,
112
- }
113
- }
114
92
  exports.customGroupMatches = customGroupMatches
115
- exports.getCompareOptions = getCompareOptions
116
93
  exports.getOverloadSignatureGroups = getOverloadSignatureGroups
@@ -1,10 +1,12 @@
1
1
  'use strict'
2
2
  const commonJsonSchemas = require('../utils/common-json-schemas.js')
3
- const sortClasses_types = require('./sort-classes.types.js')
4
3
  const sortNodesByDependencies = require('../utils/sort-nodes-by-dependencies.js')
5
4
  const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
5
+ const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
6
+ const sortClasses_types = require('./sort-classes.types.js')
7
+ const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
6
8
  const sortClassesUtils = require('./sort-classes-utils.js')
7
- const validateGeneratedGroupsConfiguration = require('./validate-generated-groups-configuration.js')
9
+ const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
8
10
  const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
9
11
  const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
10
12
  const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
@@ -61,6 +63,7 @@ let defaultOptions = {
61
63
  ignoreCase: true,
62
64
  customGroups: [],
63
65
  locales: 'en-US',
66
+ alphabet: '',
64
67
  order: 'asc',
65
68
  }
66
69
  const sortClasses = createEslintRule.createEslintRule({
@@ -76,6 +79,7 @@ const sortClasses = createEslintRule.createEslintRule({
76
79
  settings,
77
80
  defaultOptions,
78
81
  )
82
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
79
83
  validateGeneratedGroupsConfiguration.validateGeneratedGroupsConfiguration(
80
84
  {
81
85
  customGroups: options.customGroups,
@@ -446,7 +450,6 @@ const sortClasses = createEslintRule.createEslintRule({
446
450
  dependencies,
447
451
  name,
448
452
  }
449
- let comments = getCommentsBefore.getCommentsBefore(member, sourceCode)
450
453
  let lastMember =
451
454
  (_e = accumulator.at(-1)) == null ? void 0 : _e.at(-1)
452
455
  if (
@@ -460,7 +463,10 @@ const sortClasses = createEslintRule.createEslintRule({
460
463
  (options.partitionByComment &&
461
464
  isPartitionComment.hasPartitionComment(
462
465
  options.partitionByComment,
463
- comments,
466
+ getCommentsBefore.getCommentsBefore({
467
+ node: member,
468
+ sourceCode,
469
+ }),
464
470
  ))
465
471
  ) {
466
472
  accumulator.push([])
@@ -478,7 +484,10 @@ const sortClasses = createEslintRule.createEslintRule({
478
484
  getGroupNumber.getGroupNumber(options.groups, sortingNode) ===
479
485
  options.groups.length,
480
486
  getGroupCompareOptions: groupNumber =>
481
- sortClassesUtils.getCompareOptions(options, groupNumber),
487
+ getCustomGroupsCompareOptions.getCustomGroupsCompareOptions(
488
+ options,
489
+ groupNumber,
490
+ ),
482
491
  ignoreEslintDisabledNodes,
483
492
  }),
484
493
  ),
@@ -567,44 +576,6 @@ const sortClasses = createEslintRule.createEslintRule({
567
576
  schema: [
568
577
  {
569
578
  properties: {
570
- customGroups: {
571
- items: {
572
- oneOf: [
573
- {
574
- properties: {
575
- ...sortClasses_types.customGroupNameJsonSchema,
576
- ...sortClasses_types.customGroupSortJsonSchema,
577
- anyOf: {
578
- items: {
579
- properties: {
580
- ...sortClasses_types.singleCustomGroupJsonSchema,
581
- },
582
- description: 'Custom group.',
583
- additionalProperties: false,
584
- type: 'object',
585
- },
586
- type: 'array',
587
- },
588
- },
589
- description: 'Custom group block.',
590
- additionalProperties: false,
591
- type: 'object',
592
- },
593
- {
594
- properties: {
595
- ...sortClasses_types.customGroupNameJsonSchema,
596
- ...sortClasses_types.customGroupSortJsonSchema,
597
- ...sortClasses_types.singleCustomGroupJsonSchema,
598
- },
599
- description: 'Custom group.',
600
- additionalProperties: false,
601
- type: 'object',
602
- },
603
- ],
604
- },
605
- description: 'Specifies custom groups.',
606
- type: 'array',
607
- },
608
579
  ignoreCallbackDependenciesPatterns: {
609
580
  description:
610
581
  'Patterns that should be ignored when detecting dependencies in method callbacks.',
@@ -618,10 +589,15 @@ const sortClasses = createEslintRule.createEslintRule({
618
589
  description:
619
590
  'Allows to use comments to separate the class members into logical groups.',
620
591
  },
592
+ customGroups: commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
593
+ singleCustomGroupJsonSchema:
594
+ sortClasses_types.singleCustomGroupJsonSchema,
595
+ }),
621
596
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
622
597
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
623
598
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
624
599
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
600
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
625
601
  locales: commonJsonSchemas.localesJsonSchema,
626
602
  groups: commonJsonSchemas.groupsJsonSchema,
627
603
  order: commonJsonSchemas.orderJsonSchema,
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
3
+ const commonJsonSchemas = require('../utils/common-json-schemas.js')
3
4
  let allSelectors = [
4
5
  'accessor-property',
5
6
  'index-signature',
@@ -24,33 +25,7 @@ let allModifiers = [
24
25
  'declare',
25
26
  'optional',
26
27
  ]
27
- let customGroupSortJsonSchema = {
28
- type: {
29
- enum: ['alphabetical', 'line-length', 'natural', 'unsorted'],
30
- description: 'Custom group sort type.',
31
- type: 'string',
32
- },
33
- order: {
34
- description: 'Custom group sort order.',
35
- enum: ['desc', 'asc'],
36
- type: 'string',
37
- },
38
- }
39
- let customGroupNameJsonSchema = {
40
- groupName: {
41
- description: 'Custom group name.',
42
- type: 'string',
43
- },
44
- }
45
28
  let singleCustomGroupJsonSchema = {
46
- modifiers: {
47
- items: {
48
- enum: allModifiers,
49
- type: 'string',
50
- },
51
- description: 'Modifier filters.',
52
- type: 'array',
53
- },
54
29
  elementValuePattern: {
55
30
  description: 'Element value pattern filter for properties.',
56
31
  type: 'string',
@@ -59,18 +34,11 @@ let singleCustomGroupJsonSchema = {
59
34
  description: 'Decorator name pattern filter.',
60
35
  type: 'string',
61
36
  },
62
- selector: {
63
- description: 'Selector filter.',
64
- enum: allSelectors,
65
- type: 'string',
66
- },
67
- elementNamePattern: {
68
- description: 'Element name pattern filter.',
69
- type: 'string',
70
- },
37
+ modifiers:
38
+ commonJsonSchemas.buildCustomGroupModifiersJsonSchema(allModifiers),
39
+ selector: commonJsonSchemas.buildCustomGroupSelectorJsonSchema(allSelectors),
40
+ elementNamePattern: commonJsonSchemas.elementNamePatternJsonSchema,
71
41
  }
72
42
  exports.allModifiers = allModifiers
73
43
  exports.allSelectors = allSelectors
74
- exports.customGroupNameJsonSchema = customGroupNameJsonSchema
75
- exports.customGroupSortJsonSchema = customGroupSortJsonSchema
76
44
  exports.singleCustomGroupJsonSchema = singleCustomGroupJsonSchema
@@ -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'],
@@ -176,7 +180,10 @@ let sortDecorators$1 = (context, options, decorators) => {
176
180
  options.partitionByComment &&
177
181
  isPartitionComment.hasPartitionComment(
178
182
  options.partitionByComment,
179
- getCommentsBefore.getCommentsBefore(decorator, sourceCode),
183
+ getCommentsBefore.getCommentsBefore({
184
+ node: decorator,
185
+ sourceCode,
186
+ }),
180
187
  )
181
188
  ) {
182
189
  accumulator.push([])
@@ -226,6 +233,7 @@ let sortDecorators$1 = (context, options, decorators) => {
226
233
  fix: fixer =>
227
234
  makeFixes.makeFixes({
228
235
  sortedNodes: sortedNodesExcludingEslintDisabled,
236
+ ignoreFirstNodeHighestBlockComment: true,
229
237
  sourceCode,
230
238
  options,
231
239
  fixer,
@@ -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,
@@ -109,7 +112,10 @@ const sortEnums = createEslintRule.createEslintRule({
109
112
  (options.partitionByComment &&
110
113
  isPartitionComment.hasPartitionComment(
111
114
  options.partitionByComment,
112
- getCommentsBefore.getCommentsBefore(member, sourceCode),
115
+ getCommentsBefore.getCommentsBefore({
116
+ node: member,
117
+ sourceCode,
118
+ }),
113
119
  )) ||
114
120
  (options.partitionByNewLine &&
115
121
  lastSortingNode &&
@@ -162,6 +168,7 @@ const sortEnums = createEslintRule.createEslintRule({
162
168
  : options.type,
163
169
  specialCharacters: options.specialCharacters,
164
170
  ignoreCase: options.ignoreCase,
171
+ alphabet: options.alphabet,
165
172
  locales: options.locales,
166
173
  order: options.order,
167
174
  }
@@ -241,6 +248,7 @@ const sortEnums = createEslintRule.createEslintRule({
241
248
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
242
249
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
243
250
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
251
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
244
252
  locales: commonJsonSchemas.localesJsonSchema,
245
253
  order: commonJsonSchemas.orderJsonSchema,
246
254
  type: commonJsonSchemas.typeJsonSchema,
@@ -295,6 +303,7 @@ let getUnaryExpressionNumberValue = (argumentExpression, operator) => {
295
303
  return -argument
296
304
  case '~':
297
305
  return ~argument
306
+ /* v8 ignore next 2 - Unsure if we can reach it */
298
307
  default:
299
308
  return Number.NaN
300
309
  }
@@ -329,6 +338,7 @@ let getBinaryExpressionNumberValue = (
329
338
  return left & right
330
339
  case '^':
331
340
  return left ^ right
341
+ /* v8 ignore next 2 - Unsure if we can reach it */
332
342
  default:
333
343
  return Number.NaN
334
344
  }
@@ -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({
@@ -56,7 +59,10 @@ const sortExports = createEslintRule.createEslintRule({
56
59
  (partitionComment &&
57
60
  isPartitionComment.hasPartitionComment(
58
61
  partitionComment,
59
- getCommentsBefore.getCommentsBefore(node, sourceCode),
62
+ getCommentsBefore.getCommentsBefore({
63
+ sourceCode,
64
+ node,
65
+ }),
60
66
  )) ||
61
67
  (options.partitionByNewLine &&
62
68
  lastNode &&
@@ -147,6 +153,7 @@ const sortExports = createEslintRule.createEslintRule({
147
153
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
148
154
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
149
155
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
156
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
150
157
  locales: commonJsonSchemas.localesJsonSchema,
151
158
  order: commonJsonSchemas.orderJsonSchema,
152
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'],