Skip to content

Commit 9a69fd5

Browse files
committed
Apply linting fixes to Vitest configuration
1 parent 123cd73 commit 9a69fd5

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

vitest.config.mts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url'
44
import { defineConfig } from 'vitest/config'
55

66
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
const isCoverage = process.argv.includes('--coverage')
78

89
export default defineConfig({
910
test: {
@@ -59,16 +60,22 @@ export default defineConfig({
5960
},
6061
},
6162
resolve: {
62-
alias: [
63-
// Map dist imports to src for proper coverage tracking.
64-
{
65-
find: /^\.\.\/dist\/(.*)\.js$/,
66-
replacement: path.resolve(__dirname, 'src/$1.ts'),
67-
},
68-
{
69-
find: /^\.\/dist\/(.*)\.js$/,
70-
replacement: path.resolve(__dirname, 'src/$1.ts'),
71-
},
72-
],
63+
// Map dist imports to src when running coverage, use dist otherwise.
64+
alias: isCoverage
65+
? [
66+
{
67+
// Match: ../dist/some-module.js
68+
find: /^\.\.\/dist\/(.*)\.js$/,
69+
// Replace: src/some-module.ts
70+
replacement: path.resolve(__dirname, 'src/$1.ts'),
71+
},
72+
{
73+
// Match: ./dist/some-module.js
74+
find: /^\.\/dist\/(.*)\.js$/,
75+
// Replace: src/some-module.ts
76+
replacement: path.resolve(__dirname, 'src/$1.ts'),
77+
},
78+
]
79+
: [],
7380
},
7481
})

0 commit comments

Comments
 (0)