From 3451f2a73aef4e2bda5038d095da789b7ac9f4da Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Wed, 15 Apr 2026 14:20:53 +0300 Subject: [PATCH] feat(eslint): add backend shared types and enforce compile-time contract for imports --- eslint.config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eslint.config.js b/eslint.config.js index 9176e2c6..b638ff37 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -147,6 +147,11 @@ export default tseslint.config( }), ], "boundaries/elements": [ + { + type: "backend-shared-types", // shared backend type contract that modules may consume without creating runtime coupling + pattern: ["server/shared/types.{js,ts}", "server/types.{js,ts}"], // support the current shared types path and the older top-level server/types file + mode: "file", // treat the types file itself as the boundary element instead of the whole folder + }, { type: "backend-module", // logical element name used by boundaries rules below pattern: "server/modules/*", // each direct folder in server/modules is treated as one module boundary @@ -190,6 +195,15 @@ export default tseslint.config( default: "allow", // allow normal imports unless a rule below explicitly disallows them checkInternals: false, // do not apply these cross-module rules to imports inside the same module rules: [ + { + from: { type: "backend-module" }, // modules may depend on the shared types contract only as erased type-only imports + to: { type: "backend-shared-types" }, + disallow: { + dependency: { kind: ["value", "typeof"] }, + }, // block runtime imports so shared types stay a compile-time contract instead of a hidden shared module + message: + "Backend modules may only use `import type` when importing from server/shared/types.ts (or server/types.ts).", + }, { to: { type: "backend-module" }, // when importing anything that belongs to another backend module disallow: { to: { internalPath: "**" } }, // block all direct/deep imports into module internals by default