Add eslint-plugin-boundaries with layered dependency rules
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import js from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import unusedImports from "eslint-plugin-unused-imports";
|
||||
import boundaries from "eslint-plugin-boundaries";
|
||||
|
||||
export default [
|
||||
{
|
||||
@@ -52,4 +53,57 @@ export default [
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.{ts,tsx}"],
|
||||
plugins: {
|
||||
boundaries,
|
||||
},
|
||||
settings: {
|
||||
"boundaries/elements": [
|
||||
{ type: "routes", pattern: "src/routes/*" },
|
||||
{ type: "mf", pattern: "src/mf/*" },
|
||||
{ type: "features", pattern: "src/features/*", capture: ["feature"] },
|
||||
{ type: "ui", pattern: "src/ui/*" },
|
||||
{ type: "shared", pattern: "src/shared/*" },
|
||||
{ type: "observability", pattern: "src/observability/*" },
|
||||
{ type: "i18n", pattern: "src/i18n/*" },
|
||||
{ type: "env", pattern: "src/env/*" },
|
||||
],
|
||||
},
|
||||
rules: {
|
||||
// Design spec §1.2 layered dependency direction:
|
||||
// features/ cannot import routes/ or mf/
|
||||
// ui/ cannot import features/
|
||||
// shared/ cannot import features/, routes/, mf/, observability/
|
||||
// observability/ cannot import features/, routes/, mf/
|
||||
"boundaries/element-types": [
|
||||
"error",
|
||||
{
|
||||
default: "allow",
|
||||
rules: [
|
||||
{
|
||||
from: "features",
|
||||
disallow: ["routes", "mf"],
|
||||
message: "Features must not import from routes/ or mf/. Use the HostContract or a shared module instead.",
|
||||
},
|
||||
{
|
||||
from: "ui",
|
||||
disallow: ["features", "routes", "mf"],
|
||||
message: "UI layer must not import from features/, routes/, or mf/. UI is consumed by features, not the other way around.",
|
||||
},
|
||||
{
|
||||
from: "shared",
|
||||
disallow: ["features", "routes", "mf", "observability"],
|
||||
message: "Shared modules must not import from features/, routes/, mf/, or observability/.",
|
||||
},
|
||||
{
|
||||
from: "observability",
|
||||
disallow: ["features", "routes", "mf"],
|
||||
message: "Observability modules must not import from features/, routes/, or mf/.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user