Skip to content

Commit e6f46ff

Browse files
committed
Sync strengthened dependency-cruiser policy
1 parent 64f73ce commit e6f46ff

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

‎.dependency-cruiser.cjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ const config = {
120120
from: { path: "(^|/)model/" },
121121
to: { path: "(^|/)view/" },
122122
},
123+
{
124+
name: "no-root-to-screen",
125+
severity: "error",
126+
comment: "Only src/main.ts wires screens. Move screen-specific helpers into their screen package.",
127+
from: { path: "^src/[^/]+$", pathNot: "^src/main\\.ts$" },
128+
to: { path: "^src/[^/]+/", pathNot: `^src/(${SHARED_ROOTS})/` },
129+
},
123130
{
124131
name: "no-common-to-screen",
125132
severity: "error",

‎package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"build": "tsc && vite build",
2626
"build:single": "tsc && vite build --mode single",
2727
"check": "tsc --noEmit && tsc -p tsconfig.scripts.json --noEmit && tsc -p tsconfig.test.json --noEmit",
28-
"check:architecture": "depcruise src",
28+
"check:architecture": "depcruise --config .dependency-cruiser.cjs src",
2929
"check:unused": "knip",
3030
"clean": "rm -rf dist",
3131
"dev": "vite",
@@ -40,15 +40,15 @@
4040
"start": "vite",
4141
"test": "vitest run",
4242
"test:architecture": "node --test tests/*.node-test.ts",
43+
"test:browser": "playwright test --project=chromium tests/browser",
4344
"test:fuzz": "node scripts/test-fuzz.ts",
4445
"test:fuzz:long": "node scripts/test-fuzz.ts 300",
4546
"test:fuzz:quick": "node scripts/test-fuzz.ts 10",
4647
"test:soak": "npm run test:soak:headless && npm run test:soak:browser",
4748
"test:soak:browser": "npx playwright test tests/soak/browser.spec.ts",
4849
"test:soak:headless": "vitest run --config vitest.soak.config.ts",
4950
"test:watch": "vitest",
50-
"watch": "tsc --watch",
51-
"test:browser": "playwright test --project=chromium tests/browser"
51+
"watch": "tsc --watch"
5252
},
5353
"overrides": {
5454
"brace-expansion": "~5.0.12",

‎tests/architecture.node-test.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function cruise(
4545
mkdirSync(dirname(join(directory, name)), { recursive: true });
4646
writeFileSync(join(directory, name), source);
4747
}
48-
const result = spawnSync(process.execPath, [cli, "src", "--output-type", "err"], {
48+
const result = spawnSync(process.execPath, [cli, "--config", ".dependency-cruiser.cjs", "src"], {
4949
cwd: directory,
5050
encoding: "utf8",
5151
timeout: 20_000,
@@ -73,6 +73,15 @@ const forbidden: [string, Files][] = [
7373
["no-src-to-tests", { "src/main.ts": 'import "../tests/helper.js";', "tests/helper.ts": "export const x = 1;" }],
7474
["not-to-dev-dep", { "src/main.test.ts": 'import { test } from "vitest";' }],
7575
["no-app-to-bootstrap", { "src/common/helper.ts": 'import "../init.js";', "src/init.ts": "export const x = 1;" }],
76+
[
77+
"no-root-to-screen",
78+
{
79+
"src/main.ts": 'import "./intro/Screen.js";',
80+
"src/intro/Screen.ts": 'import "../root-helper.js";',
81+
"src/root-helper.ts": 'export * from "./lab/Screen.js";',
82+
"src/lab/Screen.ts": "export const screen = 1;",
83+
},
84+
],
7685
[
7786
"no-model-to-view",
7887
{ "src/lab/model/Model.ts": 'import "../view/View.js";', "src/lab/view/View.ts": "export const x = 1;" },
@@ -148,6 +157,15 @@ test("allows bootstrap metadata, same-screen imports, shared models, and type-on
148157
assert.equal(result.status, 0);
149158
});
150159

160+
test("uses the fleet config when another default config is present", () => {
161+
const result = cruise({
162+
".dependency-cruiser.json": '{ "forbidden": [] }',
163+
"src/main.ts": 'import "./missing.js";',
164+
});
165+
assert.deepEqual(violations(result), ["no-unresolved"], result.stdout);
166+
assert.notEqual(result.status, 0);
167+
});
168+
151169
const source = { "src/main.ts": 'import "./missing.js";' };
152170
const failClosedOverlays: [string, string][] = [
153171
["missing overlay dependency", 'require("./absent.cjs");'],

0 commit comments

Comments
 (0)