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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 59 additions and 75 deletions

View file

@ -3,7 +3,7 @@ ARG NODE_VERSION=18
# 1. Create an image to build n8n # 1. Create an image to build n8n
FROM n8nio/base:${NODE_VERSION} as builder FROM n8nio/base:${NODE_VERSION} as builder
COPY --chown=node:node turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml jest.config.js tsconfig.json ./ COPY --chown=node:node turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml jest.config.js tsconfig*.json ./
COPY --chown=node:node scripts ./scripts COPY --chown=node:node scripts ./scripts
COPY --chown=node:node packages ./packages COPY --chown=node:node packages ./packages
COPY --chown=node:node patches ./patches COPY --chown=node:node patches ./patches

View file

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

View file

@ -58,7 +58,9 @@
"start-server-and-test": "^2.0.0", "start-server-and-test": "^2.0.0",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"ts-jest": "^29.1.1", "ts-jest": "^29.1.1",
"tsc-alias": "^1.8.7",
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"tsconfig-paths": "^4.2.0",
"turbo": "1.10.12", "turbo": "1.10.12",
"typescript": "*", "typescript": "*",
"vite": "^4.4.7", "vite": "^4.4.7",

View file

@ -1,11 +1,8 @@
{ {
"extends": "./tsconfig.json", "extends": ["./tsconfig.json", "../../../tsconfig.build.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist"
"types": ["node"],
"noEmit": false,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
}, },
"include": ["src/**/*.ts"], "include": ["src/**/*.ts"],
"exclude": ["test/**"] "exclude": ["test/**"]

View file

@ -7,10 +7,6 @@ module.exports = {
globalSetup: '<rootDir>/test/setup.ts', globalSetup: '<rootDir>/test/setup.ts',
globalTeardown: '<rootDir>/test/teardown.ts', globalTeardown: '<rootDir>/test/teardown.ts',
setupFilesAfterEnv: ['<rootDir>/test/setup-mocks.ts', '<rootDir>/test/extend-expect.ts'], setupFilesAfterEnv: ['<rootDir>/test/setup-mocks.ts', '<rootDir>/test/extend-expect.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@db/(.*)$': '<rootDir>/src/databases/$1',
},
coveragePathIgnorePatterns: ['/src/databases/migrations/'], coveragePathIgnorePatterns: ['/src/databases/migrations/'],
testTimeout: 10_000, testTimeout: 10_000,
}; };

View file

@ -96,9 +96,7 @@
"@types/yamljs": "^0.2.31", "@types/yamljs": "^0.2.31",
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"concurrently": "^8.2.0", "concurrently": "^8.2.0",
"ts-essentials": "^7.0.3", "ts-essentials": "^7.0.3"
"tsc-alias": "^1.8.7",
"tsconfig-paths": "^4.2.0"
}, },
"dependencies": { "dependencies": {
"@n8n/client-oauth2": "workspace:*", "@n8n/client-oauth2": "workspace:*",

View file

@ -1,19 +1,9 @@
{ {
"extends": "./tsconfig.json", "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist"
"types": ["node"],
"noEmit": false,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
}, },
"include": ["src/**/*.ts"], "include": ["src/**/*.ts"],
"exclude": ["test/**"], "exclude": ["test/**"]
"tsc-alias": {
"replacers": {
"base-url": {
"enabled": false
}
}
}
} }

View file

@ -1,9 +1,7 @@
{ {
"extends": "../../tsconfig.json", "extends": ["../../tsconfig.json", "../../tsconfig.backend.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": ".", "rootDir": ".",
"types": ["node", "jest"],
"noEmit": true,
"preserveSymlinks": true, "preserveSymlinks": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
@ -12,7 +10,6 @@
"@/*": ["./*"], "@/*": ["./*"],
"@db/*": ["./databases/*"] "@db/*": ["./databases/*"]
}, },
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo",
// TODO: remove all options below this line // TODO: remove all options below this line
"strict": false, "strict": false,
"noUnusedLocals": false, "noUnusedLocals": false,

View file

@ -1,11 +1,8 @@
{ {
"extends": "./tsconfig.json", "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist"
"types": ["node"],
"noEmit": false,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
}, },
"include": ["src/**/*.ts"], "include": ["src/**/*.ts"],
"exclude": ["test/**"] "exclude": ["test/**"]

View file

@ -1,15 +1,12 @@
{ {
"extends": "../../tsconfig.json", "extends": ["../../tsconfig.json", "../../tsconfig.backend.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": ".", "rootDir": ".",
"types": ["node", "jest"],
"composite": true, "composite": true,
"noEmit": true,
"baseUrl": "src", "baseUrl": "src",
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
}, },
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo",
// TODO: remove all options below this line // TODO: remove all options below this line
"useUnknownInCatchVariables": false "useUnknownInCatchVariables": false
}, },

View file

@ -6,7 +6,6 @@
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"importHelpers": true, "importHelpers": true,
"skipLibCheck": true,
"allowJs": true, "allowJs": true,
"incremental": false, "incremental": false,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,

View file

@ -5,7 +5,6 @@
"outDir": "dist", "outDir": "dist",
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"skipLibCheck": true,
"allowJs": true, "allowJs": true,
"importHelpers": true, "importHelpers": true,
"incremental": false, "incremental": false,

