fix(typescript): Use consistent typescript configs - N8N-4552 (#4049)

fix(typescript): Use consistent typescript configs

make all packages inherit tsconfig from the root tsconfig
skips building tests. reformat all tsconfigs with prettier.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-09-09 18:00:18 +02:00 committed by GitHub
parent 2c7ef1e550
commit 9267e8fb12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 98 additions and 268 deletions

View file

@ -7,7 +7,7 @@ RUN \
apk --no-cache add git && \ apk --no-cache add git && \
npm install -g run-script-os turbo npm install -g run-script-os turbo
COPY turbo.json package.json package-lock.json ./ COPY turbo.json package.json package-lock.json tsconfig.json ./
COPY packages ./packages COPY packages ./packages
RUN chown -R node:node . RUN chown -R node:node .
@ -21,7 +21,7 @@ RUN \
# TODO: removing dev dependecies is deleting `bn.js`, which breaks the Snowflake node # TODO: removing dev dependecies is deleting `bn.js`, which breaks the Snowflake node
npm prune --omit=dev && \ npm prune --omit=dev && \
npm i --omit=dev bn.js && \ npm i --omit=dev bn.js && \
find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" | xargs rm &&\ find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" | xargs rm &&\
rm -rf node_modules/.cache packages/*/node_modules/.cache packages/*/.turbo .config .npm /tmp/* rm -rf node_modules/.cache packages/*/node_modules/.cache packages/*/.turbo .config .npm /tmp/*

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
verbose: true, verbose: true,
transform: { transform: {
'^.+\\.ts?$': 'ts-jest', '^.+\\.ts$': 'ts-jest',
}, },
testURL: 'http://localhost/', testURL: 'http://localhost/',
testRegex: '(/__tests__/.*|(\\.|/)(test))\\.ts$', testRegex: '(/__tests__/.*|(\\.|/)(test))\\.ts$',

View file

@ -1,40 +1,14 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [ "outDir": "dist",
"es2017", "types": ["node", "jest"],
"ES2020.Promise"
],
"types": [
"node",
"jest"
],
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"incremental": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"preserveConstEnums": true,
"declaration": true,
"outDir": "./dist/",
"target": "es2017",
"sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"esModuleInterop": true // TODO: remove all options below this line
"strict": false,
"noUnusedLocals": false,
"useUnknownInCatchVariables": false
}, },
"include": [ "include": ["**/*.d.ts", "commands/**/*", "config/**/*", "src/**/*"]
"**/*.d.ts",
"commands/**/*",
"index.ts",
"config/**/*",
"src/**/*",
"test/**/*"
],
"exclude": [
"dist/**/*",
"node_modules/**/*",
"**/*.spec.ts"
]
} }

View file

@ -61,17 +61,16 @@
}, },
"jest": { "jest": {
"transform": { "transform": {
"^.+\\.tsx?$": "ts-jest" "^.+\\.ts$": "ts-jest"
}, },
"testURL": "http://localhost/", "testURL": "http://localhost/",
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$",
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"/dist/", "/dist/",
"/node_modules/" "/node_modules/"
], ],
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
"tsx",
"js", "js",
"json", "json",
"node" "node"

View file

@ -1,35 +1,11 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [ "rootDir": ".",
"es2019" "outDir": "dist",
], "types": ["node", "jest"],
"types": [ // TODO: remove all options below this line
"node", "useUnknownInCatchVariables": false
"jest"
],
"module": "commonjs",
"incremental": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"strict": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"declaration": true,
"outDir": "./dist/",
"target": "es2019",
"sourceMap": true,
"esModuleInterop": true,
"useUnknownInCatchVariables": false,
}, },
"include": [ "include": ["src/**/*.ts"]
"**/*.d.ts",
"src/**/*",
"test/**/*"
],
"exclude": [
"dist/**/*",
"node_modules/**/*",
"**/*.spec.ts"
]
} }

View file

