diff --git a/.gitignore b/.gitignore index 1989315ace..df1bf1fedf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ yarn-error.log node_modules # This repository currently uses npm over yarn due to some complications in releasing the library with yarn yarn.lock + +tsconfig.tsbuildinfo diff --git a/package-lock.json b/package-lock.json index b7d403ddb9..0ced3fe060 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "devDependencies": { "@guardian/eslint-config-typescript": "7.0.0", "@guardian/eslint-plugin-tsdoc-required": "^0.1.3", + "@guardian/tsconfig": "^0.2.0", "@types/git-url-parse": "^9.0.1", "@types/jest": "^29.5.5", "@types/js-yaml": "^4.0.6", @@ -880,6 +881,12 @@ "integrity": "sha512-ohk4/a0Kq9oEq4sSBFS+0XU3AjANwcEbK5HgBHNyIBZgc+7SU0ws+3/7W9QrBZts1lXkOhqBrIW+D+PG5Rk39A==", "dev": true }, + "node_modules/@guardian/tsconfig": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@guardian/tsconfig/-/tsconfig-0.2.0.tgz", + "integrity": "sha512-RauppalK+cQZDRK6IssVmDSnU/VyqMNuVOxPxhmI03kVRxEdwcmBuRqexHwDbnClVUxW/N9hYLbFNuAb9V/p+A==", + "dev": true + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.11", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", diff --git a/package.json b/package.json index 29493389b9..f2fbd905eb 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@guardian/eslint-config-typescript": "7.0.0", "@guardian/eslint-plugin-tsdoc-required": "^0.1.3", + "@guardian/tsconfig": "^0.2.0", "@types/git-url-parse": "^9.0.1", "@types/jest": "^29.5.5", "@types/js-yaml": "^4.0.6", diff --git a/src/bin/commands/new-project/index.ts b/src/bin/commands/new-project/index.ts index 55179ff0fd..eba4e95ca6 100644 --- a/src/bin/commands/new-project/index.ts +++ b/src/bin/commands/new-project/index.ts @@ -117,7 +117,7 @@ export const newCdkProject = async (props: NewProjectProps): CliCommandResponse // lib directory await constructStack({ - imports: Imports.newStackImports(), + imports: Imports.newStackImports(!!config.yamlTemplateLocation), appName: config.appName, outputFile: basename(config.stackPath), outputDir: dirname(config.stackPath), diff --git a/src/bin/commands/new-project/template/tsconfig.json.template b/src/bin/commands/new-project/template/tsconfig.json.template index dc83b2ce96..d3899d53df 100644 --- a/src/bin/commands/new-project/template/tsconfig.json.template +++ b/src/bin/commands/new-project/template/tsconfig.json.template @@ -1,31 +1,7 @@ { - "ts-node": { - "compilerOptions": { - "module": "CommonJS" - } - }, + "extends": "@guardian/tsconfig/tsconfig.json", "compilerOptions": { - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "node", - "lib": ["ES2020"], - "declaration": true, - "strict": true, - "noImplicitAny": true, - "strictNullChecks": true, - "esModuleInterop": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": false, - "inlineSourceMap": true, - "inlineSources": true, - "experimentalDecorators": true, - "strictPropertyInitialization": false, - "typeRoots": ["./node_modules/@types"], - "outDir": "dist" + "module": "CommonJS" }, "include": ["lib/**/*", "bin/**/*"], "exclude": [ diff --git a/src/bin/commands/new-project/utils/imports.ts b/src/bin/commands/new-project/utils/imports.ts index 699cae6ed6..04079cfc30 100644 --- a/src/bin/commands/new-project/utils/imports.ts +++ b/src/bin/commands/new-project/utils/imports.ts @@ -14,16 +14,18 @@ export class Imports { this.imports = imports; } - public static newStackImports(): Imports { + public static newStackImports(addCfnIncludeImports: boolean): Imports { return new Imports({ - path: { - types: [], - components: ["join"], - }, - "aws-cdk-lib/cloudformation-include": { - types: [], - components: ["CfnInclude"], - }, + ...(addCfnIncludeImports && { + path: { + types: [], + components: ["join"], + }, + "aws-cdk-lib/cloudformation-include": { + types: [], + components: ["CfnInclude"], + }, + }), "aws-cdk-lib": { types: ["App"], components: [], diff --git a/src/bin/commands/new-project/utils/init.ts b/src/bin/commands/new-project/utils/init.ts index 49f98f36d6..db2b6dbe22 100644 --- a/src/bin/commands/new-project/utils/init.ts +++ b/src/bin/commands/new-project/utils/init.ts @@ -72,6 +72,7 @@ function createPackageJson(outputDirectory: string): void { const coreDeps: Record = [ "@guardian/eslint-config-typescript", + "@guardian/tsconfig", "@types/jest", "@types/node", "eslint", diff --git a/tools/integration-test/package.json b/tools/integration-test/package.json index 607d1d8947..ae3ae17b7f 100644 --- a/tools/integration-test/package.json +++ b/tools/integration-test/package.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@guardian/eslint-config-typescript": "7.0.0", + "@guardian/tsconfig": "^0.2.0", "@types/jest": "^29.1.2", "@types/node": "20.8.2", "aws-cdk": "2.95.1", diff --git a/tools/integration-test/tsconfig.json b/tools/integration-test/tsconfig.json index 44c26517fe..7110e735b4 100644 --- a/tools/integration-test/tsconfig.json +++ b/tools/integration-test/tsconfig.json @@ -1,31 +1,7 @@ { - "ts-node": { - "compilerOptions": { - "module": "CommonJS" - } - }, + "extends": "@guardian/tsconfig/tsconfig.json", "compilerOptions": { - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "node", - "lib": ["ES2020"], - "declaration": true, - "strict": true, - "noImplicitAny": true, - "strictNullChecks": true, - "esModuleInterop": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": false, - "inlineSourceMap": true, - "inlineSources": true, - "experimentalDecorators": true, - "strictPropertyInitialization": false, - "typeRoots": ["./node_modules/@types"], - "outDir": "dist" + "module": "CommonJS" }, "include": [ "src/**/*", "bin/**/*" diff --git a/tsconfig.json b/tsconfig.json index 14832762d3..6c9467df93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,13 @@ { + "extends": "@guardian/tsconfig/tsconfig.json", "compilerOptions": { "target": "ES2020", "module": "commonjs", - "moduleResolution": "node", "declaration": true, "declarationMap": true, - "esModuleInterop": true, - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, "sourceMap": true, "inlineSourceMap": false, "inlineSources": true, - "experimentalDecorators": true, - "typeRoots": ["./node_modules/@types"], "outDir": "lib" }, "include": ["src/**/*"],