eslint-plugin-perfectionist 4.8.0 → 4.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.
Files changed (40) hide show
  1. package/dist/rules/sort-array-includes/types.js +1 -1
  2. package/dist/rules/sort-array-includes.js +2 -10
  3. package/dist/rules/sort-classes/types.js +3 -6
  4. package/dist/rules/sort-classes.js +74 -91
  5. package/dist/rules/sort-decorators.js +11 -8
  6. package/dist/rules/sort-enums/types.js +2 -2
  7. package/dist/rules/sort-enums.js +1 -1
  8. package/dist/rules/sort-exports.js +1 -1
  9. package/dist/rules/sort-heritage-clauses.js +6 -6
  10. package/dist/rules/sort-imports.js +7 -13
  11. package/dist/rules/sort-interfaces.js +1 -0
  12. package/dist/rules/sort-intersection-types.js +1 -0
  13. package/dist/rules/sort-jsx-props.js +60 -31
  14. package/dist/rules/sort-maps/types.js +1 -1
  15. package/dist/rules/sort-maps.js +2 -5
  16. package/dist/rules/sort-modules/types.js +2 -5
  17. package/dist/rules/sort-modules.js +8 -11
  18. package/dist/rules/sort-named-exports.js +1 -1
  19. package/dist/rules/sort-named-imports.js +1 -1
  20. package/dist/rules/sort-object-types/types.js +1 -1
  21. package/dist/rules/sort-object-types.js +10 -28
  22. package/dist/rules/sort-objects/types.js +2 -2
  23. package/dist/rules/sort-objects.js +12 -28
  24. package/dist/rules/sort-switch-case.js +2 -2
  25. package/dist/rules/sort-union-types.js +6 -6
  26. package/dist/rules/sort-variable-declarations.js +1 -1
  27. package/dist/utils/common-json-schemas.js +48 -32
  28. package/dist/utils/compare.js +16 -4
  29. package/dist/utils/get-comment-after.js +1 -1
  30. package/dist/utils/get-custom-groups-compare-options.js +1 -7
  31. package/dist/utils/get-decorator-name.js +10 -0
  32. package/dist/utils/is-partition-comment.js +14 -10
  33. package/dist/utils/matches.js +9 -1
  34. package/dist/utils/validate-generated-groups-configuration.js +6 -2
  35. package/dist/utils/validate-groups-configuration.js +18 -38
  36. package/dist/utils/validate-newlines-between-inside-groups.js +18 -0
  37. package/dist/utils/validate-no-duplicated-groups.js +22 -0
  38. package/package.json +3 -3
  39. package/readme.md +3 -3
  40. package/dist/rules/sort-decorators/get-decorator-name.js +0 -23
@@ -4,7 +4,7 @@ const commonJsonSchemas = require('../../utils/common-json-schemas.js')
4
4
  let allSelectors = ['literal', 'spread']
5
5
  let singleCustomGroupJsonSchema = {
6
6
  selector: commonJsonSchemas.buildCustomGroupSelectorJsonSchema(allSelectors),
7
- elementNamePattern: commonJsonSchemas.elementNamePatternJsonSchema,
7
+ elementNamePattern: commonJsonSchemas.regexJsonSchema,
8
8
  }
9
9
  exports.allSelectors = allSelectors
10
10
  exports.singleCustomGroupJsonSchema = singleCustomGroupJsonSchema
@@ -27,6 +27,7 @@ const useGroups = require('../utils/use-groups.js')
27
27
  const complete = require('../utils/complete.js')
28
28
  let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
29
29
  let defaultOptions = {
30
+ fallbackSort: { type: 'unsorted' },
30
31
  groupKind: 'literals-first',
31
32
  specialCharacters: 'keep',
32
33
  partitionByComment: false,
@@ -54,7 +55,6 @@ let jsonSchema = {
54
55
  singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
55
56
  }),
56
57
  useConfigurationIf: commonJsonSchemas.buildUseConfigurationIfJsonSchema(),
57
- type: commonJsonSchemas.buildTypeJsonSchema({ withUnsorted: true }),
58
58
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
59
59
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
60
60
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
@@ -127,19 +127,11 @@ let sortArray = ({ availableMessageIds, elements, context }) => {
127
127
  .map(element => getNodeName({ sourceCode, element })),
128
128
  contextOptions: context.options,
129
129
  })
