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/docs/contributing.md b/docs/contributing.md index 7595d73..23b507c 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -23,4 +23,18 @@ 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. + +tsconfig for `packages/*` is shared from the `packages/tsconfig` package. `apps/hompage-legacy` has +its own tsconfig + +```mermaid +flowchart + T[packages/tsconfig] --> PM[packages/pie-math] + T --> SP[packages/simple-pie] + T --> RSP[packages/react-simple-pie] + HL[apps/homepage-legacy] +``` + +🚧 TBD diff --git a/docs/monorepo.md b/docs/monorepo.md index 3af0b37..f2db055 100644 --- a/docs/monorepo.md +++ b/docs/monorepo.md @@ -23,17 +23,22 @@ simple-pie-project └─ packages ├─ pie-math ├─ simple-pie - └─ react-simple-pie + ├─ react-simple-pie + └─ tsconfig ``` `packages/pie-math` includes all calculations (business logic).\ `packages/simple-pie` and `packages/react-simple-pie` are external and are published to npm. -They don't include any calculations and they are just "transport" packages (read more in [package-publishing.md](./package-publishing.md)). +They don't include any calculations and they are just "transport" packages (read more in [package-publishing.md](./package-publishing.md)).\ +`packages/tsconfig` just shares tsconfigs for packages. ```mermaid flowchart TD - PM[packages/pie-math] --> SP[packages/simple-pie] - PM[packages/pie-math] --> RSP[packages/react-simple-pie] + T[packages/tsconfig] --> PM[packages/pie-math] + T --> SP[packages/simple-pie] + PM --> SP + PM --> RSP[packages/react-simple-pie] + T --> RSP SP --> HL[apps/homepage-legacy] RSP --> HL SP -.-> NPM[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..8bd5a4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6498,6 +6498,10 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "dev": true }, + "node_modules/tsconfig": { + "resolved": "packages/tsconfig", + "link": true + }, "node_modules/tsup": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.0.2.tgz", @@ -7729,7 +7733,10 @@ }, "packages/pie-math": { "version": "0.0.1", - "license": "MIT" + "license": "MIT", + "devDependencies": { + "tsconfig": "*" + } }, "packages/react-simple-pie": { "version": "1.1.2", @@ -7752,6 +7759,7 @@ "pie-math": "*", "tsup": "8.0.2" } - } + }, + "packages/tsconfig": {} } } 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..3d8fe64 100644 --- a/packages/pie-math/package.json +++ b/packages/pie-math/package.json @@ -4,7 +4,10 @@ "main": "./src/index.ts", "private": true, "scripts": { - "type-check": "tsc" + "lint": "tsc" + }, + "devDependencies": { + "tsconfig": "*" }, "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..6833d4f 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": "tsconfig/pkg.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..5703c3b 100644 --- a/packages/react-simple-pie/tsconfig.json +++ b/packages/react-simple-pie/tsconfig.json @@ -1,15 +1,7 @@ { + "extends": "tsconfig/pkg.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..6833d4f 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": "tsconfig/pkg.json", "include": ["src"], "exclude": ["node_modules"] } diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json new file mode 100644 index 0000000..8c6576b --- /dev/null +++ b/packages/tsconfig/package.json @@ -0,0 +1,4 @@ +{ + "name": "tsconfig", + "private": true +} diff --git a/packages/tsconfig/pkg.json b/packages/tsconfig/pkg.json new file mode 100644 index 0000000..de425a4 --- /dev/null +++ b/packages/tsconfig/pkg.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/packages/tsconfig/vite.json b/packages/tsconfig/vite.json new file mode 100644 index 0000000..1a23a3b --- /dev/null +++ b/packages/tsconfig/vite.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/tsconfig/vite.node.json b/packages/tsconfig/vite.node.json new file mode 100644 index 0000000..e69de29 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,