eslint-plugin-perfectionist 4.2.0 → 4.4.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 (42) hide show
  1. package/dist/alphabet.d.ts +176 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +8 -0
  4. package/dist/rules/sort-array-includes-utils.js +30 -0
  5. package/dist/rules/sort-array-includes.js +150 -54
  6. package/dist/rules/sort-array-includes.types.js +10 -0
  7. package/dist/rules/sort-classes.js +19 -16
  8. package/dist/rules/sort-decorators.js +11 -6
  9. package/dist/rules/sort-enums.js +39 -31
  10. package/dist/rules/sort-exports.js +11 -5
  11. package/dist/rules/sort-heritage-clauses.js +12 -6
  12. package/dist/rules/sort-imports.js +34 -21
  13. package/dist/rules/sort-interfaces.js +3 -1
  14. package/dist/rules/sort-intersection-types.js +24 -19
  15. package/dist/rules/sort-jsx-props.js +12 -7
  16. package/dist/rules/sort-maps.js +18 -13
  17. package/dist/rules/sort-modules.js +23 -18
  18. package/dist/rules/sort-named-exports.js +18 -13
  19. package/dist/rules/sort-named-imports.js +18 -13
  20. package/dist/rules/sort-object-types.js +149 -103
  21. package/dist/rules/sort-objects.js +142 -58
  22. package/dist/rules/sort-sets.js +14 -5
  23. package/dist/rules/sort-switch-case.js +16 -14
  24. package/dist/rules/sort-union-types.js +24 -19
  25. package/dist/rules/sort-variable-declarations.js +18 -13
  26. package/dist/utils/alphabet.js +385 -0
  27. package/dist/utils/common-json-schemas.js +27 -5
  28. package/dist/utils/compare.js +88 -38
  29. package/dist/utils/convert-boolean-to-sign.js +4 -0
  30. package/dist/utils/create-node-index-map.js +10 -0
  31. package/dist/{rules → utils}/get-custom-groups-compare-options.js +1 -0
  32. package/dist/utils/{get-node-parent.js → get-first-node-parent-with-type.js} +3 -4
  33. package/dist/utils/get-matching-context-options.js +18 -0
  34. package/dist/utils/get-settings.js +1 -0
  35. package/dist/utils/is-node-function-type.js +15 -0
  36. package/dist/utils/is-partition-comment.js +4 -1
  37. package/dist/utils/pairwise.js +1 -3
  38. package/dist/utils/validate-custom-sort-configuration.js +11 -0
  39. package/dist/{rules → utils}/validate-generated-groups-configuration.js +1 -1
  40. package/dist/utils/validate-groups-configuration.js +11 -5
  41. package/package.json +7 -3
  42. package/readme.md +4 -3
@@ -1,8 +1,10 @@
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')
7
+ const createNodeIndexMap = require('../utils/create-node-index-map.js')
6
8
  const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
7
9
  const createEslintRule = require('../utils/create-eslint-rule.js')
8
10
  const getGroupNumber = require('../utils/get-group-number.js')
@@ -22,6 +24,7 @@ let defaultOptions = {
22
24
  ignoreCase: true,
23
25
  customGroups: {},
24
26
  locales: 'en-US',
27
+ alphabet: '',
25
28
  order: 'asc',
26
29
  groups: [],
27
30
  }
