Skip to content

Commit

Permalink
Merge pull request #2043 from guardian/aa/tsconfig
Browse files Browse the repository at this point in the history
chore: Adopt `@guardian/tsconfig` to simplify `tsconfig.json`
  • Loading branch information
akash1810 authored Oct 5, 2023
2 parents c68b5a6 + d43919a commit 173f134
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/commands/new-project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
28 changes: 2 additions & 26 deletions src/bin/commands/new-project/template/tsconfig.json.template
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
20 changes: 11 additions & 9 deletions src/bin/commands/new-project/utils/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
1 change: 1 addition & 0 deletions src/bin/commands/new-project/utils/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function createPackageJson(outputDirectory: string): void {

const coreDeps: Record<string, string> = [
"@guardian/eslint-config-typescript",
"@guardian/tsconfig",
"@types/jest",
"@types/node",
"eslint",
Expand Down
1 change: 1 addition & 0 deletions tools/integration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 2 additions & 26 deletions tools/integration-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"
Expand Down
11 changes: 1 addition & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"],
Expand Down

0 comments on commit 173f134

Please sign in to comment.