Skip to content

Commit 5452245

Browse files
hugop95azat-io
authored andcommitted
feat(sort-imports)!: drop deprecated ts config root dir support
1 parent ad7530e commit 5452245

File tree

4 files changed

+12
-37
lines changed

4 files changed

+12
-37
lines changed

docs/content/rules/sort-imports.mdx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,6 @@ This option is only available when the type is set to `'line-length'`.
282282

283283
If this option is not set, the rule will not search for a `tsconfig.json` file.
284284

285-
### [DEPRECATED] tsconfigRootDir
286-
287-
<sub>default: `undefined`</sub>
288-
289-
Use the [tsconfig](#tsconfig) option with the `rootDir` attribute.
290-
291-
Specifies the directory of the root `tsconfig.json` file (ex: `.`). This is used in [`groups`](#groups) for:
292-
- Marking aliased imports as `internal`.
293-
- Marking imports matching [tsconfig paths](https://www.typescriptlang.org/tsconfig/#paths) as `tsconfig-path`.
294-
295-
If this option is not set, the rule will not search for a `tsconfig.json` file.
296-
297285
### groups
298286

299287
<sub>
@@ -335,7 +323,7 @@ The list of selectors is sorted from most to least important:
335323
- `'side-effect-style'` — Side effect style imports.
336324
- `'side-effect'` — Side effect imports.
337325
- `'style'` — Styles.
338-
- `'tsconfig-path'``tsconfig` [paths](https://www.typescriptlang.org/tsconfig/#paths) alias imports. Requires [`tsconfigRootDir`](#tsconfigrootdir) to be set.
326+
- `'tsconfig-path'``tsconfig` [paths](https://www.typescriptlang.org/tsconfig/#paths) alias imports. Requires [`tsconfig.rootDir`](#tsconfig) to be set.
339327
- `'index'` — Main file from the current directory.
340328
- `'sibling'` — Modules from the same directory.
341329
- `'parent'` — Modules from the parent directory.

rules/sort-imports.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ export type MessageId =
6969
| 'missedCommentAboveImport'
7070
| 'unexpectedImportsOrder'
7171

72-
let defaultOptions: Required<
73-
Omit<Options[0], 'tsconfigRootDir' | 'maxLineLength' | 'tsconfig'>
74-
> &
75-
Pick<Options[0], 'tsconfigRootDir' | 'maxLineLength' | 'tsconfig'> = {
72+
let defaultOptions: Required<Omit<Options[0], 'maxLineLength' | 'tsconfig'>> &
73+
Pick<Options[0], 'maxLineLength' | 'tsconfig'> = {
7674
groups: [
7775
'type-import',
7876
['value-builtin', 'value-external'],
@@ -125,8 +123,7 @@ export default createEslintRule<Options, MessageId>({
125123
validateNewlinesAndPartitionConfiguration(options)
126124
validateSideEffectsConfiguration(options)
127125

128-
let tsconfigRootDirectory =
129-
options.tsconfig?.rootDir ?? options.tsconfigRootDir
126+
let tsconfigRootDirectory = options.tsconfig?.rootDir
130127
let tsConfigOutput = tsconfigRootDirectory
131128
? readClosestTsConfigByPath({
132129
tsconfigFilename: options.tsconfig?.filename ?? 'tsconfig.json',
@@ -497,10 +494,6 @@ export default createEslintRule<Options, MessageId>({
497494
enum: ['node', 'bun'],
498495
type: 'string',
499496
},
500-
tsconfigRootDir: {
501-
description: 'Specifies the tsConfig root directory.',
502-
type: 'string',
503-
},
504497
partitionByComment: partitionByCommentJsonSchema,
505498
partitionByNewLine: partitionByNewLineJsonSchema,
506499
newlinesBetween: newlinesBetweenJsonSchema,
@@ -579,7 +572,7 @@ function computeGroupExceptUnknown({
579572
}: {
580573
options: Omit<
581574
Required<Options[0]>,
582-
'tsconfigRootDir' | 'maxLineLength' | 'customGroups' | 'tsconfig'
575+
'maxLineLength' | 'customGroups' | 'tsconfig'
583576
>
584577
customGroups: DeprecatedCustomGroupsOption | CustomGroupsOption | undefined
585578
selectors?: Selector[]

rules/sort-imports/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ export type Options = Partial<{
7777
/** Controls the placement of newlines between different groups of imports. */
7878
newlinesBetween: NewlinesBetweenOption
7979

80-
/**
81-
* @deprecated Since v4.14.0. Will be removed in v5.0.0. Use
82-
* {@link tsconfig.rootDir} instead.
83-
*/
84-
tsconfigRootDir: undefined | string
85-
8680
/**
8781
* Maximum line length for imports. When exceeded, import names are used for
8882
* sorting instead of the entire line.

test/rules/sort-imports.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,7 +2553,7 @@ describe('sort-imports', () => {
25532553
'tsconfig-path',
25542554
],
25552555
],
2556-
tsconfigRootDir: '.',
2556+
tsconfig: { rootDir: '.' },
25572557
},
25582558
],
25592559
output: dedent`
@@ -6375,7 +6375,7 @@ describe('sort-imports', () => {
63756375
'tsconfig-path',
63766376
],
63776377
],
6378-
tsconfigRootDir: '.',
6378+
tsconfig: { rootDir: '.' },
63796379
},
63806380
],
63816381
output: dedent`
@@ -10138,7 +10138,7 @@ describe('sort-imports', () => {
1013810138
'tsconfig-path',
1013910139
],
1014010140
],
10141-
tsconfigRootDir: '.',
10141+
tsconfig: { rootDir: '.' },
1014210142
},
1014310143
],
1014410144
output: dedent`
@@ -12027,7 +12027,7 @@ describe('sort-imports', () => {
1202712027
options: [
1202812028
{
1202912029
groups: ['internal', 'unknown'],
12030-
tsconfigRootDir: '.',
12030+
tsconfig: { rootDir: '.' },
1203112031
},
1203212032
],
1203312033
before: () => {
@@ -12051,7 +12051,7 @@ describe('sort-imports', () => {
1205112051
options: [
1205212052
{
1205312053
groups: ['external', 'unknown'],
12054-
tsconfigRootDir: '.',
12054+
tsconfig: { rootDir: '.' },
1205512055
},
1205612056
],
1205712057
code: dedent`
@@ -12075,7 +12075,7 @@ describe('sort-imports', () => {
1207512075
options: [
1207612076
{
1207712077
groups: ['external', 'unknown'],
12078-
tsconfigRootDir: '.',
12078+
tsconfig: { rootDir: '.' },
1207912079
},
1208012080
],
1208112081
before: () => {
@@ -12105,7 +12105,7 @@ describe('sort-imports', () => {
1210512105
options: [
1210612106
{
1210712107
groups: ['external', 'unknown'],
12108-
tsconfigRootDir: '.',
12108+
tsconfig: { rootDir: '.' },
1210912109
},
1211012110
],
1211112111
code: dedent`

0 commit comments

Comments
 (0)