130
- let completeOptions = complete.complete(
130
+ let options = complete.complete(
131
131
  matchedContextOptions[0],
132
132
  settings,
133
133
  defaultOptions,
134
134
  )
135
- let { type } = completeOptions
136
- if (type === 'unsorted') {
137
- return
138
- }
139
- let options = {
140
- ...completeOptions,
141
- type,
142
- }
143
135
  validateCustomSortConfiguration.validateCustomSortConfiguration(options)
144
136
  validateGeneratedGroupsConfiguration.validateGeneratedGroupsConfiguration({
145
137
  selectors: types.allSelectors,
@@ -26,15 +26,12 @@ let allModifiers = [
26
26
  'optional',
27
27
  ]
28
28
  let singleCustomGroupJsonSchema = {
29
- decoratorNamePattern: {
30
- description: 'Decorator name pattern filter.',
31
- type: 'string',
32
- },
33
29
  modifiers:
34
30
  commonJsonSchemas.buildCustomGroupModifiersJsonSchema(allModifiers),
35
31
  selector: commonJsonSchemas.buildCustomGroupSelectorJsonSchema(allSelectors),
36
- elementValuePattern: commonJsonSchemas.elementValuePatternJsonSchema,
37
- elementNamePattern: commonJsonSchemas.elementNamePatternJsonSchema,
32
+ decoratorNamePattern: commonJsonSchemas.regexJsonSchema,
33
+ elementValuePattern: commonJsonSchemas.regexJsonSchema,
34
+ elementNamePattern: commonJsonSchemas.regexJsonSchema,
38
35
  }
39
36
  exports.allModifiers = allModifiers
40
37
  exports.allSelectors = allSelectors
@@ -13,7 +13,9 @@ const doesCustomGroupMatch = require('./sort-classes/does-custom-group-match.js'
13
13
  const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
14
14
  const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
15
15
  const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
16
+ const getNodeDecorators = require('../utils/get-node-decorators.js')
16
17
  const createEslintRule = require('../utils/create-eslint-rule.js')
18
+ const getDecoratorName = require('../utils/get-decorator-name.js')
17
19
  const reportAllErrors = require('../utils/report-all-errors.js')
18
20
  const shouldPartition = require('../utils/should-partition.js')
19
21
  const getGroupNumber = require('../utils/get-group-number.js')
@@ -51,6 +53,7 @@ let defaultOptions = {
51
53
  'unknown',
52
54
  ],
53
55
  ignoreCallbackDependenciesPatterns: [],
56
+ fallbackSort: { type: 'unsorted' },
54
57
  partitionByComment: false,
55
58
  partitionByNewLine: false,
56
59
  newlinesBetween: 'ignore',
@@ -185,8 +188,9 @@ const sortClasses = createEslintRule.createEslintRule({
185
188
  'name' in nodeValue.callee ? nodeValue.callee.name : null
186
189
  shouldIgnore =
187
190
  functionName !== null &&
188
- options.ignoreCallbackDependenciesPatterns.some(pattern =>
189
- matches.matches(functionName, pattern),
191
+ matches.matches(
192
+ functionName,
193
+ options.ignoreCallbackDependenciesPatterns,
190
194
  )
191
195
  }
192
196
  if (!shouldIgnore) {
@@ -227,7 +231,7 @@ const sortClasses = createEslintRule.createEslintRule({
227
231
  getOverloadSignatureGroups.getOverloadSignatureGroups(node.body)
228
232
  let formattedNodes = node.body.reduce(
229
233
  (accumulator, member) => {
230
- var _a2, _b, _c
234
+ var _a2, _b, _c, _d, _e
231
235
  let name
232
236
  let dependencies = []
233
237
  let { defineGroup, getGroup } = useGroups.useGroups(options)
@@ -250,25 +254,73 @@ const sortClasses = createEslintRule.createEslintRule({
250
254
  let decorated = false
251
255
  let decorators = []
252
256
  if ('decorators' in member) {
253
- decorated = member.decorators.length > 0
254
- for (let decorator of member.decorators) {
255
- if (decorator.expression.type === 'Identifier') {
256
- decorators.push(decorator.expression.name)
257
- } else if (
258
- decorator.expression.type === 'CallExpression' &&
259
- decorator.expression.callee.type === 'Identifier'
260
- ) {
261
- decorators.push(decorator.expression.callee.name)
262
- }
263
- }
257
+ decorators = getNodeDecorators
258
+ .getNodeDecorators(member)
259
+ .map(decorator =>
260
+ getDecoratorName.getDecoratorName({ sourceCode, decorator }),
261
+ )
262
+ decorated = decorators.length > 0
264
263
  }
265
264
  let memberValue
266
265
  let modifiers = []
267
266
  let selectors = []
268
267
  let addSafetySemicolonWhenInline = true
269
268
  switch (member.type) {
269
+ case 'TSAbstractPropertyDefinition':
270
+ case 'PropertyDefinition':
271
+ if ('static' in member && member.static) {
272
+ modifiers.push('static')
273
+ }
274
+ if ('declare' in member && member.declare) {
275
+ modifiers.push('declare')
276
+ }
277
+ if (member.type === 'TSAbstractPropertyDefinition') {
278
+ modifiers.push('abstract')
279
+ }
280
+ if (decorated) {
281
+ modifiers.push('decorated')
282
+ }
283
+ if ('override' in member && member.override) {
284
+ modifiers.push('override')
285
+ }
286
+ if ('readonly' in member && member.readonly) {
287
+ modifiers.push('readonly')
288
+ }
289
+ if (
290
+ 'accessibility' in member &&
291
+ member.accessibility === 'protected'
292
+ ) {
293
+ modifiers.push('protected')
294
+ } else if (
295
+ ('accessibility' in member &&
296
+ member.accessibility === 'private') ||
297
+ isPrivateHash
298
+ ) {
299
+ modifiers.push('private')
300
+ } else {
301
+ modifiers.push('public')
302
+ }
303
+ if ('optional' in member && member.optional) {
304
+ modifiers.push('optional')
305
+ }
306
+ if (
307
+ ((_b = member.value) == null ? void 0 : _b.type) ===
308
+ 'ArrowFunctionExpression' ||
309
+ ((_c = member.value) == null ? void 0 : _c.type) ===
310
+ 'FunctionExpression'
311
+ ) {
312
+ if (member.value.async) {
313
+ modifiers.push('async')
314
+ }
315
+ selectors.push('function-property')
316
+ } else if (member.value) {
317
+ memberValue = sourceCode.getText(member.value)
318
+ dependencies = extractDependencies(member.value, member.static)
319
+ }
320
+ selectors.push('property')
321
+ break
270
322
  case 'TSAbstractMethodDefinition':
271
- case 'MethodDefinition': {
323
+ case 'MethodDefinition':
272
324
  if (member.static) {
273
325
  modifiers.push('static')
274
326
  }
@@ -307,9 +359,8 @@ const sortClasses = createEslintRule.createEslintRule({
307
359
  }
308
360
  selectors.push('method')
309
361
  break
310
- }
311
362
  case 'TSAbstractAccessorProperty':
312
- case 'AccessorProperty': {
363
+ case 'AccessorProperty':
313
364
  if (member.static) {
314
365
  modifiers.push('static')
315
366
  }
@@ -331,8 +382,7 @@ const sortClasses = createEslintRule.createEslintRule({
331
382
  }
332
383
  selectors.push('accessor-property')
333
384
  break
334
- }
335
- case 'TSIndexSignature': {
385
+ case 'TSIndexSignature':
336
386
  if (member.static) {
337
387
  modifiers.push('static')
338
388
  }
@@ -341,70 +391,11 @@ const sortClasses = createEslintRule.createEslintRule({
341
391
  }
342
392
  selectors.push('index-signature')
343
393
  break
344
- }
345
- case 'StaticBlock': {
394
+ case 'StaticBlock':
346
395
  addSafetySemicolonWhenInline = false
347
396
  selectors.push('static-block')
348
397
  dependencies = extractDependencies(member, true)
349
398
  break
350
- }
351
- default: {
352
- if ('static' in member && member.static) {
353
- modifiers.push('static')
354
- }
355
- if ('declare' in member && member.declare) {
356
- modifiers.push('declare')
357
- }
358
- if (member.type === 'TSAbstractPropertyDefinition') {
359
- modifiers.push('abstract')
360
- }
361
- if (decorated) {
362
- modifiers.push('decorated')
363
- }
364
- if ('override' in member && member.override) {
365
- modifiers.push('override')
366
- }
367
- if ('readonly' in member && member.readonly) {
368
- modifiers.push('readonly')
369
- }
370
- if (
371
- 'accessibility' in member &&
372
- member.accessibility === 'protected'
373
- ) {
374
- modifiers.push('protected')
375
- } else if (
376
- ('accessibility' in member &&
377
- member.accessibility === 'private') ||
378
- isPrivateHash
379
- ) {
380
- modifiers.push('private')
381
- } else {
382
- modifiers.push('public')
383
- }
384
- if ('optional' in member && member.optional) {
385
- modifiers.push('optional')
386
- }
387
- if ('value' in member && member.value) {
388
- if (
389
- member.value.type === 'ArrowFunctionExpression' ||
390
- member.value.type === 'FunctionExpression'
391
- ) {
392
- if (member.value.async) {
393
- modifiers.push('async')
394
- }
395
- selectors.push('function-property')
396
- } else {
397
- memberValue = sourceCode.getText(member.value)
398
- }
399
- if (member.value.type !== 'TSEmptyBodyFunctionExpression') {
400
- dependencies = extractDependencies(
401
- member.value,
402
- member.static,
403
- )
404
- }
405
- }
406
- selectors.push('property')
407
- }
408
399
  }
409
400
  let predefinedGroups =
410
401
  generatePredefinedGroups.generatePredefinedGroups({
@@ -437,10 +428,10 @@ const sortClasses = createEslintRule.createEslintRule({
437
428
  overloadSignatures.includes(member),
438
429
  )
439
430
  let overloadSignatureGroupMember =
440
- (_b = overloadSignatureGroups[overloadSignatureGroupMemberIndex]) ==
431
+ (_d = overloadSignatureGroups[overloadSignatureGroupMemberIndex]) ==
441
432
  null
442
433
  ? void 0
443
- : _b.at(-1)
434
+ : _d.at(-1)
444
435
  let sortingNode = {
445
436
  dependencyName: getDependencyName({
446
437
  nodeNameWithoutStartingHash: name.startsWith('#')
@@ -470,7 +461,7 @@ const sortClasses = createEslintRule.createEslintRule({
470
461
  name,
471
462
  }
472
463
  let lastSortingNode =
473
- (_c = accumulator.at(-1)) == null ? void 0 : _c.at(-1)
464
+ (_e = accumulator.at(-1)) == null ? void 0 : _e.at(-1)
474
465
  if (
475
466
  shouldPartition.shouldPartition({
476
467
  lastSortingNode,
@@ -540,21 +531,13 @@ const sortClasses = createEslintRule.createEslintRule({
540
531
  {
541
532
  properties: {
542
533
  ...commonJsonSchemas.commonJsonSchemas,
543
- ignoreCallbackDependenciesPatterns: {
544
- description:
545
- 'Patterns that should be ignored when detecting dependencies in method callbacks.',
546
- items: {
547
- type: 'string',
548
- },
549
- type: 'array',
550
- },
551
534
  customGroups: commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
552
535
  singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
553
536
  }),
537
+ ignoreCallbackDependenciesPatterns: commonJsonSchemas.regexJsonSchema,
554
538
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
555
539
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
556
540
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
557
- type: commonJsonSchemas.buildTypeJsonSchema(),
558
541
  groups: commonJsonSchemas.groupsJsonSchema,
559
542
  },
560
543
  additionalProperties: false,
@@ -4,10 +4,10 @@ const validateCustomSortConfiguration = require('../utils/validate-custom-sort-c
4
4
  const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
5
5
  const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
6
6
  const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
7
- const getDecoratorName = require('./sort-decorators/get-decorator-name.js')
8
7
  const reportErrors = require('../utils/report-errors.js')
9
8
  const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
10
9
  const getNodeDecorators = require('../utils/get-node-decorators.js')
10
+ const getDecoratorName = require('../utils/get-decorator-name.js')
11
11
  const createEslintRule = require('../utils/create-eslint-rule.js')
12
12
  const reportAllErrors = require('../utils/report-all-errors.js')
13
13
  const shouldPartition = require('../utils/should-partition.js')
@@ -18,6 +18,7 @@ const isSortable = require('../utils/is-sortable.js')
18
18
  const useGroups = require('../utils/use-groups.js')
19
19
  const complete = require('../utils/complete.js')
20
20
  let defaultOptions = {
21
+ fallbackSort: { type: 'unsorted' },
21
22
  specialCharacters: 'keep',
22
23
  partitionByComment: false,
23
24
  sortOnProperties: true,
@@ -42,11 +43,11 @@ const sortDecorators = createEslintRule.createEslintRule({
42
43
  defaultOptions,
43
44
  )
44
45
  validateCustomSortConfiguration.validateCustomSortConfiguration(options)
45
- validateGroupsConfiguration.validateGroupsConfiguration(
46
- options.groups,
47
- ['unknown'],
48
- Object.keys(options.customGroups),
49
- )
46
+ validateGroupsConfiguration.validateGroupsConfiguration({
47
+ allowedCustomGroups: Object.keys(options.customGroups),
48
+ allowedPredefinedGroups: ['unknown'],
49
+ options,
50
+ })
50
51
  return {
51
52
  Decorator: decorator => {
52
53
  if (!options.sortOnParameters) {
@@ -130,7 +131,6 @@ const sortDecorators = createEslintRule.createEslintRule({
130
131
  },
131
132
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
132
133
  customGroups: commonJsonSchemas.customGroupsJsonSchema,
133
- type: commonJsonSchemas.buildTypeJsonSchema(),
134
134
  groups: commonJsonSchemas.groupsJsonSchema,
135
135
  },
136
136
  additionalProperties: false,
@@ -165,7 +165,10 @@ let sortDecorators$1 = (context, options, decorators) => {
165
165
  (accumulator, decorator) => {
166
166
  var _a
167
167
  let { setCustomGroups, getGroup } = useGroups.useGroups(options)
168
- let name = getDecoratorName.getDecoratorName(decorator)
168
+ let name = getDecoratorName.getDecoratorName({
169
+ sourceCode,
170
+ decorator,
171
+ })
169
172
  setCustomGroups(options.customGroups, name)
170
173
  let sortingNode = {
171
174
  isEslintDisabled: isNodeEslintDisabled.isNodeEslintDisabled(
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
3
3
  const commonJsonSchemas = require('../../utils/common-json-schemas.js')
4
4
  let singleCustomGroupJsonSchema = {
5
- elementValuePattern: commonJsonSchemas.elementValuePatternJsonSchema,
6
- elementNamePattern: commonJsonSchemas.elementNamePatternJsonSchema,
5
+ elementValuePattern: commonJsonSchemas.regexJsonSchema,
6
+ elementNamePattern: commonJsonSchemas.regexJsonSchema,
7
7
  }
8
8
  exports.singleCustomGroupJsonSchema = singleCustomGroupJsonSchema
@@ -22,6 +22,7 @@ const isSortable = require('../utils/is-sortable.js')
22
22
  const useGroups = require('../utils/use-groups.js')
23
23
  const complete = require('../utils/complete.js')
24
24
  let defaultOptions = {
25
+ fallbackSort: { type: 'unsorted' },
25
26
  partitionByComment: false,
26
27
  partitionByNewLine: false,
27
28
  specialCharacters: 'keep',
@@ -251,7 +252,6 @@ const sortEnums = createEslintRule.createEslintRule({
251
252
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
252
253
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
253
254
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
254
- type: commonJsonSchemas.buildTypeJsonSchema(),
255
255
  groups: commonJsonSchemas.groupsJsonSchema,
256
256
  },
257
257
  additionalProperties: false,
@@ -13,6 +13,7 @@ const getSettings = require('../utils/get-settings.js')
13
13
  const sortNodes = require('../utils/sort-nodes.js')
14
14
  const complete = require('../utils/complete.js')
15
15
  let defaultOptions = {
16
+ fallbackSort: { type: 'unsorted' },
16
17
  specialCharacters: 'keep',
17
18
  partitionByComment: false,
18
19
  partitionByNewLine: false,
@@ -119,7 +120,6 @@ const sortExports = createEslintRule.createEslintRule({
119
120
  },
120
121
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
121
122
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
122
- type: commonJsonSchemas.buildTypeJsonSchema(),
123
123
  },
124
124
  additionalProperties: false,
125
125
  type: 'object',
@@ -15,6 +15,7 @@ const isSortable = require('../utils/is-sortable.js')
15
15
  const useGroups = require('../utils/use-groups.js')
16
16
  const complete = require('../utils/complete.js')
17
17
  let defaultOptions = {
18
+ fallbackSort: { type: 'unsorted' },
18
19
  specialCharacters: 'keep',
19
20
  type: 'alphabetical',
20
21
  ignoreCase: true,
@@ -31,7 +32,6 @@ const sortHeritageClauses = createEslintRule.createEslintRule({
31
32
  properties: {
32
33
  ...commonJsonSchemas.commonJsonSchemas,
33
34
  customGroups: commonJsonSchemas.customGroupsJsonSchema,
34
- type: commonJsonSchemas.buildTypeJsonSchema(),
35
35
  groups: commonJsonSchemas.groupsJsonSchema,
36
36
  },
37
37
  additionalProperties: false,
@@ -58,11 +58,11 @@ const sortHeritageClauses = createEslintRule.createEslintRule({
58
58
  defaultOptions,
59
59
  )
60
60
  validateCustomSortConfiguration.validateCustomSortConfiguration(options)
61
- validateGroupsConfiguration.validateGroupsConfiguration(
62
- options.groups,
63
- ['unknown'],
64
- Object.keys(options.customGroups),
65
- )
61
+ validateGroupsConfiguration.validateGroupsConfiguration({
62
+ allowedCustomGroups: Object.keys(options.customGroups),
63
+ allowedPredefinedGroups: ['unknown'],
64
+ options,
65
+ })
66
66
  return {
67
67
  TSInterfaceDeclaration: declaration =>
68
68
  sortHeritageClauses$1(context, options, declaration.extends),
@@ -39,6 +39,7 @@ const sortImports = createEslintRule.createEslintRule({
39
39
  'unknown',
40
40
  ],
41
41
  customGroups: { value: {}, type: {} },
42
+ fallbackSort: { type: 'unsorted' },
42
43
  internalPattern: ['^~/.+'],
43
44
  partitionByComment: false,
44
45
  partitionByNewLine: false,
@@ -53,9 +54,8 @@ const sortImports = createEslintRule.createEslintRule({
53
54
  order: 'asc',
54
55
  }),
55
56
  )
56
- validateGroupsConfiguration.validateGroupsConfiguration(
57
- options.groups,
58
- [
57
+ validateGroupsConfiguration.validateGroupsConfiguration({
58
+ allowedPredefinedGroups: [
59
59
  'side-effect-style',
60
60
  'external-type',
61
61
  'internal-type',
@@ -75,11 +75,12 @@ const sortImports = createEslintRule.createEslintRule({
75
75
  'style',
76
76
  'type',
77
77
  ],
78
- [
78
+ allowedCustomGroups: [
79
79
  ...Object.keys(options.customGroups.type ?? {}),
80
80
  ...Object.keys(options.customGroups.value ?? {}),
81
81
  ],
82
- )
82
+ options,
83
+ })
83
84
  validateCustomSortConfiguration.validateCustomSortConfiguration(options)
84
85
  validateNewlinesAndPartitionConfiguration.validateNewlinesAndPartitionConfiguration(
85
86
  options,
@@ -428,13 +429,6 @@ const sortImports = createEslintRule.createEslintRule({
428
429
  additionalProperties: false,
429
430
  type: 'object',
430
431
  },
431
- internalPattern: {
432
- description: 'Specifies the pattern for internal modules.',
433
- items: {
434
- type: 'string',
435
- },
436
- type: 'array',
437
- },
438
432
  maxLineLength: {
439
433
  description: 'Specifies the maximum line length.',
440
434
  exclusiveMinimum: true,
@@ -458,7 +452,7 @@ const sortImports = createEslintRule.createEslintRule({
458
452
  partitionByComment: commonJsonSchemas.partitionByCommentJsonSchema,
459
453
  partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,
460
454
  newlinesBetween: commonJsonSchemas.newlinesBetweenJsonSchema,
461
- type: commonJsonSchemas.buildTypeJsonSchema(),
455
+ internalPattern: commonJsonSchemas.regexJsonSchema,
462
456
  groups: commonJsonSchemas.groupsJsonSchema,
463
457
  },
464
458
  definitions: {
@@ -3,6 +3,7 @@ const reportErrors = require('../utils/report-errors.js')
3
3
  const sortObjectTypes = require('./sort-object-types.js')
4
4
  const createEslintRule = require('../utils/create-eslint-rule.js')
5
5
  let defaultOptions = {
6
+ fallbackSort: { type: 'unsorted' },
6
7
  partitionByComment: false,
7
8
  partitionByNewLine: false,
8
9
  newlinesBetween: 'ignore',
@@ -3,6 +3,7 @@ const reportErrors = require('../utils/report-errors.js')
3
3
  const sortUnionTypes = require('./sort-union-types.js')
4
4
  const createEslintRule = require('../utils/create-eslint-rule.js')
5
5
  let defaultOptions = {
6
+ fallbackSort: { type: 'unsorted' },
6
7
  specialCharacters: 'keep',
7
8
  newlinesBetween: 'ignore',
8
9
  partitionByComment: false,