refactor: Consolidate tsconfig and eslintrc files (no-changelog) (#6816)

Co-authored-by: Csaba Tuncsik <csaba@n8n.io>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-08-01 17:32:43 +02:00
committed by GitHub
parent 31d8f478ee
commit 34df8b6238
22 changed files with 59 additions and 75 deletions

View File

@@ -6,10 +6,11 @@ const tsJestOptions = {
...compilerOptions,
declaration: false,
sourceMap: true,
skipLibCheck: true,
},
};
const { baseUrl, paths } = require('get-tsconfig').getTsconfig().config?.compilerOptions;
/** @type {import('jest').Config} */
const config = {
verbose: true,
@@ -19,9 +20,14 @@ const config = {
transform: {
'^.+\\.ts$': ['ts-jest', tsJestOptions],
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
// This resolve the path mappings from the tsconfig relative to each jest.config.js
moduleNameMapper: Object.entries(paths || {}).reduce((acc, [path, [mapping]]) => {
path = `^${path.replace(/\/\*$/, '/(.*)$')}`;
mapping = mapping.replace(/^\.\/(?:(.*)\/)?\*$/, '$1');
mapping = mapping ? `/${mapping}` : '';
acc[path] = '<rootDir>' + (baseUrl ? `/${baseUrl.replace(/^\.\//, '')}` : '') + mapping + '/$1';
return acc;
}, {}),
setupFilesAfterEnv: ['jest-expect-message'],
collectCoverage: true,
coverageReporters: [process.env.COVERAGE_REPORT === 'true' ? 'text' : 'text-summary'],