From 07b88f57f8aa3bcc3be8134571a77e3ebde3931b Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 6 Feb 2025 13:18:24 +0100 Subject: [PATCH] chore(devtools): add shared typescript config (#943) --- Dockerfile | 2 ++ package-lock.json | 27 +++++++++++++++++++ package.json | 2 ++ packages/core/tsconfig.json | 11 ++------ packages/crisp/tsconfig.json | 6 +---- packages/debounce/package.json | 4 ++- .../debounce/src/api/single-validation.ts | 2 +- packages/debounce/tsconfig.json | 11 ++------ .../devtools/typescript/base/tsconfig.json | 26 ++++++++++++++++++ packages/devtools/typescript/package.json | 10 +++++++ packages/email/tsconfig.json | 13 ++------- packages/identite/tsconfig.json | 12 ++------- .../formatters/libelle-from-code-effectif.ts | 2 +- packages/insee/tsconfig.json | 11 ++------ tsconfig.json | 17 +++++------- 15 files changed, 89 insertions(+), 67 deletions(-) create mode 100644 packages/devtools/typescript/base/tsconfig.json create mode 100644 packages/devtools/typescript/package.json diff --git a/Dockerfile b/Dockerfile index 879545c05..f9e0d4614 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ RUN --mount=type=bind,source=package.json,target=package.json \ --mount=type=bind,source=packages/core/package.json,target=packages/core/package.json \ --mount=type=bind,source=packages/crisp/package.json,target=packages/crisp/package.json \ --mount=type=bind,source=packages/debounce/package.json,target=packages/debounce/package.json \ + --mount=type=bind,source=packages/devtools/typescript/package.json,target=packages/devtools/typescript/package.json \ --mount=type=bind,source=packages/email/package.json,target=packages/email/package.json \ --mount=type=bind,source=packages/identite/package.json,target=packages/identite/package.json \ --mount=type=bind,source=packages/insee/package.json,target=packages/insee/package.json \ @@ -25,6 +26,7 @@ RUN --mount=type=bind,source=package.json,target=package.json \ --mount=type=bind,source=packages/core/package.json,target=packages/core/package.json \ --mount=type=bind,source=packages/crisp/package.json,target=packages/crisp/package.json \ --mount=type=bind,source=packages/debounce/package.json,target=packages/debounce/package.json \ + --mount=type=bind,source=packages/devtools/typescript/package.json,target=packages/devtools/typescript/package.json \ --mount=type=bind,source=packages/email/package.json,target=packages/email/package.json \ --mount=type=bind,source=packages/identite/package.json,target=packages/identite/package.json \ --mount=type=bind,source=packages/insee/package.json,target=packages/insee/package.json \ diff --git a/package-lock.json b/package-lock.json index 2286e60d7..2dc3c09b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "MIT", "workspaces": [ + "packages/devtools/typescript", "packages/core", "packages/crisp", "packages/debounce", @@ -20,6 +21,7 @@ "@gouvfr-lasuite/proconnect.core": "workspace:*", "@gouvfr-lasuite/proconnect.crisp": "workspace:*", "@gouvfr-lasuite/proconnect.debounce": "workspace:*", + "@gouvfr-lasuite/proconnect.devtools.typescript": "workspace:*", "@gouvfr-lasuite/proconnect.email": "workspace:*", "@gouvfr-lasuite/proconnect.identite": "workspace:*", "@gouvfr-lasuite/proconnect.insee": "workspace:*", @@ -1323,6 +1325,10 @@ "resolved": "packages/debounce", "link": true }, + "node_modules/@gouvfr-lasuite/proconnect.devtools.typescript": { + "resolved": "packages/devtools/typescript", + "link": true + }, "node_modules/@gouvfr-lasuite/proconnect.email": { "resolved": "packages/email", "link": true @@ -2716,6 +2722,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@tsconfig/strictest": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.5.tgz", + "integrity": "sha512-ec4tjL2Rr0pkZ5hww65c+EEPYwxOi4Ryv+0MtjeaSQRJyq322Q27eOQiFbuNgw2hpL4hB1/W/HBGk3VKS43osg==", + "license": "MIT" + }, "node_modules/@types/accepts": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.5.tgz", @@ -10577,6 +10589,14 @@ "zod": "^3.18.0" } }, + "packages/config/typescript": { + "name": "@gouvfr-lasuite/proconnect.devtools.typescript", + "version": "0.0.0", + "extraneous": true, + "dependencies": { + "@tsconfig/strictest": "2.0.5" + } + }, "packages/core": { "name": "@gouvfr-lasuite/proconnect.core", "version": "0.3.2", @@ -10650,6 +10670,13 @@ "tsx": "^4.19.2" } }, + "packages/devtools/typescript": { + "name": "@gouvfr-lasuite/proconnect.devtools.typescript", + "version": "0.0.0", + "dependencies": { + "@tsconfig/strictest": "2.0.5" + } + }, "packages/email": { "name": "@gouvfr-lasuite/proconnect.email", "version": "0.1.0", diff --git a/package.json b/package.json index 748738161..6de92960c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "main": "src/index.js", "workspaces": [ + "packages/devtools/typescript", "packages/core", "packages/crisp", "packages/debounce", @@ -53,6 +54,7 @@ ] }, "dependencies": { + "@gouvfr-lasuite/proconnect.devtools.typescript": "workspace:*", "@gouvfr-lasuite/proconnect.core": "workspace:*", "@gouvfr-lasuite/proconnect.debounce": "workspace:*", "@gouvfr-lasuite/proconnect.crisp": "workspace:*", diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 23b7c277d..f21692ed9 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,18 +1,11 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, "outDir": "./dist", "rootDir": "src", - "types": ["node", "./types"], - "module": "NodeNext", - "moduleResolution": "nodenext", - "verbatimModuleSyntax": true, - "paths": { - "#src/*": ["./src/*"] - } + "types": ["node", "./types"] }, - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "references": [] } diff --git a/packages/crisp/tsconfig.json b/packages/crisp/tsconfig.json index 7cfd90574..0c9b510dc 100644 --- a/packages/crisp/tsconfig.json +++ b/packages/crisp/tsconfig.json @@ -1,18 +1,14 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, "outDir": "./dist", "types": ["node"], - "module": "NodeNext", - "moduleResolution": "nodenext", - "verbatimModuleSyntax": true, "paths": { "#src/*": ["./src/*"] } }, - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "include": ["src", "test"], "references": [] } diff --git a/packages/debounce/package.json b/packages/debounce/package.json index 0a101944a..ac4860198 100644 --- a/packages/debounce/package.json +++ b/packages/debounce/package.json @@ -11,7 +11,9 @@ "license": "MIT", "sideEffects": false, "type": "module", - "imports": {}, + "imports": { + "#src/types": "./src/types/index.ts" + }, "exports": { "./api": { "require": "./dist/api/index.cjs", diff --git a/packages/debounce/src/api/single-validation.ts b/packages/debounce/src/api/single-validation.ts index b397e19e9..ff03d747d 100644 --- a/packages/debounce/src/api/single-validation.ts +++ b/packages/debounce/src/api/single-validation.ts @@ -1,6 +1,6 @@ // -import type { DebounceSuccessResponse } from "#src/types/index.js"; +import type { DebounceSuccessResponse } from "#src/types"; import axios, { type AxiosRequestConfig, type AxiosResponse } from "axios"; // diff --git a/packages/debounce/tsconfig.json b/packages/debounce/tsconfig.json index ec2a63458..57b3b5489 100644 --- a/packages/debounce/tsconfig.json +++ b/packages/debounce/tsconfig.json @@ -1,18 +1,11 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, "outDir": "./dist", "rootDir": "src", - "types": ["node"], - "module": "NodeNext", - "moduleResolution": "nodenext", - "verbatimModuleSyntax": true, - "paths": { - "#src/*": ["./src/*"] - } + "types": ["node"] }, - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "references": [] } diff --git a/packages/devtools/typescript/base/tsconfig.json b/packages/devtools/typescript/base/tsconfig.json new file mode 100644 index 000000000..fda36ad9e --- /dev/null +++ b/packages/devtools/typescript/base/tsconfig.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "ProConnect Base", + "extends": "@tsconfig/strictest/tsconfig.json", + "compilerOptions": { + "checkJs": false, + "composite": true, + "esModuleInterop": true, + // TODO(douglasduteil): remove this line + // We might want to acticate exactOptionalPropertyTypes + "exactOptionalPropertyTypes": false, + "ignoreDeprecations": "5.0", + "isolatedModules": true, + "lib": ["ESNext"], + "module": "NodeNext", + "moduleResolution": "nodenext", + "noImplicitReturns": false, + // TODO(douglasduteil): remove this line + // We might want to acticate noUncheckedIndexedAccess + "noUncheckedIndexedAccess": false, + "preserveWatchOutput": true, + "target": "ESNext", + "types": [], + "verbatimModuleSyntax": true, + } +} diff --git a/packages/devtools/typescript/package.json b/packages/devtools/typescript/package.json new file mode 100644 index 000000000..d1f60097c --- /dev/null +++ b/packages/devtools/typescript/package.json @@ -0,0 +1,10 @@ +{ + "name": "@gouvfr-lasuite/proconnect.devtools.typescript", + "version": "0.0.0", + "private": true, + "type": "module", + "files": [], + "dependencies": { + "@tsconfig/strictest": "2.0.5" + } +} diff --git a/packages/email/tsconfig.json b/packages/email/tsconfig.json index dd167789e..848724137 100644 --- a/packages/email/tsconfig.json +++ b/packages/email/tsconfig.json @@ -1,6 +1,5 @@ { "$schema": "https://json.schemastore.org/tsconfig", - "extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "composite": true, "esModuleInterop": true, @@ -11,21 +10,13 @@ "module": "Preserve", "moduleResolution": "Bundler", "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noPropertyAccessFromIndexSignature": true, - "noUnusedLocals": true, - "noUnusedParameters": true, "plugins": [{ "name": "@kitajs/ts-html-plugin" }], "preserveSymlinks": true, - "preserveWatchOutput": true, "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true, "strictNullChecks": true, - "target": "ESNext", - "types": ["vite/client"], - "verbatimModuleSyntax": true + "types": ["vite/client"] }, + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "files": [], "include": ["src/**/*.ts", "src/**/*.tsx", ".storybook/**/*.tsx"], "references": [] diff --git a/packages/identite/tsconfig.json b/packages/identite/tsconfig.json index c66deae2b..cc69b7e38 100644 --- a/packages/identite/tsconfig.json +++ b/packages/identite/tsconfig.json @@ -1,21 +1,13 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, - "esModuleInterop": true, - "module": "NodeNext", - "moduleResolution": "nodenext", "outDir": "./dist", "resolveJsonModule": true, "rootDir": "src", - "types": ["node"], - "verbatimModuleSyntax": true, - "paths": { - "#src/*": ["./src/*"] - } + "types": ["node"] }, - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "references": [ { "path": "../core/tsconfig.lib.json" }, { "path": "../insee/tsconfig.lib.json" } diff --git a/packages/insee/src/formatters/libelle-from-code-effectif.ts b/packages/insee/src/formatters/libelle-from-code-effectif.ts index b16a92f6f..c4e903722 100644 --- a/packages/insee/src/formatters/libelle-from-code-effectif.ts +++ b/packages/insee/src/formatters/libelle-from-code-effectif.ts @@ -1,7 +1,7 @@ // import { codesEffectifs } from "#src/data"; -import type { TrancheEffectifs } from "#src/types/tranche-effectifs.js"; +import type { TrancheEffectifs } from "#src/types"; // diff --git a/packages/insee/tsconfig.json b/packages/insee/tsconfig.json index ec2a63458..57b3b5489 100644 --- a/packages/insee/tsconfig.json +++ b/packages/insee/tsconfig.json @@ -1,18 +1,11 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, "outDir": "./dist", "rootDir": "src", - "types": ["node"], - "module": "NodeNext", - "moduleResolution": "nodenext", - "verbatimModuleSyntax": true, - "paths": { - "#src/*": ["./src/*"] - } + "types": ["node"] }, - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json", "references": [] } diff --git a/tsconfig.json b/tsconfig.json index e5aae435e..88c76b091 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,28 +2,23 @@ "compilerOptions": { "allowJs": true, "allowSyntheticDefaultImports": true, - "jsx": "react-jsx", - "jsxImportSource": "@kitajs/html", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, + "jsx": "react-jsx", + "jsxImportSource": "@kitajs/html", "module": "Preserve", "moduleResolution": "Bundler", - "noFallthroughCasesInSwitch": true, - "noPropertyAccessFromIndexSignature": true, - "noUnusedLocals": true, - "noUnusedParameters": true, "outDir": "./build", - "resolveJsonModule": true, - "rootDir": ".", - "verbatimModuleSyntax": true + "resolveJsonModule": true }, - "exclude": ["packages/*", "build/*"], + "exclude": ["packages/*", "build/*", "dist/*"], + "include": ["src"], "references": [ { "path": "./packages/core/tsconfig.lib.json" }, { "path": "./packages/email/tsconfig.lib.json" }, { "path": "./packages/identite/tsconfig.lib.json" }, { "path": "./packages/insee/tsconfig.lib.json" } ], - "extends": "@tsconfig/node22/tsconfig.json" + "extends": "@gouvfr-lasuite/proconnect.devtools.typescript/base/tsconfig.json" }