eslint-plugin-perfectionist 5.10.0 → 5.11.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 (70) hide show
  1. package/dist/package.json.js +1 -1
  2. package/dist/rules/sort-arrays/sort-array.js +8 -6
  3. package/dist/rules/sort-classes/compute-dependencies-by-sorting-node.js +28 -43
  4. package/dist/rules/sort-classes/compute-dependencies.js +0 -3
  5. package/dist/rules/sort-classes/compute-overload-signature-groups.js +4 -3
  6. package/dist/rules/sort-classes/sort-class.js +33 -35
  7. package/dist/rules/sort-classes/types.d.ts +1 -1
  8. package/dist/rules/sort-enums/compute-dependencies.js +0 -3
  9. package/dist/rules/sort-enums/sort-enum.js +24 -26
  10. package/dist/rules/sort-enums/types.d.ts +1 -1
  11. package/dist/rules/sort-exports.js +6 -5
  12. package/dist/rules/sort-heritage-clauses/sort-heritage-clause.js +6 -9
  13. package/dist/rules/sort-import-attributes/sort-import-or-export-attributes.js +6 -9
  14. package/dist/rules/sort-imports/compute-common-selectors.d.ts +1 -1
  15. package/dist/rules/sort-imports/compute-common-selectors.js +2 -2
  16. package/dist/rules/sort-imports/matches-tsconfig-paths.d.ts +1 -1
  17. package/dist/rules/sort-imports/types.d.ts +7 -16
  18. package/dist/rules/sort-imports.js +35 -45
  19. package/dist/rules/sort-jsx-props/sort-jsx-object.js +13 -15
  20. package/dist/rules/sort-maps/sort-potential-map.js +6 -9
  21. package/dist/rules/sort-modules/build-usage-comparator.js +1 -1
  22. package/dist/rules/sort-modules/compute-additional-module-statements.d.ts +19 -0
  23. package/dist/rules/sort-modules/compute-additional-module-statements.js +32 -0
  24. package/dist/rules/sort-modules/compute-node-details.js +14 -13
  25. package/dist/rules/sort-modules/compute-overload-signature-groups.js +4 -3
  26. package/dist/rules/sort-modules/dependencies/compute-dependencies-by-sorting-node.d.ts +26 -0
  27. package/dist/rules/sort-modules/{compute-dependencies-by-sorting-node.js → dependencies/compute-dependencies-by-sorting-node.js} +33 -9
  28. package/dist/rules/sort-modules/dependencies/is-identifier-in-decorator-metadata-type-position.d.ts +13 -0
  29. package/dist/rules/sort-modules/dependencies/is-identifier-in-decorator-metadata-type-position.js +100 -0
  30. package/dist/rules/sort-modules/types.d.ts +13 -1
  31. package/dist/rules/sort-modules.js +66 -27
  32. package/dist/rules/sort-named-exports/sort-named-export.js +12 -14
  33. package/dist/rules/sort-named-imports/sort-named-import.js +12 -14
  34. package/dist/rules/sort-object-types/sort-object-type-elements.js +16 -17
  35. package/dist/rules/sort-objects/sort-object.js +36 -34
  36. package/dist/rules/sort-objects/types.d.ts +6 -1
  37. package/dist/rules/sort-objects.js +2 -0
  38. package/dist/rules/sort-union-or-intersection-types/sort-union-or-intersection-types.js +12 -15
  39. package/dist/rules/sort-variable-declarations/compute-dependencies.js +0 -1
  40. package/dist/rules/sort-variable-declarations/sort-variable-declaration.js +28 -27
  41. package/dist/rules/sort-variable-declarations/types.d.ts +6 -1
  42. package/dist/rules/sort-variable-declarations.js +2 -0
  43. package/dist/types/ts-config-option.d.ts +10 -0
  44. package/dist/utils/compare/build-line-length-comparator.js +2 -1
  45. package/dist/utils/compare/build-subgroup-order-comparator.js +3 -4
  46. package/dist/utils/compare/compare-alphabetically.js +2 -4
  47. package/dist/utils/compare/compare-naturally.js +2 -4
  48. package/dist/utils/{compute-dependencies-outside-functions-by-sorting-node.d.ts → compute-dependencies-outside-deferred-functions-by-sorting-node.d.ts} +4 -1
  49. package/dist/utils/compute-dependencies-outside-deferred-functions-by-sorting-node.js +22 -0
  50. package/dist/utils/get-comments-before.js +1 -1
  51. package/dist/utils/get-settings.d.ts +4 -2
  52. package/dist/utils/get-settings.js +1 -0
  53. package/dist/utils/is-node-immediately-called.d.ts +4 -1
  54. package/dist/utils/is-node-inside-deferred-function.d.ts +26 -0
  55. package/dist/utils/is-node-inside-deferred-function.js +70 -0
  56. package/dist/utils/is-partition-comment.js +3 -3
  57. package/dist/utils/json-schemas/tsconfig-json-schema.d.ts +2 -0
  58. package/dist/utils/json-schemas/tsconfig-json-schema.js +16 -0
  59. package/dist/utils/make-single-node-comment-after-fixes.js +52 -9
  60. package/dist/utils/should-partition.js +1 -1
  61. package/dist/utils/sort-nodes-by-groups.js +1 -1
  62. package/dist/utils/sort-nodes.js +1 -1
  63. package/dist/utils/tsconfig/get-typescript-import.d.ts +20 -0
  64. package/dist/{rules/sort-imports → utils/tsconfig}/get-typescript-import.js +19 -2
  65. package/dist/{rules/sort-imports → utils/tsconfig}/read-closest-ts-config-by-path.js +14 -10
  66. package/package.json +2 -2
  67. package/dist/rules/sort-imports/get-typescript-import.d.ts +0 -7
  68. package/dist/rules/sort-modules/compute-dependencies-by-sorting-node.d.ts +0 -16
  69. package/dist/utils/compute-dependencies-outside-functions-by-sorting-node.js +0 -30
  70. /package/dist/{rules/sort-imports → utils/tsconfig}/read-closest-ts-config-by-path.d.ts +0 -0