View file

@ -1,8 +1,7 @@
{ {
"extends": "../../tsconfig.json", "extends": ["../../tsconfig.json", "../../tsconfig.backend.json"],
"compilerOptions": { "compilerOptions": {
"outDir": "dist", "outDir": "dist",
"types": ["node"],
"preserveSymlinks": true, "preserveSymlinks": true,
// TODO: remove all options below this line // TODO: remove all options below this line
"noUnusedLocals": false, "noUnusedLocals": false,

View file

@ -2,8 +2,4 @@
module.exports = { module.exports = {
...require('../../jest.config'), ...require('../../jest.config'),
collectCoverageFrom: ['credentials/**/*.ts', 'nodes/**/*.ts', 'utils/**/*.ts'], collectCoverageFrom: ['credentials/**/*.ts', 'nodes/**/*.ts', 'utils/**/*.ts'],
moduleNameMapper: {
'^@test/(.*)$': '<rootDir>/test/$1',
'^@utils/(.*)$': '<rootDir>/utils/$1',
},
}; };

View file

@ -1,10 +1,7 @@
{ {
"extends": "./tsconfig.json", "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
"compilerOptions": { "compilerOptions": {
"outDir": "dist", "outDir": "dist"
"types": ["node"],
"noEmit": false,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
}, },
"include": [ "include": [
"credentials/**/*.ts", "credentials/**/*.ts",

View file

@ -1,9 +1,7 @@
{ {
"extends": "../../tsconfig.json", "extends": ["../../tsconfig.json", "../../tsconfig.backend.json"],
"compilerOptions": { "compilerOptions": {
"lib": ["dom", "es2020", "es2022.error"], "lib": ["dom", "es2020", "es2022.error"],
"types": ["node", "jest"],
"noEmit": true,
"paths": { "paths": {
"@test/*": ["./test/*"], "@test/*": ["./test/*"],
"@utils/*": ["./utils/*"] "@utils/*": ["./utils/*"]

View file

@ -1,11 +1,8 @@
{ {
"extends": "./tsconfig.json", "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
"compilerOptions": { "compilerOptions": {
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist"
"types": ["node"],
"noEmit": false,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
}, },
"include": ["src/**/*.ts"], "include": ["src/**/*.ts"],
"exclude": ["test/**"] "exclude": ["test/**"]

View file

@ -2,14 +2,11 @@
"extends": "../../tsconfig.json", "extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"rootDir": ".", "rootDir": ".",
"types": ["node", "jest"],
"composite": true, "composite": true,
"noEmit": true,
"baseUrl": "src", "baseUrl": "src",
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
}, },
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo",
// TODO: remove all options below this line // TODO: remove all options below this line
"useUnknownInCatchVariables": false "useUnknownInCatchVariables": false
}, },

View file

@ -108,9 +108,15 @@ importers:
ts-jest: ts-jest:
specifier: ^29.1.1 specifier: ^29.1.1
version: 29.1.1(@babel/core@7.22.9)(jest@29.6.2)(typescript@5.1.6) version: 29.1.1(@babel/core@7.22.9)(jest@29.6.2)(typescript@5.1.6)
tsc-alias:
specifier: ^1.8.7
version: 1.8.7
tsc-watch: tsc-watch:
specifier: ^6.0.4 specifier: ^6.0.4
version: 6.0.4(typescript@5.1.6) version: 6.0.4(typescript@5.1.6)
tsconfig-paths:
specifier: ^4.2.0
version: 4.2.0
turbo: turbo:
specifier: 1.10.12 specifier: 1.10.12
version: 1.10.12 version: 1.10.12
@ -556,12 +562,6 @@ importers:
ts-essentials: ts-essentials:
specifier: ^7.0.3 specifier: ^7.0.3
version: 7.0.3(typescript@5.1.6) version: 7.0.3(typescript@5.1.6)
tsc-alias:
specifier: ^1.8.7
version: 1.8.7
tsconfig-paths:
specifier: ^4.2.0
version: 4.2.0
packages/core: packages/core:
dependencies: dependencies:
@ -19805,7 +19805,7 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
dependencies: dependencies:
json5: 2.2.3 json5: 2.2.3
minimist: 1.2.7 minimist: 1.2.8
strip-bom: 3.0.0 strip-bom: 3.0.0
dev: true dev: true

7
tsconfig.backend.json Normal file
View file

@ -0,0 +1,7 @@
{
"compilerOptions": {
"types": ["node", "jest"],
"noEmit": true,
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo"
}
}

15
tsconfig.build.json Normal file
View file

@ -0,0 +1,15 @@
{
"compilerOptions": {
"types": ["node"],
"noEmit": false,
"declaration": true,
"tsBuildInfoFile": "dist/build.tsbuildinfo"
},
"tsc-alias": {
"replacers": {
"base-url": {
"enabled": false
}
}
}
}

View file

@ -16,7 +16,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"incremental": true, "incremental": true,
"declaration": true, "declaration": false,
"sourceMap": true, "sourceMap": true,
"skipLibCheck": true "skipLibCheck": true
}, },