@ -4,7 +4,7 @@ const path = require('path');
* @type {import('@storybook/core-common').StorybookConfig} * @type {import('@storybook/core-common').StorybookConfig}
*/ */
module.exports = { module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|ts)'],
addons: [ addons: [
'@storybook/addon-links', '@storybook/addon-links',
'@storybook/addon-essentials', '@storybook/addon-essentials',

View file

@ -1,13 +0,0 @@
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}

View file

@ -1,38 +1,24 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"rootDir": ".",
"outDir": "dist",
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"strict": true,
"importHelpers": true, "importHelpers": true,
"moduleResolution": "node",
"declaration": true,
"experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"incremental": true,
"esModuleInterop": true,
"allowJs": true, "allowJs": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"outDir": "dist", "types": ["webpack-env", "jest", "vitest/globals"],
"types": [ "typeRoots": ["@testing-library", "@types"],
"webpack-env",
"jest",
"vitest/globals"
],
"typeRoots": [
"@testing-library",
"@types"
],
"paths": { "paths": {
"@/*": ["src/*"] "@/*": ["src/*"]
}, },
"lib": ["esnext", "dom", "dom.iterable", "scripthost"] "lib": ["esnext", "dom", "dom.iterable", "scripthost"],
// TODO: remove all options below this line
"noUnusedLocals": false,
"noImplicitReturns": false
}, },
"include": [ "include": ["src/**/*.ts", "src/**/*.vue"]
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
"exclude": ["node_modules"]
} }

View file

@ -1,16 +1,14 @@
module.exports = { module.exports = {
moduleFileExtensions: [ moduleFileExtensions: [
'js', 'js',
'jsx',
'json', 'json',
'vue', 'vue',
'ts', 'ts',
'tsx',
], ],
transform: { transform: {
'^.+\\.vue$': 'vue-jest', '^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.tsx?$': 'ts-jest', '^.+\\.ts$': 'ts-jest',
}, },
moduleNameMapper: { moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1', '^@/(.*)$': '<rootDir>/src/$1',
@ -19,7 +17,7 @@ module.exports = {
'jest-serializer-vue', 'jest-serializer-vue',
], ],
testMatch: [ testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', '**/tests/unit/**/*.spec.(js|ts)|**/__tests__/*.(js|ts)',
], ],
testURL: 'http://localhost/', testURL: 'http://localhost/',
}; };

View file

@ -1,13 +0,0 @@
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}

View file

@ -1,46 +1,23 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"rootDir": ".",
"outDir": "dist",
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"strict": true,
"jsx": "preserve",
"skipLibCheck": true, "skipLibCheck": true,
"incremental": true, "allowJs": true,
"importHelpers": true, "importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"useUnknownInCatchVariables": false,
"resolveJsonModule": true,
"sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": ["webpack-env", "jest"],
"webpack-env",
"jest"
],
"paths": { "paths": {
"@/*": [ "@/*": ["src/*"]
"src/*"
]
}, },
"lib": [ "lib": ["esnext", "dom", "dom.iterable", "scripthost"],
"esnext", // TODO: remove all options below this line
"dom", "noUnusedLocals": false,
"dom.iterable", "useUnknownInCatchVariables": false
"scripthost"
]
}, },
"include": [ "include": ["src/**/*.ts", "src/**/*.vue"]
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
],
"exclude": [
"node_modules"
]
} }

View file

@ -1,22 +1,10 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [
"es2017"
],
"types": [],
"module": "commonjs",
"incremental": true,
"importHelpers": true, "importHelpers": true,
"preserveConstEnums": true,
"declaration": true,
"target": "es2017",
"sourceMap": true
}, },
"include": [ "include": [
"*.credentials.ts", "*.credentials.ts",
"*.node.ts" "*.node.ts"
],
"exclude": [
"node_modules"
] ]
} }

View file

