Skip to content

Commit 75d54d6

Browse files
committed
feat(typescript): add tsconfigRootDir option to typescript config
Allow specifying custom tsconfig root directory path for better project structure flexibility
1 parent 5be25e0 commit 75d54d6

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/configs/ts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@ export function typescript (options: Options['ts'] = true): TypedFlatConfigItem[
6060
}
6161
const preset = (options === true || !options?.preset) ? 'recommended' : options.preset
6262
const projectService = (typeof options === 'object' && options?.projectService) || ['recommendedTypeChecked', 'strictTypeChecked', 'all'].includes(preset)
63+
const tsconfigRootDir = typeof options === 'object' ? options?.tsconfigRootDir : undefined
64+
6365
return [
6466
...typescriptCore(preset),
6567
{
6668
languageOptions: {
6769
parserOptions: {
6870
projectService,
71+
tsconfigRootDir,
6972
},
7073
},
7174
},

src/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const typescriptSchema = v.exactOptional(
2121
files: v.exactOptional(v.array(v.string())),
2222
preset: v.exactOptional(tsPresets, 'recommended'),
2323
projectService: v.exactOptional(v.boolean()),
24+
tsconfigRootDir: v.exactOptional(v.string()),
2425
}),
2526
]),
2627
hasPackage('typescript'),

tests/config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('validateOptions: full and edge case validation', () => {
5353

5454
describe('validateOptions: partial and matrix edge cases', () => {
5555
const matrix = [
56-
{ key: 'ts', values: [true, false, { files: ['src/**/*.ts'] }, { preset: 'strict' }, { files: ['src/a.ts'], preset: 'all' }] },
56+
{ key: 'ts', values: [true, false, { files: ['src/**/*.ts'] }, { preset: 'strict' }, { files: ['src/a.ts'], preset: 'all' }, { tsconfigRootDir: '/path/to/root' }] },
5757
{ key: 'vue', values: [true, false, { files: ['src/**/*.vue'] }, { a11y: true }, { files: ['src/a.vue'], a11y: false }] },
5858
{ key: 'perfectionist', values: [true, false, { files: ['src/**/*.js'] }, { import: true }, { export: false }, { import: false, export: false }] },
5959
]

0 commit comments

Comments
 (0)