|
| 1 | +/** @type {import('dependency-cruiser').IConfiguration} */ |
| 2 | +module.exports = { |
| 3 | + forbidden: [ |
| 4 | + { |
| 5 | + name: 'no-renderer-importing-main', |
| 6 | + severity: 'error', |
| 7 | + comment: |
| 8 | + 'Renderer (src/) must never import Electron main-process code. ' + |
| 9 | + 'Use IPC channels instead.', |
| 10 | + from: { path: '^src/' }, |
| 11 | + to: { |
| 12 | + path: '^electron/', |
| 13 | + // Allow importing the shared IPC channel enum (channels.ts is a pure enum, no Node/Electron deps) |
| 14 | + pathNot: '^electron/ipc/channels\\.ts', |
| 15 | + }, |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'no-mcp-importing-components', |
| 19 | + severity: 'error', |
| 20 | + comment: 'MCP coordinator must not import frontend components or store.', |
| 21 | + from: { path: '^electron/mcp/' }, |
| 22 | + to: { path: '^src/(components|store|lib)/' }, |
| 23 | + }, |
| 24 | + { |
| 25 | + name: 'no-circular', |
| 26 | + severity: 'error', |
| 27 | + comment: |
| 28 | + 'Circular dependencies break tree-shaking and make reasoning about startup order impossible.', |
| 29 | + from: {}, |
| 30 | + to: { circular: true }, |
| 31 | + }, |
| 32 | + { |
| 33 | + name: 'no-orphans', |
| 34 | + severity: 'warn', |
| 35 | + comment: 'Orphan modules have no importers and no exports used elsewhere — likely dead code.', |
| 36 | + from: { |
| 37 | + orphan: true, |
| 38 | + // Test files, config files, entry points, and pure type modules are expected orphans. |
| 39 | + // Type-only modules (types.ts, *.d.ts) are consumed by TypeScript structurally — the |
| 40 | + // import graph doesn't capture all type-level usage, so they appear orphaned. |
| 41 | + pathNot: [ |
| 42 | + '\\.test\\.(ts|tsx)$', |
| 43 | + '\\.config\\.(ts|js|cjs)$', |
| 44 | + '\\.d\\.ts$', |
| 45 | + 'types\\.ts$', |
| 46 | + 'types\\.(ts|tsx)$', |
| 47 | + '^src/main\\.tsx$', |
| 48 | + '^src/remote/main\\.tsx$', |
| 49 | + '^electron/main\\.ts$', |
| 50 | + '^electron/preload\\.cjs$', |
| 51 | + '^electron/mcp/server\\.ts$', |
| 52 | + // Vite ambient env declarations |
| 53 | + '^src/vite-env\\.d\\.ts$', |
| 54 | + ], |
| 55 | + }, |
| 56 | + to: {}, |
| 57 | + }, |
| 58 | + ], |
| 59 | + |
| 60 | + options: { |
| 61 | + doNotFollow: { |
| 62 | + path: 'node_modules', |
| 63 | + }, |
| 64 | + moduleSystems: ['es6', 'cjs'], |
| 65 | + tsConfig: { |
| 66 | + fileName: 'tsconfig.json', |
| 67 | + }, |
| 68 | + reporterOptions: { |
| 69 | + dot: { |
| 70 | + collapsePattern: 'node_modules/[^/]+', |
| 71 | + }, |
| 72 | + archi: { |
| 73 | + collapsePattern: '^(node_modules|src/components)/[^/]+', |
| 74 | + }, |
| 75 | + }, |
| 76 | + }, |
| 77 | +}; |
0 commit comments