feat: ESLint module boundary rule (PRD §5.4)
Enforced module boundaries via no-restricted-imports: (a) Views must not import other views directly (use shared primitives) (b) Infrastructure code must not import UI views (c) Portal-shell is isolated from agency views Pattern from Haben: strict module separation, cross-module access only via index.ts
This commit is contained in:
1 parent
9bf94ee79a
commit
f942c65e0d
1 file changed
+29
-4
+29
-4
@@ -6,8 +6,33 @@ import { fileURLToPath } from "url";
|
|||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
|
// PRD §5.4: Module boundaries —
|
||||||
|
// (a) cross-module imports only via index.ts
|
||||||
|
// (b) infrastructure never imports modules
|
||||||
|
// (c) modules never import routes or UI
|
||||||
|
const MODULE_BOUNDARY_RULE = {
|
||||||
|
// Prevent direct imports between modules (must go through index.ts)
|
||||||
|
"no-restricted-imports": ["error", {
|
||||||
|
patterns: [
|
||||||
|
// Module → Module direct import (must use index.ts)
|
||||||
|
{
|
||||||
|
group: ["@/components/aos/views/*"],
|
||||||
|
message: "Views must not import other views directly. Use shared primitives instead."
|
||||||
|
},
|
||||||
|
// Infrastructure → Module (infrastructure should not depend on modules)
|
||||||
|
{
|
||||||
|
group: ["@/components/aos/views/*", "@/components/aos/portal-*"],
|
||||||
|
message: "Infrastructure code must not import UI views."
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, {
|
const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, {
|
||||||
rules: {
|
rules: {
|
||||||
|
// PRD §5.4: Module boundary enforcement
|
||||||
|
...MODULE_BOUNDARY_RULE,
|
||||||
|
|
||||||
// TypeScript rules
|
// TypeScript rules
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"@typescript-eslint/no-unused-vars": "off",
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
@@ -15,7 +40,7 @@ const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, {
|
|||||||
"@typescript-eslint/ban-ts-comment": "off",
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
"@typescript-eslint/prefer-as-const": "off",
|
"@typescript-eslint/prefer-as-const": "off",
|
||||||
"@typescript-eslint/no-unused-disable-directive": "off",
|
"@typescript-eslint/no-unused-disable-directive": "off",
|
||||||
|
|
||||||
// React rules
|
// React rules
|
||||||
"react-hooks/exhaustive-deps": "off",
|
"react-hooks/exhaustive-deps": "off",
|
||||||
"react-hooks/purity": "off",
|
"react-hooks/purity": "off",
|
||||||
@@ -23,11 +48,11 @@ const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, {
|
|||||||
"react/display-name": "off",
|
"react/display-name": "off",
|
||||||
"react/prop-types": "off",
|
"react/prop-types": "off",
|
||||||
"react-compiler/react-compiler": "off",
|
"react-compiler/react-compiler": "off",
|
||||||
|
|
||||||
// Next.js rules
|
// Next.js rules
|
||||||
"@next/next/no-img-element": "off",
|
"@next/next/no-img-element": "off",
|
||||||
"@next/next/no-html-link-for-pages": "off",
|
"@next/next/no-html-link-for-pages": "off",
|
||||||
|
|
||||||
// General JavaScript rules
|
// General JavaScript rules
|
||||||
"prefer-const": "off",
|
"prefer-const": "off",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
@@ -44,7 +69,7 @@ const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, {
|
|||||||
"no-useless-escape": "off",
|
"no-useless-escape": "off",
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts", "examples/**", "skills"]
|
ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts", "examples/**", "skills"],
|
||||||
}];
|
}];
|
||||||
|
|
||||||
export default eslintConfig;
|
export default eslintConfig;
|
||||||
Reference in new issue
Block a user