@@ -37,6 +40,7 @@ const sortJsxProps = createEslintRule.createEslintRule({
37
40
  settings,
38
41
  defaultOptions,
39
42
  )
43
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
40
44
  validateGroupsConfiguration.validateGroupsConfiguration(
41
45
  options.groups,
42
46
  ['multiline', 'shorthand', 'unknown'],
@@ -75,8 +79,7 @@ const sortJsxProps = createEslintRule.createEslintRule({
75
79
  setCustomGroups(options.customGroups, name)
76
80
  if (attribute.value === null) {
77
81
  defineGroup('shorthand')
78
- }
79
- if (attribute.loc.start.line !== attribute.loc.end.line) {
82
+ } else if (attribute.loc.start.line !== attribute.loc.end.line) {
80
83
  defineGroup('multiline')
81
84
  }
82
85
  let jsxNode = {
@@ -102,14 +105,15 @@ const sortJsxProps = createEslintRule.createEslintRule({
102
105
  let sortedNodes = sortNodesExcludingEslintDisabled(false)
103
106
  let sortedNodesExcludingEslintDisabled =
104
107
  sortNodesExcludingEslintDisabled(true)
108
+ let nodeIndexMap = createNodeIndexMap.createNodeIndexMap(sortedNodes)
105
109
  pairwise.pairwise(nodes, (left, right) => {
106
- let indexOfLeft = sortedNodes.indexOf(left)
107
- let indexOfRight = sortedNodes.indexOf(right)
110
+ let leftIndex = nodeIndexMap.get(left)
111
+ let rightIndex = nodeIndexMap.get(right)
108
112
  let indexOfRightExcludingEslintDisabled =
109
113
  sortedNodesExcludingEslintDisabled.indexOf(right)
110
114
  if (
111
- indexOfLeft < indexOfRight &&
112
- indexOfLeft < indexOfRightExcludingEslintDisabled
115
+ leftIndex < rightIndex &&
116
+ leftIndex < indexOfRightExcludingEslintDisabled
113
117
  ) {
114
118
  return
115
119
  }
@@ -154,10 +158,11 @@ const sortJsxProps = createEslintRule.createEslintRule({
154
158
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
155
159
  customGroups: commonJsonSchemas.customGroupsJsonSchema,
156
160
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
161
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
162
+ type: commonJsonSchemas.buildTypeJsonSchema(),
157
163
  locales: commonJsonSchemas.localesJsonSchema,
158
164
  groups: commonJsonSchemas.groupsJsonSchema,
159
165
  order: commonJsonSchemas.orderJsonSchema,
160
- type: commonJsonSchemas.typeJsonSchema,
161
166
  },
162
167
  additionalProperties: false,
163
168
  type: 'object',
@@ -1,7 +1,9 @@
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')
6
+ const createNodeIndexMap = require('../utils/create-node-index-map.js')
5
7
  const isPartitionComment = require('../utils/is-partition-comment.js')
6
8
  const getCommentsBefore = require('../utils/get-comments-before.js')
7
9
  const createEslintRule = require('../utils/create-eslint-rule.js')
@@ -22,6 +24,7 @@ let defaultOptions = {
22
24
  type: 'alphabetical',
23
25
  ignoreCase: true,
24
26
  locales: 'en-US',
27
+ alphabet: '',
25
28
  order: 'asc',
26
29
  }
27
30
  const sortMaps = createEslintRule.createEslintRule({
@@ -47,6 +50,7 @@ const sortMaps = createEslintRule.createEslintRule({
47
50
  settings,
48
51
  defaultOptions,
49
52
  )
53
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
50
54
  let sourceCode = getSourceCode.getSourceCode(context)
51
55
  let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
52
56
  ruleName: context.id,
@@ -91,14 +95,13 @@ const sortMaps = createEslintRule.createEslintRule({
91
95
  name,
92
96
  }
93
97
  if (
94
- (options.partitionByComment &&
95
- isPartitionComment.hasPartitionComment(
96
- options.partitionByComment,
97
- getCommentsBefore.getCommentsBefore({
98
- node: element,
99
- sourceCode,
100
- }),
101
- )) ||
98
+ isPartitionComment.hasPartitionComment(
99
+ options.partitionByComment,
100
+ getCommentsBefore.getCommentsBefore({
101
+ node: element,
102
+ sourceCode,
103
+ }),
104
+ ) ||
102
105
  (options.partitionByNewLine &&
103
106
  lastSortingNode &&
104
107
  getLinesBetween.getLinesBetween(
@@ -117,14 +120,15 @@ const sortMaps = createEslintRule.createEslintRule({
117
120
  let sortedNodes = sortNodesExcludingEslintDisabled(false)
118
121
  let sortedNodesExcludingEslintDisabled =
119
122
  sortNodesExcludingEslintDisabled(true)
123
+ let nodeIndexMap = createNodeIndexMap.createNodeIndexMap(sortedNodes)
120
124
  pairwise.pairwise(nodes, (left, right) => {
121
- let indexOfLeft = sortedNodes.indexOf(left)
122
- let indexOfRight = sortedNodes.indexOf(right)
125
+ let leftIndex = nodeIndexMap.get(left)
126
+ let rightIndex = nodeIndexMap.get(right)
123
127
  let indexOfRightExcludingEslintDisabled =
124
128
  sortedNodesExcludingEslintDisabled.indexOf(right)
125
129
  if (
126
- indexOfLeft < indexOfRight &&
127
- indexOfLeft < indexOfRightExcludingEslintDisabled
130
+ leftIndex < rightIndex &&
131
+ leftIndex < indexOfRightExcludingEslintDisabled
128
132
  ) {
129
133
  return
130
134
  }
@@ -161,9 +165,10 @@ const sortMaps = createEslintRule.createEslintRule({
161
165
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
162
166
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
163
167
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
168
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
169
+ type: commonJsonSchemas.buildTypeJsonSchema(),
164
170
  locales: commonJsonSchemas.localesJsonSchema,
165
171
  order: commonJsonSchemas.orderJsonSchema,
166
- type: commonJsonSchemas.typeJsonSchema,
167
172
  },
168
173
  additionalProperties: false,
169
174
  type: 'object',
@@ -3,12 +3,14 @@ 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 validateGeneratedGroupsConfiguration = require('./validate-generated-groups-configuration.js')
8
- const getCustomGroupsCompareOptions = require('./get-custom-groups-compare-options.js')
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')
13
+ const createNodeIndexMap = require('../utils/create-node-index-map.js')
12
14
  const isPartitionComment = require('../utils/is-partition-comment.js')
13
15
  const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
14
16
  const getNewlinesErrors = require('../utils/get-newlines-errors.js')
@@ -53,6 +55,7 @@ let defaultOptions = {
53
55
  ignoreCase: true,
54
56
  customGroups: [],
55
57
  locales: 'en-US',
58
+ alphabet: '',
56
59
  order: 'asc',
57
60
  }
58
61
  const sortModules = createEslintRule.createEslintRule({
@@ -73,10 +76,11 @@ const sortModules = createEslintRule.createEslintRule({
73
76
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
74
77
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
75
78
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
79
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
80
+ type: commonJsonSchemas.buildTypeJsonSchema(),
76
81
  locales: commonJsonSchemas.localesJsonSchema,
77
82
  groups: commonJsonSchemas.groupsJsonSchema,
78
83
  order: commonJsonSchemas.orderJsonSchema,
79
- type: commonJsonSchemas.typeJsonSchema,
80
84
  },
81
85
  additionalProperties: false,
82
86
  type: 'object',
@@ -108,6 +112,7 @@ const sortModules = createEslintRule.createEslintRule({
108
112
  settings,
109
113
  defaultOptions,
110
114
  )
115
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
111
116
  validateGeneratedGroupsConfiguration.validateGeneratedGroupsConfiguration({
112
117
  customGroups: options.customGroups,
113
118
  modifiers: sortModules_types.allModifiers,
@@ -256,14 +261,14 @@ let analyzeModule = ({
256
261
  continue
257
262
  }
258
263
  let { defineGroup, getGroup } = useGroups.useGroups(options)
259
- for (let officialGroup of generatePredefinedGroups.generatePredefinedGroups(
264
+ for (let predefinedGroup of generatePredefinedGroups.generatePredefinedGroups(
260
265
  {
261
266
  cache: cachedGroupsByModifiersAndSelectors,
262
267
  selectors: [selector],
263
268
  modifiers,
264
269
  },
265
270
  )) {
266
- defineGroup(officialGroup)
271
+ defineGroup(predefinedGroup)
267
272
  }
268
273
  for (let customGroup of options.customGroups) {
269
274
  if (
@@ -291,8 +296,8 @@ let analyzeModule = ({
291
296
  dependencyName: name,
292
297
  group: getGroup(),
293
298
  dependencies,
294
- node,
295
299
  name,
300
+ node,
296
301
  }
297
302
  let lastSortingNode =
298
303
  (_a = formattedNodes.at(-1)) == null ? void 0 : _a.at(-1)
@@ -304,14 +309,13 @@ let analyzeModule = ({
304
309
  lastSortingNode,
305
310
  sortingNode,
306
311
  )) ||
307
- (options.partitionByComment &&
308
- isPartitionComment.hasPartitionComment(
309
- options.partitionByComment,
310
- getCommentsBefore.getCommentsBefore({
311
- sourceCode,
312
- node,
313
- }),
314
- ))
312
+ isPartitionComment.hasPartitionComment(
313
+ options.partitionByComment,
314
+ getCommentsBefore.getCommentsBefore({
315
+ sourceCode,
316
+ node,
317
+ }),
318
+ )
315
319
  ) {
316
320
  formattedNodes.push([])
317
321
  }
@@ -340,11 +344,12 @@ let analyzeModule = ({
340
344
  let sortedNodesExcludingEslintDisabled =
341
345
  sortNodesIgnoringEslintDisabledNodes(true)
342
346
  let nodes = formattedNodes.flat()
347
+ let nodeIndexMap = createNodeIndexMap.createNodeIndexMap(sortedNodes)
343
348
  pairwise.pairwise(nodes, (left, right) => {
344
349
  let leftNumber = getGroupNumber.getGroupNumber(options.groups, left)
345
350
  let rightNumber = getGroupNumber.getGroupNumber(options.groups, right)
346
- let indexOfLeft = sortedNodes.indexOf(left)
347
- let indexOfRight = sortedNodes.indexOf(right)
351
+ let leftIndex = nodeIndexMap.get(left)
352
+ let rightIndex = nodeIndexMap.get(right)
348
353
  let indexOfRightExcludingEslintDisabled =
349
354
  sortedNodesExcludingEslintDisabled.indexOf(right)
350
355
  let messageIds = []
@@ -352,8 +357,8 @@ let analyzeModule = ({
352
357
  sortNodesByDependencies.getFirstUnorderedNodeDependentOn(right, nodes)
353
358
  if (
354
359
  firstUnorderedNodeDependentOnRight ||
355
- indexOfLeft > indexOfRight ||
356
- indexOfLeft >= indexOfRightExcludingEslintDisabled
360
+ leftIndex > rightIndex ||
361
+ leftIndex >= indexOfRightExcludingEslintDisabled
357
362
  ) {
358
363
  if (firstUnorderedNodeDependentOnRight) {
359
364
  messageIds.push('unexpectedModulesDependencyOrder')
@@ -1,7 +1,9 @@
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')
6
+ const createNodeIndexMap = require('../utils/create-node-index-map.js')
5
7
  const isPartitionComment = require('../utils/is-partition-comment.js')
6
8
  const getCommentsBefore = require('../utils/get-comments-before.js')
7
9
  const createEslintRule = require('../utils/create-eslint-rule.js')
@@ -22,6 +24,7 @@ let defaultOptions = {
22
24
  groupKind: 'mixed',
23
25
  ignoreCase: true,
24
26
  locales: 'en-US',
27
+ alphabet: '',
25
28
  order: 'asc',
26
29
  }
27
30
  const sortNamedExports = createEslintRule.createEslintRule({
@@ -37,6 +40,7 @@ const sortNamedExports = createEslintRule.createEslintRule({
37
40
  settings,
38
41
  defaultOptions,
39
42
  )
43
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
40
44
  let sourceCode = getSourceCode.getSourceCode(context)
41
45
  let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
42
46
  ruleName: context.id,
@@ -64,14 +68,13 @@ const sortNamedExports = createEslintRule.createEslintRule({
64
68
  name,
65
69
  }
66
70
  if (
67
- (options.partitionByComment &&
68
- isPartitionComment.hasPartitionComment(
69
- options.partitionByComment,
70
- getCommentsBefore.getCommentsBefore({
71
- node: specifier,
72
- sourceCode,
73
- }),
74
- )) ||
71
+ isPartitionComment.hasPartitionComment(
72
+ options.partitionByComment,
73
+ getCommentsBefore.getCommentsBefore({
74
+ node: specifier,
75
+ sourceCode,
76
+ }),
77
+ ) ||
75
78
  (options.partitionByNewLine &&
76
79
  lastSortingNode &&
77
80
  getLinesBetween.getLinesBetween(
@@ -108,14 +111,15 @@ const sortNamedExports = createEslintRule.createEslintRule({
108
111
  let sortedNodes = sortNodesExcludingEslintDisabled(false)
109
112
  let sortedNodesExcludingEslintDisabled =
110
113
  sortNodesExcludingEslintDisabled(true)
114
+ let nodeIndexMap = createNodeIndexMap.createNodeIndexMap(sortedNodes)
111
115
  pairwise.pairwise(nodes, (left, right) => {
112
- let indexOfLeft = sortedNodes.indexOf(left)
113
- let indexOfRight = sortedNodes.indexOf(right)
116
+ let leftIndex = nodeIndexMap.get(left)
117
+ let rightIndex = nodeIndexMap.get(right)
114
118
  let indexOfRightExcludingEslintDisabled =
115
119
  sortedNodesExcludingEslintDisabled.indexOf(right)
116
120
  if (
117
- indexOfLeft < indexOfRight &&
118
- indexOfLeft < indexOfRightExcludingEslintDisabled
121
+ leftIndex < rightIndex &&
122
+ leftIndex < indexOfRightExcludingEslintDisabled
119
123
  ) {
120
124
  return
121
125
  }
@@ -156,9 +160,10 @@ const sortNamedExports = createEslintRule.createEslintRule({
156
160
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
157
161
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
158
162
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
163
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
164
+ type: commonJsonSchemas.buildTypeJsonSchema(),
159
165
  locales: commonJsonSchemas.localesJsonSchema,
160
166
  order: commonJsonSchemas.orderJsonSchema,
161
- type: commonJsonSchemas.typeJsonSchema,
162
167
  },
163
168
  additionalProperties: false,
164
169
  type: 'object',
@@ -1,7 +1,9 @@
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')
6
+ const createNodeIndexMap = require('../utils/create-node-index-map.js')
5
7
  const isPartitionComment = require('../utils/is-partition-comment.js')
6
8
  const getCommentsBefore = require('../utils/get-comments-before.js')
7
9
  const createEslintRule = require('../utils/create-eslint-rule.js')
@@ -23,6 +25,7 @@ let defaultOptions = {
23
25
  groupKind: 'mixed',
24
26
  ignoreCase: true,
25
27
  locales: 'en-US',
28
+ alphabet: '',
26
29
  order: 'asc',
27
30
  }
28
31
  const sortNamedImports = createEslintRule.createEslintRule({
@@ -41,6 +44,7 @@ const sortNamedImports = createEslintRule.createEslintRule({
41
44
  settings,
42
45
  defaultOptions,
43
46
  )
47
+ validateCustomSortConfiguration.validateCustomSortConfiguration(options)
44
48
  let sourceCode = getSourceCode.getSourceCode(context)
45
49
  let eslintDisabledLines = getEslintDisabledLines.getEslintDisabledLines({
46
50
  ruleName: context.id,
@@ -73,14 +77,13 @@ const sortNamedImports = createEslintRule.createEslintRule({
73
77
  name,
74
78
  }
75
79
  if (
76
- (options.partitionByComment &&
77
- isPartitionComment.hasPartitionComment(
78
- options.partitionByComment,
79
- getCommentsBefore.getCommentsBefore({
80
- node: specifier,
81
- sourceCode,
82
- }),
83
- )) ||
80
+ isPartitionComment.hasPartitionComment(
81
+ options.partitionByComment,
82
+ getCommentsBefore.getCommentsBefore({
83
+ node: specifier,
84
+ sourceCode,
85
+ }),
86
+ ) ||
84
87
  (options.partitionByNewLine &&
85
88
  lastSortingNode &&
86
89
  getLinesBetween.getLinesBetween(
@@ -117,14 +120,15 @@ const sortNamedImports = createEslintRule.createEslintRule({
117
120
  let sortedNodes = sortNodesExcludingEslintDisabled(false)
118
121
  let sortedNodesExcludingEslintDisabled =
119
122
  sortNodesExcludingEslintDisabled(true)
123
+ let nodeIndexMap = createNodeIndexMap.createNodeIndexMap(sortedNodes)
120
124
  pairwise.pairwise(nodes, (left, right) => {
121
- let indexOfLeft = sortedNodes.indexOf(left)
122
- let indexOfRight = sortedNodes.indexOf(right)
125
+ let leftIndex = nodeIndexMap.get(left)
126
+ let rightIndex = nodeIndexMap.get(right)
123
127
  let indexOfRightExcludingEslintDisabled =
124
128
  sortedNodesExcludingEslintDisabled.indexOf(right)
125
129
  if (
126
- indexOfLeft < indexOfRight &&
127
- indexOfLeft < indexOfRightExcludingEslintDisabled
130
+ leftIndex < rightIndex &&
131
+ leftIndex < indexOfRightExcludingEslintDisabled
128
132
  ) {
129
133
  return
130
134
  }
@@ -169,9 +173,10 @@ const sortNamedImports = createEslintRule.createEslintRule({
169
173
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
170
174
  specialCharacters: commonJsonSchemas.specialCharactersJsonSchema,
171
175
  ignoreCase: commonJsonSchemas.ignoreCaseJsonSchema,
176
+ alphabet: commonJsonSchemas.alphabetJsonSchema,
177
+ type: commonJsonSchemas.buildTypeJsonSchema(),
172
178
  locales: commonJsonSchemas.localesJsonSchema,
173
179
  order: commonJsonSchemas.orderJsonSchema,
174
- type: commonJsonSchemas.typeJsonSchema,
175
180
  },
176
181
  additionalProperties: false,
177
182
  type: 'object',