Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the first integration test #124

Merged
merged 19 commits into from
Jan 16, 2025
Merged
Prev Previous commit
Next Next commit
Merge branch 'master' into e2e
  • Loading branch information
illright committed Dec 26, 2024

Verified

This commit was signed with the committer’s verified signature.
crazy-max CrazyMax
commit c2baf795b8e9c804d3d2b100ed0f68066907bec8
47 changes: 45 additions & 2 deletions packages/steiger-plugin-fsd/src/_lib/collect-related-ts-configs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TSConfckParseResult } from 'tsconfck'
import { dirname, posix } from 'node:path'
import { dirname } from 'node:path'

export type CollectRelatedTsConfigsPayload = {
tsconfig: TSConfckParseResult['tsconfig']
@@ -118,7 +118,9 @@ function makeRelativePathAliasesAbsolute(
for (const entries of Object.entries(paths)) {
const [key, paths] = entries as [key: string, paths: Array<string>]
absolutePaths[key] = paths.map((relativePath: string) =>
posix.resolve(dirname(firstConfigWithPaths.tsconfigFile!), relativePath),
baseUrl
? resolve(dirname(firstConfigWithPaths.tsconfigFile!), baseUrl, relativePath)
: resolve(dirname(firstConfigWithPaths.tsconfigFile!), relativePath),
)
}

@@ -288,4 +290,45 @@ if (import.meta.vitest) {

expect(collectRelatedTsConfigs(payload)).toEqual(expectedResult)
})

test('correctly resolves paths if baseUrl is set', () => {
const payload: CollectRelatedTsConfigsPayload = {
tsconfigFile: resolve(joinFromRoot('user', 'projects', 'project-0', 'tsconfig.json')),
tsconfig: {
compilerOptions: {
baseUrl: './src',
paths: {
'~': ['./'],
'~/*': ['./*'],
},
strict: true,
noUncheckedIndexedAccess: false,
forceConsistentCasingInFileNames: true,
noImplicitOverride: true,
module: 'ESNext',
noEmit: true,
},
},
}

const expectedResult = [
{
compilerOptions: {
baseUrl: './src',
paths: {
'~': [resolve(joinFromRoot('user', 'projects', 'project-0', 'src'))],
'~/*': [resolve(joinFromRoot('user', 'projects', 'project-0', 'src', '*'))],
},
strict: true,
noUncheckedIndexedAccess: false,
forceConsistentCasingInFileNames: true,
noImplicitOverride: true,
module: 'ESNext',
noEmit: true,
},
},
]

expect(collectRelatedTsConfigs(payload)).toEqual(expectedResult)
})
}
You are viewing a condensed version of this merge commit. You can view the full changes here.