Skip to content

Commit d4f8d98

Browse files
committed
feat: when changing filePath allow to also change definitionPath
1 parent 0710f52 commit d4f8d98

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

packages/wxt/src/core/resolve-config.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ async function getUnimportOptions(
495495

496496
const importsCopy = {
497497
...(config.imports || {}),
498+
// NOTE: `eslintrc` is resolved separately above
498499
eslintrc: undefined,
499500
};
500501

@@ -533,11 +534,16 @@ function getEslintConfig(
533534
wxtDir: string,
534535
eslintrc: Eslintrc | undefined,
535536
): ResolvedEslintrc {
537+
const filePath =
538+
eslintrc?.filePath || path.resolve(wxtDir, 'eslint-auto-imports.mjs');
539+
const definitionPath =
540+
eslintrc?.definitionPath ||
541+
path.resolve(wxtDir, 'eslint-auto-imports.d.mts');
542+
536543
return {
537544
legacy: false,
538-
filePath:
539-
eslintrc?.filePath || path.resolve(wxtDir, 'eslint-auto-imports.mjs'),
540-
definitionPath: path.resolve(wxtDir, 'eslint-auto-imports.d.mts'),
545+
filePath,
546+
definitionPath,
541547
globalsPropValue: eslintrc?.globalsPropValue ?? true,
542548
};
543549
}
@@ -546,10 +552,12 @@ function getEslintLegacyConfig(
546552
wxtDir: string,
547553
eslintrc: Eslintrc | undefined,
548554
): ResolvedEslintrcLegacy {
555+
const filePath =
556+
eslintrc?.filePath || path.resolve(wxtDir, 'eslintrc-auto-import.json');
557+
549558
return {
550559
legacy: true,
551-
filePath:
552-
eslintrc?.filePath || path.resolve(wxtDir, 'eslintrc-auto-import.json'),
560+
filePath,
553561
globalsPropValue: eslintrc?.globalsPropValue ?? true,
554562
};
555563
}

packages/wxt/src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,7 @@ export interface Eslintrc {
14341434
* @default 'auto'
14351435
*/
14361436
enabled?: false | true | 'auto' | 8 | 9;
1437+
14371438
/**
14381439
* File path to save the generated eslint config.
14391440
*
@@ -1442,6 +1443,16 @@ export interface Eslintrc {
14421443
* - 8 and below: './.wxt/eslintrc-auto-import.json'
14431444
*/
14441445
filePath?: string;
1446+
1447+
/**
1448+
* File path to the TypeScript definition file to use for auto-imported variables.
1449+
* Needs to match the definition file path for `filePath`
1450+
*
1451+
* Default:
1452+
* - 9 and above: './.wxt/types/wxt-auto-imports.d.mts'
1453+
*/
1454+
definitionPath?: string;
1455+
14451456
/**
14461457
* @default true
14471458
*/

0 commit comments

Comments
 (0)