From e47faaeb5ce7c920aea995272a71b59a6b245f28 Mon Sep 17 00:00:00 2001 From: Oskar Dudycz Date: Mon, 19 Feb 2024 11:34:55 +0100 Subject: [PATCH] Configured typescript and lint to allow build without running it on each package --- .eslintrc.json | 2 +- .../gettingStarted/businessLogic.unit.spec.ts | 1 + docs/snippets/gettingStarted/state.ts | 1 + package-lock.json | 1 - package.json | 4 ++-- packages/emmett-esdb/tsconfig.build.json | 3 ++- packages/emmett-esdb/tsconfig.json | 16 +++++++++++++--- packages/emmett-expressjs/src/etag.ts | 6 +++--- packages/emmett-expressjs/tsconfig.json | 13 ++++++++++--- packages/emmett/tsconfig.json | 6 ++++-- tsconfig.json | 13 +++++++++++-- tsconfig.shared.json | 9 +-------- 12 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a0f93312..305e3dc9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,7 @@ "parserOptions": { "ecmaVersion": 2023, "sourceType": "module", - "project": "tsconfig.json" + "project": "./tsconfig.json" }, "rules": { "no-unused-vars": "off", diff --git a/docs/snippets/gettingStarted/businessLogic.unit.spec.ts b/docs/snippets/gettingStarted/businessLogic.unit.spec.ts index add462b5..ad538472 100644 --- a/docs/snippets/gettingStarted/businessLogic.unit.spec.ts +++ b/docs/snippets/gettingStarted/businessLogic.unit.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-floating-promises */ import { describe, it } from 'node:test'; import { v4 as uuid } from 'uuid'; import { decide } from './businessLogic'; diff --git a/docs/snippets/gettingStarted/state.ts b/docs/snippets/gettingStarted/state.ts index 6d96746d..b481e9cd 100644 --- a/docs/snippets/gettingStarted/state.ts +++ b/docs/snippets/gettingStarted/state.ts @@ -7,6 +7,7 @@ export type EmptyShoppingCart = { export type OpenedShoppingCart = { status: 'Opened'; + productItems: ProductItems; }; diff --git a/package-lock.json b/package-lock.json index f0f504fa..7885bbdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "packages/emmett-expressjs" ], "devDependencies": { - "@event-driven-io/emmett": "0.1.8", "@faker-js/faker": "8.4.1", "@types/express": "4.17.21", "@types/node": "20.11.17", diff --git a/package.json b/package.json index 08798906..7bc0db23 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "scripts": { "setup": "cat .nvmrc | nvm install; nvm use", "build": "npm run build --ws", - "build:ts": "npm run build:ts --ws", - "build:ts:watch": "npm run build:ts:watch --ws", + "build:ts": "tsc -b", + "build:ts:watch": "tsc -b --watch", "lint": "npm run lint --ws", "fix": "npm run fix --ws", "test": "run-s test:unit test:int test:e2e", diff --git a/packages/emmett-esdb/tsconfig.build.json b/packages/emmett-esdb/tsconfig.build.json index 80b6a0a8..eb45422c 100644 --- a/packages/emmett-esdb/tsconfig.build.json +++ b/packages/emmett-esdb/tsconfig.build.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "composite": false + "composite": false, + "paths": {} } } diff --git a/packages/emmett-esdb/tsconfig.json b/packages/emmett-esdb/tsconfig.json index c3e2e8de..c9a4e83e 100644 --- a/packages/emmett-esdb/tsconfig.json +++ b/packages/emmett-esdb/tsconfig.json @@ -1,7 +1,17 @@ { "extends": "../../tsconfig.shared.json", - "include": ["./src/**/*", "./tsup.config.ts"], + "include": ["./src/**/*"], "compilerOptions": { - "composite": true - } + "composite": true, + "outDir": "./dist" /* Redirect output structure to the directory. */, + "rootDir": "./src", + "paths": { + "@event-driven-io/emmett": ["../emmett"] + } + }, + "references": [ + { + "path": "../emmett/" + } + ] } diff --git a/packages/emmett-expressjs/src/etag.ts b/packages/emmett-expressjs/src/etag.ts index c45a6dbb..03be6157 100644 --- a/packages/emmett-expressjs/src/etag.ts +++ b/packages/emmett-expressjs/src/etag.ts @@ -23,11 +23,11 @@ export const enum ETagErrors { } export const isWeakETag = (etag: ETag): etag is WeakETag => { - return WeakETagRegex.test(etag); + return WeakETagRegex.test(etag as string); }; export const getWeakETagValue = (etag: ETag): string => { - const result = WeakETagRegex.exec(etag); + const result = WeakETagRegex.exec(etag as string); if (result === null || result.length === 0) { throw new Error(ETagErrors.WRONG_WEAK_ETAG_FORMAT); } @@ -59,5 +59,5 @@ export const getETagFromIfNotMatch = (request: Request): ETag => { }; export const setETag = (response: Response, etag: ETag): void => { - response.setHeader(HeaderNames.ETag, etag); + response.setHeader(HeaderNames.ETag, etag as string); }; diff --git a/packages/emmett-expressjs/tsconfig.json b/packages/emmett-expressjs/tsconfig.json index 13880cc2..8f1f6c9f 100644 --- a/packages/emmett-expressjs/tsconfig.json +++ b/packages/emmett-expressjs/tsconfig.json @@ -1,10 +1,17 @@ { "extends": "../../tsconfig.shared.json", - "include": ["./src/**/*", "./tsup.config.ts"], + "include": ["./src/**/*"], "compilerOptions": { "composite": true, + "outDir": "./dist" /* Redirect output structure to the directory. */, + "rootDir": "./src", "paths": { - "@event-driven-io/emmett": ["./packages/emmett/src"] + "@event-driven-io/emmett": ["./packages/emmett"] } - } + }, + "references": [ + { + "path": "../emmett/" + } + ] } diff --git a/packages/emmett/tsconfig.json b/packages/emmett/tsconfig.json index c3e2e8de..835c6888 100644 --- a/packages/emmett/tsconfig.json +++ b/packages/emmett/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../../tsconfig.shared.json", - "include": ["./src/**/*", "./tsup.config.ts"], + "include": ["./src/**/*"], "compilerOptions": { - "composite": true + "composite": true, + "outDir": "./dist" /* Redirect output structure to the directory. */, + "rootDir": "./src" } } diff --git a/tsconfig.json b/tsconfig.json index 4ee0c181..3375f08b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,18 @@ { "extends": "./tsconfig.shared.json", - "include": ["./packages/**/*", "./packages/**/**/*", "./tsup.config.ts"], + "include": ["docs/**/*.ts", "./tsup.config.ts"], + "exclude": ["node_modules", "tmp"], "files": [], "compilerOptions": { - "noEmit": true /* Do not emit outputs. */ + "disableSourceOfProjectReferenceRedirect": true, + "noEmit": true /* Do not emit outputs. */, + "paths": { + "@event-driven-io/emmett": ["./packages/emmett/src"], + "@event-driven-io/emmett-expressjs": ["./packages/emmett-expressjs/src"], + "@event-driven-io/emmett-eventstoredb": [ + "./packages/emmett-eventstoredb/src" + ] + } }, "references": [ { diff --git a/tsconfig.shared.json b/tsconfig.shared.json index 774d29e4..24bfc23a 100644 --- a/tsconfig.shared.json +++ b/tsconfig.shared.json @@ -18,7 +18,7 @@ "sourceMap": true /* Generates corresponding '.map' file. */, // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./dist" /* Redirect output structure to the directory. */, - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "rootDir": "./" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ @@ -48,13 +48,6 @@ /* Module Resolution Options */ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, "baseUrl": "./" /* Base directory to resolve non-absolute module names. */, - "paths": { - "@event-driven-io/emmett": ["./packages/emmett/src"], - "@event-driven-io/emmett-expressjs": ["./packages/emmett-expressjs/src"], - "@event-driven-io/emmett-eventstoredb": [ - "./packages/emmett-eventstoredb/src" - ] - } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */