From 95f35f0d9cbf03c0a10adb68f39fa7226fbe9538 Mon Sep 17 00:00:00 2001 From: Serge Ilyashenko Date: Sun, 12 May 2024 19:28:20 +0200 Subject: [PATCH] chore(all): tsconfig sharing via internal package --- README.md | 3 ++- apps/homepage-legacy/package.json | 3 ++- apps/homepage-legacy/tsconfig.json | 1 + config/tsconfig.package.json | 16 ++++++++++++++++ docs/contributing.md | 8 +++++++- docs/monorepo.md | 9 +++++---- docs/package-publishing.md | 2 +- package-lock.json | 3 +++ package.json | 1 + packages/pie-math/package.json | 2 +- packages/pie-math/tsconfig.json | 12 +----------- packages/react-simple-pie/package.json | 4 +--- packages/react-simple-pie/tsconfig.json | 12 ++---------- packages/simple-pie/package.json | 4 +--- packages/simple-pie/tsconfig.json | 12 +----------- turbo.json | 1 + 16 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 config/tsconfig.package.json diff --git a/README.md b/README.md index 9430647..aa8fd28 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ simple-pie-project └─ packages ├─ pie-math ├─ simple-pie - └─ react-simple-pie + ├─ react-simple-pie + └─ tsconfig ``` ## Installing packages diff --git a/apps/homepage-legacy/package.json b/apps/homepage-legacy/package.json index 333e9c3..59f1802 100644 --- a/apps/homepage-legacy/package.json +++ b/apps/homepage-legacy/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "tsc", + "lint-legacy": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview" }, "dependencies": { diff --git a/apps/homepage-legacy/tsconfig.json b/apps/homepage-legacy/tsconfig.json index a7fc6fb..f5ce6d0 100644 --- a/apps/homepage-legacy/tsconfig.json +++ b/apps/homepage-legacy/tsconfig.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, diff --git a/config/tsconfig.package.json b/config/tsconfig.package.json new file mode 100644 index 0000000..de425a4 --- /dev/null +++ b/config/tsconfig.package.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "preserveWatchOutput": true, + "skipLibCheck": true, + "noEmit": true, + "strict": true + }, + "include": ["src"], + "exclude": ["node_modules"] +} diff --git a/docs/contributing.md b/docs/contributing.md index 7595d73..67770c9 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -23,4 +23,10 @@ Some common ones are: ## Linting -🚧TBD +TypeScript can be used in one of two ways - as a linter, or as a build tool. +`noEmit` prevents emitting files. So, TS is used to check source code's types. + +`config` folder contains reusable `tsconfig.package.json`.\ +`apps/hompage-legacy` has its own tsconfig + +🚧 TBD diff --git a/docs/monorepo.md b/docs/monorepo.md index 3af0b37..f087d5d 100644 --- a/docs/monorepo.md +++ b/docs/monorepo.md @@ -17,6 +17,7 @@ The monorepo is split into `apps` and `packages`. ```tree simple-pie-project +├─ config ├─ docs ├─ apps │ └─ homepage-legacy @@ -32,10 +33,10 @@ They don't include any calculations and they are just "transport" packages (read ```mermaid flowchart TD - PM[packages/pie-math] --> SP[packages/simple-pie] - PM[packages/pie-math] --> RSP[packages/react-simple-pie] - SP --> HL[apps/homepage-legacy] + PM[packages/pie-math] --> SP + PM --> RSP[packages/react-simple-pie] + SP[packages/simple-pie] --> HL[apps/homepage-legacy] RSP --> HL - SP -.-> NPM[npm] + SP -.-> NPM([📦 npm]) RSP -.-> NPM ``` diff --git a/docs/package-publishing.md b/docs/package-publishing.md index 52c3b72..bfe6208 100644 --- a/docs/package-publishing.md +++ b/docs/package-publishing.md @@ -1,6 +1,6 @@ # Package publishing -The publishing is applied to the next packages: +The publishing is applied to external packages. The next ones: - `packages/simple-pie` - `packages/react-simple-pie` diff --git a/package-lock.json b/package-lock.json index f3deaa7..3591188 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7752,6 +7752,9 @@ "pie-math": "*", "tsup": "8.0.2" } + }, + "packages/tsconfig": { + "extraneous": true } } } diff --git a/package.json b/package.json index b3a6601..8783a36 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dev": "turbo dev", "build": "turbo build", "build:packages": "turbo build --filter='./packages/*'", + "lint": "turbo lint", "changeset": "npx changeset", "release": "changeset publish", "prettier": "prettier --write .", diff --git a/packages/pie-math/package.json b/packages/pie-math/package.json index fdfee2d..729d05f 100644 --- a/packages/pie-math/package.json +++ b/packages/pie-math/package.json @@ -4,7 +4,7 @@ "main": "./src/index.ts", "private": true, "scripts": { - "type-check": "tsc" + "lint": "tsc" }, "author": "Serge Iyashenko ", "repository": "https://github.com/serjilyashenko/simple-pie-project", diff --git a/packages/pie-math/tsconfig.json b/packages/pie-math/tsconfig.json index 803840c..63c7072 100644 --- a/packages/pie-math/tsconfig.json +++ b/packages/pie-math/tsconfig.json @@ -1,15 +1,5 @@ { - "compilerOptions": { - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "isolatedModules": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "skipLibCheck": true, - "noEmit": true, - "strict": true - }, + "extends": "../../config/tsconfig.package.json", "include": ["src"], "exclude": ["node_modules"] } diff --git a/packages/react-simple-pie/package.json b/packages/react-simple-pie/package.json index 058310b..b3c5909 100644 --- a/packages/react-simple-pie/package.json +++ b/packages/react-simple-pie/package.json @@ -12,9 +12,7 @@ "scripts": { "dev": "npm run build -- --watch", "build": "tsup src/index.ts --format cjs,esm --dts --minify", - "npm:publish": "npm version patch && npm publish", - "type-check": "tsc", - "lint": "eslint src" + "lint": "tsc" }, "devDependencies": { "@types/react": "18.2.64", diff --git a/packages/react-simple-pie/tsconfig.json b/packages/react-simple-pie/tsconfig.json index 7b1fadb..07c6582 100644 --- a/packages/react-simple-pie/tsconfig.json +++ b/packages/react-simple-pie/tsconfig.json @@ -1,15 +1,7 @@ { + "extends": "../../config/tsconfig.package.json", "compilerOptions": { - "jsx": "react-jsx", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "isolatedModules": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "skipLibCheck": true, - "noEmit": true, - "strict": true + "jsx": "react-jsx" }, "include": ["src"], "exclude": ["node_modules"] diff --git a/packages/simple-pie/package.json b/packages/simple-pie/package.json index f2cca09..3bc81ad 100644 --- a/packages/simple-pie/package.json +++ b/packages/simple-pie/package.json @@ -12,9 +12,7 @@ "scripts": { "dev": "npm run build -- --watch", "build": "tsup src/index.ts --format cjs,esm --dts --minify", - "npm:publish": "npm version patch && npm publish", - "type-check": "tsc", - "lint": "eslint src" + "lint": "tsc" }, "devDependencies": { "pie-math": "*", diff --git a/packages/simple-pie/tsconfig.json b/packages/simple-pie/tsconfig.json index 803840c..63c7072 100644 --- a/packages/simple-pie/tsconfig.json +++ b/packages/simple-pie/tsconfig.json @@ -1,15 +1,5 @@ { - "compilerOptions": { - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "isolatedModules": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "skipLibCheck": true, - "noEmit": true, - "strict": true - }, + "extends": "../../config/tsconfig.package.json", "include": ["src"], "exclude": ["node_modules"] } diff --git a/turbo.json b/turbo.json index 61cdadd..f5c2175 100644 --- a/turbo.json +++ b/turbo.json @@ -5,6 +5,7 @@ "dependsOn": ["^build"], "outputs": ["dist/**"] }, + "lint": {}, "dev": { "cache": false, "persistent": true,