@@ -1,3 +1,3 @@
1
1
  var name = 'eslint-plugin-perfectionist'
2
- var version = '5.10.0'
2
+ var version = '5.11.0'
3
3
  export { name, version }
@@ -73,6 +73,11 @@ function sortArray({
73
73
  sourceCode,
74
74
  })
75
75
  let selector = 'literal'
76
+ let predefinedGroups = generatePredefinedGroups({
77
+ cache: cachedGroupsByModifiersAndSelectors,
78
+ selectors: [selector],
79
+ modifiers: [],
80
+ })
76
81
  let group = computeGroup({
77
82
  customGroupMatcher: customGroup =>
78
83
  doesCustomGroupMatch({
@@ -81,11 +86,7 @@ function sortArray({
81
86
  modifiers: [],
82
87
  customGroup,
83
88
  }),
84
- predefinedGroups: generatePredefinedGroups({
85
- cache: cachedGroupsByModifiersAndSelectors,
86
- selectors: [selector],
87
- modifiers: [],
88
- }),
89
+ predefinedGroups,
89
90
  options,
90
91
  })
91
92
  let sortingNode = {
@@ -125,12 +126,13 @@ function sortArray({
125
126
  }),
126
127
  )
127
128
  }
129
+ let nodes = formattedMembers.flat()
128
130
  reportAllErrors({
129
131
  sortNodesExcludingEslintDisabled,
130
132
  availableMessageIds,
131
133
  options,
132
134
  context,
133
- nodes: formattedMembers.flat(),
135
+ nodes,
134
136
  })
135
137
  }
136
138
  export { sortArray }
@@ -1,7 +1,6 @@
1
1
  import { UnreachableCaseError } from '../../utils/unreachable-case-error.js'
2
- import { matches } from '../../utils/matches.js'
3
2
  import { computeDependenciesBySortingNode as computeDependenciesBySortingNode$1 } from '../../utils/compute-dependencies-by-sorting-node.js'
4
- import { computeParentNodesWithTypes } from '../../utils/compute-parent-nodes-with-types.js'
3
+ import { isNodeInsideDeferredFunction } from '../../utils/is-node-inside-deferred-function.js'
5
4
  import { computeIdentifierNameDetails } from './compute-identifier-name-details.js'