@ -1,32 +1,11 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [ "outDir": "dist",
"es2019" "types": ["node"],
], // TODO: remove all options below this line
"types": [ "noUnusedLocals": false,
"node" "useUnknownInCatchVariables": false
],
"module": "commonjs",
"incremental": true,
"esModuleInterop": true,
"removeComments": true,
"strict": true,
"preserveConstEnums": true,
"declaration": true,
"outDir": "./dist/",
"target": "es2019",
"useUnknownInCatchVariables": false,
"sourceMap": true
}, },
"include": [ "include": ["commands/**/*.ts", "src/**/*.ts"]
"**/*.d.ts",
"commands/**/*",
"index.ts",
"src/**/*"
],
"exclude": [
"dist",
"node_modules/**/*",
"**/*.spec.ts"
]
} }

View file

@ -795,17 +795,16 @@
}, },
"jest": { "jest": {
"transform": { "transform": {
"^.+\\.tsx?$": "ts-jest" "^.+\\.ts$": "ts-jest"
}, },
"testURL": "http://localhost/", "testURL": "http://localhost/",
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$",
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"/dist/", "/dist/",
"/node_modules/" "/node_modules/"
], ],
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
"tsx",
"js", "js",
"json" "json"
] ]

View file

@ -1,35 +1,19 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [ "outDir": "dist",
"dom", "lib": ["dom", "es2020"],
"es2019" "types": ["node", "jest"],
], // TODO: remove all options below this line
"types": [ "noImplicitReturns": false,
"node", "noUnusedLocals": false,
"jest" "useUnknownInCatchVariables": false
],
"module": "commonjs",
"incremental": true,
"removeComments": true,
"strict": true,
"preserveConstEnums": true,
"resolveJsonModule": true,
"declaration": true,
"outDir": "./dist/",
"target": "es2019",
"sourceMap": true,
"esModuleInterop": true,
"useUnknownInCatchVariables": false,
}, },
"include": [ "include": [
"credentials/**/*", "credentials/**/*.ts",
"src/**/*", "src/**/*.ts",
"nodes/**/*", "nodes/**/*.ts",
"nodes/**/*.json", "nodes/**/*.json",
"credentials/translations/**/*.json", "credentials/translations/**/*.json"
"test/**/*"
],
"exclude": [
"**/*.spec.ts"
] ]
} }

View file

@ -62,17 +62,16 @@
}, },
"jest": { "jest": {
"transform": { "transform": {
"^.+\\.tsx?$": "ts-jest" "^.+\\.ts$": "ts-jest"
}, },
"testURL": "http://localhost/", "testURL": "http://localhost/",
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$",
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"/dist/", "/dist/",
"/node_modules/" "/node_modules/"
], ],
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
"tsx",
"js", "js",
"json" "json"
] ]

View file

@ -1,37 +1,11 @@
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"lib": [ "rootDir": ".",
"dom", "outDir": "dist",
"es2019" "types": ["node", "jest"],
], // TODO: remove all options below this line
"types": [ "useUnknownInCatchVariables": false
"node",
"jest"
],
"module": "commonjs",
"incremental": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"noImplicitReturns": true,
"strict": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"declaration": true,
"outDir": "./dist/",
"target": "es2019",
"moduleResolution": "node",
"sourceMap": true,
"useUnknownInCatchVariables": false,
}, },
"include": [ "include": ["src/**/*.ts"]
"**/*.d.ts",
"src/**/*",
"test/**/*"
],
"exclude": [
"dist/**/*",
"node_modules/**/*",
"**/*.spec.ts"
]
} }

23
tsconfig.json Normal file
View file

@ -0,0 +1,23 @@
{
"compilerOptions": {
"strict": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es2019",
"lib": ["es2019", "es2020"],
"removeComments": true,
"useUnknownInCatchVariables": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"preserveConstEnums": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"declaration": true,
"sourceMap": true
},
"exclude": ["**/dist/**/*", "**/node_modules/**/*"]
}