6
5
  import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils'
7
6
  function computeDependenciesBySortingNode({
@@ -10,11 +9,12 @@ function computeDependenciesBySortingNode({
10
9
  sourceCode,
11
10
  classBody,
12
11
  }) {
12
+ let staticSortingNodes = sortingNodes.filter(node => node.isStatic)
13
13
  let dependenciesBySortingNode = computeDependenciesBySortingNode$1({
14
14
  additionalIdentifierDependenciesComputer:
15
15
  buildAdditionalIdentifierDependenciesComputer({
16
16
  ignoreCallbackDependenciesPatterns,
17
- staticSortingNodes: sortingNodes.filter(node => node.isStatic),
17
+ staticSortingNodes,
18
18
  classBody,
19
19
  }),
20
20
  shouldIgnoreSortingNodeComputer: sortingNode =>
@@ -43,7 +43,14 @@ function computeIdentifierOrThisExpressionDependency({
43
43
  classElement,
44
44
  node,
45
45
  }) {
46
- if (shouldIgnoreCallbackDependency()) {
46
+ if (
47
+ classElement.type !== AST_NODE_TYPES.StaticBlock &&
48
+ isNodeInsideDeferredFunction({
49
+ ignoreCallbackDependenciesPatterns,
50
+ maxParent: classElement,
51
+ node,
52
+ })
53
+ ) {
47
54
  return null
48
55
  }
49
56
  let { parent } = node
@@ -72,24 +79,6 @@ function computeIdentifierOrThisExpressionDependency({
72
79
  return null
73
80
  }
74
81
  }
75
- function shouldIgnoreCallbackDependency() {
76
- let [firstCallExpressionParent] = computeParentNodesWithTypes({
77
- allowedTypes: [AST_NODE_TYPES.CallExpression],
78
- maxParent: classElement,
79
- consecutiveOnly: false,
80
- node,
81
- })
82
- if (!firstCallExpressionParent) {
83
- return false
84
- }
85
- if (!('name' in firstCallExpressionParent.callee)) {
86
- return false
87
- }
88
- return matches(
89
- firstCallExpressionParent.callee.name,
90
- ignoreCallbackDependenciesPatterns,
91
- )
92
- }
93
82
  }
94
83
  function computeThisExpressionDependenciesBySortingNode({
95
84
  ignoreCallbackDependenciesPatterns,
@@ -146,27 +135,6 @@ function buildAdditionalIdentifierDependenciesComputer({
146
135
  return dependency ? [dependency] : []
147
136
  }
148
137
  }
149
- function shouldIgnoreDependencyComputation(node) {
150
- switch (node.type) {
151
- case AST_NODE_TYPES.TSAbstractPropertyDefinition:
152
- case AST_NODE_TYPES.TSAbstractMethodDefinition:
153
- case AST_NODE_TYPES.StaticBlock:
154
- return false
155
- case AST_NODE_TYPES.TSAbstractAccessorProperty:
156
- case AST_NODE_TYPES.PropertyDefinition:
157
- case AST_NODE_TYPES.AccessorProperty:
158
- return (
159
- node.value?.type === AST_NODE_TYPES.ArrowFunctionExpression ||
160
- node.value?.type === AST_NODE_TYPES.FunctionExpression
161
- )
162
- case AST_NODE_TYPES.MethodDefinition:
163
- case AST_NODE_TYPES.TSIndexSignature:
164
- return true
165
- /* v8 ignore next 2 -- @preserve Exhaustive guard. */
166
- default:
167
- throw new UnreachableCaseError(node)
168
- }
169
- }
170
138
  function computeThisExpressionsInsideClassElement({
171
139
  classElement,
172
140
  sourceCode,
@@ -183,4 +151,21 @@ function computeThisExpressionsInsideClassElement({
183
151
  return token.type === AST_TOKEN_TYPES.Keyword && token.value === 'this'
184
152
  }
185
153
  }
154
+ function shouldIgnoreDependencyComputation(node) {
155
+ switch (node.type) {
156
+ case AST_NODE_TYPES.TSAbstractPropertyDefinition:
157
+ case AST_NODE_TYPES.TSAbstractAccessorProperty:
158
+ case AST_NODE_TYPES.TSAbstractMethodDefinition:
159
+ case AST_NODE_TYPES.PropertyDefinition:
160
+ case AST_NODE_TYPES.AccessorProperty:
161
+ case AST_NODE_TYPES.StaticBlock:
162
+ return false
163
+ case AST_NODE_TYPES.MethodDefinition:
164
+ case AST_NODE_TYPES.TSIndexSignature:
165
+ return true
166
+ /* v8 ignore next 2 -- @preserve Exhaustive guard. */
167
+ default:
168
+ throw new UnreachableCaseError(node)
169
+ }
170
+ }
186
171
  export { computeDependenciesBySortingNode }
@@ -63,9 +63,6 @@ function computeDependencies({
63
63
  case AST_NODE_TYPES.Property:
64
64
  traverseNode(nodeValue.key)
65
65
  traverseNode(nodeValue.value)
66
- break
67
- default:
68
- break
69
66
  }
70
67
  if ('argument' in nodeValue && nodeValue.argument) {
71
68
  traverseNode(nodeValue.argument)
@@ -41,10 +41,11 @@ function computeOverloadSignatureGroups(classElements) {
41
41
  }
42
42
  function buildOverloadSignatureGroup(methods) {
43
43
  let implementation = methods.find(isMethodImplementation) ?? methods.at(-1)
44
+ let overloadSignatures = methods.filter(
45
+ method => !isMethodImplementation(method),
46
+ )
44
47
  return new OverloadSignatureGroup({
45
- overloadSignatures: methods.filter(
46
- method => !isMethodImplementation(method),
47
- ),
48
+ overloadSignatures,
48
49
  implementation,
49
50
  })
50
51
  function isMethodImplementation(method) {
@@ -94,15 +94,12 @@ function sortClass({ matchedAstSelectors, context, node }) {
94
94
  return
95
95
  }
96
96
  let settings = getSettings(context.settings)
97
- let options = complete(
98
- computeMatchedContextOptions({
99
- matchedAstSelectors,
100
- classElements,
101
- context,
102
- }),
103
- settings,
104
- defaultOptions,
105
- )
97
+ let matchedContextOptions = computeMatchedContextOptions({
98
+ matchedAstSelectors,
99
+ classElements,
100
+ context,
101
+ })
102
+ let options = complete(matchedContextOptions, settings, defaultOptions)
106
103
  validateCustomSortConfig(options)
107
104
  validateGroupsConfig({
108
105
  modifiers: allModifiers,
@@ -235,6 +232,11 @@ function sortClass({ matchedAstSelectors, context, node }) {
235
232
  default:
236
233
  throw new UnreachableCaseError(member)
237
234
  }
235
+ let predefinedGroups = generatePredefinedGroups({
236
+ cache: cachedGroupsByModifiersAndSelectors,
237
+ selectors,
238
+ modifiers,
239
+ })
238
240
  let group = computeGroup({
239
241
  customGroupMatcher: customGroup =>
240
242
  doesCustomGroupMatch({
@@ -245,11 +247,7 @@ function sortClass({ matchedAstSelectors, context, node }) {
245
247
  modifiers,
246
248
  selectors,
247
249
  }),
248
- predefinedGroups: generatePredefinedGroups({
249
- cache: cachedGroupsByModifiersAndSelectors,
250
- selectors,
251
- modifiers,
252
- }),
250
+ predefinedGroups,
253
251
  options,
254
252
  })
255
253
  let sortingNode = {
@@ -288,14 +286,15 @@ function sortClass({ matchedAstSelectors, context, node }) {
288
286
  sortingNodeGroups: sortingNodeGroupsWithoutOverloadSignature,
289
287
  })
290
288
  if (options.useExperimentalDependencyDetection) {
289
+ let dependenciesBySortingNode = computeDependenciesBySortingNode({
290
+ ignoreCallbackDependenciesPatterns:
291
+ options.ignoreCallbackDependenciesPatterns,
292
+ sortingNodes: sortingNodeGroups.flat(),
293
+ classBody: node,
294
+ sourceCode,
295
+ })
291
296
  sortingNodeGroups = populateSortingNodeGroupsWithDependencies({
292
- dependenciesBySortingNode: computeDependenciesBySortingNode({
293
- ignoreCallbackDependenciesPatterns:
294
- options.ignoreCallbackDependenciesPatterns,
295
- sortingNodes: sortingNodeGroups.flat(),
296
- classBody: node,
297
- sourceCode,
298
- }),
297
+ dependenciesBySortingNode,
299
298
  sortingNodeGroups,
300
299
  })
301
300
  }
@@ -315,21 +314,20 @@ function sortClass({ matchedAstSelectors, context, node }) {
315
314
  context,
316
315
  })
317
316
  function sortNodesExcludingEslintDisabled(ignoreEslintDisabledNodes) {
318
- return sortNodesByDependencies(
319
- sortingNodeGroups.flatMap(sortingNodeGroup =>
320
- sortNodesByGroups({
321
- isNodeIgnored: sortingNode =>
322
- getGroupIndex(options.groups, sortingNode) ===
323
- options.groups.length,
324
- comparatorByOptionsComputer: defaultComparatorByOptionsComputer,
325
- optionsByGroupIndexComputer,
326
- ignoreEslintDisabledNodes,
327
- nodes: sortingNodeGroup,
328
- groups: options.groups,
329
- }),
330
- ),
331
- { ignoreEslintDisabledNodes },
317
+ let nodesSortedByGroups = sortingNodeGroups.flatMap(sortingNodeGroup =>
318
+ sortNodesByGroups({
319
+ isNodeIgnored: sortingNode =>
320
+ getGroupIndex(options.groups, sortingNode) === options.groups.length,
321
+ comparatorByOptionsComputer: defaultComparatorByOptionsComputer,
322
+ optionsByGroupIndexComputer,
323
+ ignoreEslintDisabledNodes,
324
+ nodes: sortingNodeGroup,
325
+ groups: options.groups,
326
+ }),
332
327
  )
328
+ return sortNodesByDependencies(nodesSortedByGroups, {
329
+ ignoreEslintDisabledNodes,
330
+ })
333
331
  }
334
332
  }
335
333
  export { defaultOptions, sortClass }
@@ -50,7 +50,7 @@ export type Options = Partial<
50
50
  */
51
51
  ignoreCallbackDependenciesPatterns: RegexOption
52
52
  /**
53
- * Enables experimental dependency detection.
53
+ * @deprecated Enables experimental dependency detection.
54
54
  */
55
55
  useExperimentalDependencyDetection: boolean
56
56
  } & AllCommonOptions<
@@ -31,9 +31,6 @@ function computeDependencies(expression, enumName) {
31
31
  break
32
32
  case AST_NODE_TYPES.Identifier:
33
33
  dependencies.push(node.name)
34
- break
35
- default:
36
- break
37
34
  }
38
35
  if ('alternate' in node && node.alternate) {
39
36
  stack.push(node.alternate)
@@ -54,15 +54,12 @@ function sortEnum({ matchedAstSelectors, context, node }) {
54
54
  return
55
55
  }
56
56
  let settings = getSettings(context.settings)
57
- let options = complete(
58
- computeMatchedContextOptions({
59
- enumMembers: members,
60
- matchedAstSelectors,
61
- context,
62
- }),
63
- settings,
64
- defaultOptions,
65
- )
57
+ let matchedContextOptions = computeMatchedContextOptions({
58
+ enumMembers: members,
59
+ matchedAstSelectors,
60
+ context,
61
+ })
62
+ let options = complete(matchedContextOptions, settings, defaultOptions)
66
63
  validateCustomSortConfig(options)
67
64
  validateGroupsConfig({
68
65
  selectors: [],
@@ -131,12 +128,13 @@ function sortEnum({ matchedAstSelectors, context, node }) {
131
128
  [[]],
132
129
  )
133
130
  if (options.useExperimentalDependencyDetection) {
131
+ let dependenciesBySortingNode = computeDependenciesBySortingNode({
132
+ sortingNodes: sortingNodeGroups.flat(),
133
+ enumName: node.id.name,
134
+ sourceCode,
135
+ })
134
136
  sortingNodeGroups = populateSortingNodeGroupsWithDependencies({
135
- dependenciesBySortingNode: computeDependenciesBySortingNode({
136
- sortingNodes: sortingNodeGroups.flat(),
137
- enumName: node.id.name,
138
- sourceCode,
139
- }),
137
+ dependenciesBySortingNode,
140
138
  sortingNodeGroups,
141
139
  })
142
140
  }
@@ -158,19 +156,19 @@ function sortEnum({ matchedAstSelectors, context, node }) {
158
156
  context,
159
157
  })
160
158
  function sortNodesExcludingEslintDisabled(ignoreEslintDisabledNodes) {
161
- return sortNodesByDependencies(
162
- sortingNodeGroups.flatMap(sortingNodeGroup =>
163
- sortNodesByGroups({
164
- comparatorByOptionsComputer:
165
- buildComparatorByOptionsComputer(isNumericEnum),
166
- optionsByGroupIndexComputer,
167
- ignoreEslintDisabledNodes,
168
- nodes: sortingNodeGroup,
169
- groups: options.groups,
170
- }),
171
- ),
172
- { ignoreEslintDisabledNodes },
159
+ let nodesSortedByGroups = sortingNodeGroups.flatMap(sortingNodeGroup =>
160
+ sortNodesByGroups({
161
+ comparatorByOptionsComputer:
162
+ buildComparatorByOptionsComputer(isNumericEnum),
163
+ optionsByGroupIndexComputer,
164
+ ignoreEslintDisabledNodes,
165
+ nodes: sortingNodeGroup,
166
+ groups: options.groups,
167
+ }),
173
168
  )
169
+ return sortNodesByDependencies(nodesSortedByGroups, {
170
+ ignoreEslintDisabledNodes,
171
+ })
174
172
  }
175
173
  }
176
174
  export { defaultOptions, sortEnum }
@@ -47,7 +47,7 @@ export type Options = Partial<
47
47
  */
48
48
  sortByValue: 'ifNumericEnum' | 'always' | 'never'
49
49
  /**
50
- * Enables experimental dependency detection.
50
+ * @deprecated Enables experimental dependency detection.
51
51
  */
52
52
  useExperimentalDependencyDetection: boolean
53
53
  } & AllCommonOptions<
@@ -88,6 +88,11 @@ var sort_exports_default = createEslintRule({
88
88
  computeLineCountModifier(node),
89
89
  ]
90
90
  let name = node.source.value
91
+ let predefinedGroups = generatePredefinedGroups({
92
+ cache: cachedGroupsByModifiersAndSelectors,
93
+ selectors: [selector],
94
+ modifiers,
95
+ })
91
96
  let group = computeGroup({
92
97
  customGroupMatcher: customGroup =>
93
98
  doesCustomGroupMatch({
@@ -96,11 +101,7 @@ var sort_exports_default = createEslintRule({
96
101
  customGroup,
97
102
  modifiers,
98
103
  }),
99
- predefinedGroups: generatePredefinedGroups({
100
- cache: cachedGroupsByModifiersAndSelectors,
101
- selectors: [selector],
102
- modifiers,
103
- }),
104
+ predefinedGroups,
104
105
  options,
105
106
  })
106
107
  let sortingNode = {
@@ -48,15 +48,12 @@ function sortHeritageClause({ matchedAstSelectors, context, node }) {
48
48
  return
49
49
  }
50
50
  let settings = getSettings(context.settings)
51
- let options = complete(
52
- computeMatchedContextOptions({
53
- matchedAstSelectors,
54
- heritageClauses,
55
- context,
56
- }),
57
- settings,
58
- defaultOptions,
59
- )
51
+ let matchedContextOptions = computeMatchedContextOptions({
52
+ matchedAstSelectors,
53
+ heritageClauses,
54
+ context,
55
+ })
56
+ let options = complete(matchedContextOptions, settings, defaultOptions)
60
57
  validateCustomSortConfig(options)
61
58
  validateGroupsConfig({
62
59
  modifiers: [],
@@ -29,15 +29,12 @@ function sortImportOrExportAttributes({
29
29
  }
30
30
  let { sourceCode, id } = context
31
31
  let settings = getSettings(context.settings)
32
- let options = complete(
33
- computeMatchedContextOptions({
34
- matchedAstSelectors,
35
- attributes,
36
- context,
37
- }),
38
- settings,
39
- defaultOptions,
40
- )
32
+ let matchedContextOptions = computeMatchedContextOptions({
33
+ matchedAstSelectors,
34
+ attributes,
35
+ context,
36
+ })
37
+ let options = complete(matchedContextOptions, settings, defaultOptions)
41
38
  validateCustomSortConfig(options)
42
39
  validateGroupsConfig({
43
40
  selectors: [],
@@ -1,4 +1,4 @@
1
- import { ReadClosestTsConfigByPathValue } from './read-closest-ts-config-by-path.js'
1
+ import { ReadClosestTsConfigByPathValue } from '../../utils/tsconfig/read-closest-ts-config-by-path.js'
2
2
  import { RegexOption } from '../../types/common-options.js'
3
3
  import { Selector } from './types.js'
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { matches } from '../../utils/matches.js'
2
- import { getTypescriptImport } from './get-typescript-import.js'
2
+ import { getTypescriptImport } from '../../utils/tsconfig/get-typescript-import.js'
3
3
  import { matchesTsconfigPaths } from './matches-tsconfig-paths.js'
4
4
  import { builtinModules } from 'node:module'
5
5
  /**
@@ -135,7 +135,7 @@ function isCoreModule(value, environment) {
135
135
  function clean(string_) {
136
136
  return string_.replace(/^(?:node:){1,2}/u, '')
137
137
  }
138
- let [basePath] = value.split('/')
138
+ let [basePath] = value.split('/', 1)
139
139
  let cleanValue = clean(value)
140
140
  let cleanBase = clean(basePath)
141
141
  if (nodeBuiltinModules.has(cleanValue) || nodeBuiltinModules.has(cleanBase)) {
@@ -1,4 +1,4 @@
1
- import { ReadClosestTsConfigByPathValue } from './read-closest-ts-config-by-path.js'
1
+ import { ReadClosestTsConfigByPathValue } from '../../utils/tsconfig/read-closest-ts-config-by-path.js'
2
2
  /**
3
3
  * Checks if an import matches any of the path mappings in tsconfig.json.
4
4
  *
@@ -3,6 +3,7 @@ import { TSESTree } from '@typescript-eslint/types'
3
3
  import { SortingNodeWithDependencies } from '../../utils/sort-nodes-by-dependencies.js'
4
4
  import { RegexOption, TypeOption } from '../../types/common-options.js'
5
5
  import { AllCommonOptions } from '../../types/all-common-options.js'
6
+ import { TsConfigOption } from '../../types/ts-config-option.js'
6
7
  /**
7
8
  * Configuration options for the sort-imports rule.
8
9
  *
@@ -12,22 +13,7 @@ import { AllCommonOptions } from '../../types/all-common-options.js'
12
13
  export type Options = Partial<
13
14
  {
14
15
  /**
15
- * TypeScript configuration for resolving module paths. Enables path alias
16
- * resolution based on tsconfig.json paths configuration.
17
- */
18
- tsconfig: {
19
- /**
20
- * Optional filename of the TypeScript config file. `@default`
21
- * tsconfig.json'.
22
- */
23
- filename?: string
24
- /**
25
- * Root directory where to search for the TypeScript config file.
26
- */
27
- rootDir: string
28
- }
29
- /**
30
- * Enables experimental dependency detection.
16
+ * @deprecated Enables experimental dependency detection.
31
17
  */
32
18
  useExperimentalDependencyDetection: boolean
33
19
  /**
@@ -42,6 +28,11 @@ export type Options = Partial<
42
28
  * @default 'node'
43
29
  */
44
30
  environment: 'node' | 'bun'
31
+ /**
32
+ * TypeScript configuration for resolving module paths. Enables path alias
33
+ * resolution based on tsconfig.json paths configuration.
34
+ */
35
+ tsconfig: TsConfigOption
45
36
  /**
46
37
  * Controls whether side-effect imports should be sorted. When false,
47
38
  * side-effect imports remain in their original positions.