From 13d029ba9707c00ed863b91ca8336ec480e36ecc Mon Sep 17 00:00:00 2001 From: VirtualMachinist Date: Thu, 19 Nov 2026 09:23:19 -0500 Subject: [PATCH 1/4] Add W-49: Astro components use the Astro API correctly laws/W-49.yaml holds the law (astro-site, required, judged in M3), with the nine eslint-plugin-astro rules its reader will prove: the deprecated-API rules, no-conflict-set-directives, no-exports-from- components and the other recommended ones. Section 8.2 is regenerated from it, and the law count goes from 48 to 49 where it is stated. Declared exceptions: WEB_TOPS.md (section 5.2 astro-site Extra laws, 8.2 heading and v0.1 line), src/config/profiles.ts (astro-site maps W-49), src/config/required.ts (LAW_COUNT) and the tests that count laws. This is a protocol-change. Co-Authored-By: Claude Sonnet 5.5 --- WEB_TOPS.md | 7 ++++--- laws/W-49.yaml | 22 ++++++++++++++++++++++ src/cli/laws.test.ts | 18 +++++++++--------- src/config/profiles.ts | 2 +- src/config/required.test.ts | 4 ++-- src/config/required.ts | 4 ++-- src/init/catalog.test.ts | 11 ++++++----- src/laws/catalog/catalog.test.ts | 7 ++++--- src/laws/catalog/query.test.ts | 2 +- 9 files changed, 51 insertions(+), 26 deletions(-) create mode 100644 laws/W-49.yaml diff --git a/WEB_TOPS.md b/WEB_TOPS.md index 408e95d..dcd1a04 100644 --- a/WEB_TOPS.md +++ b/WEB_TOPS.md @@ -272,7 +272,7 @@ have different budgets. | `size-limit` per entry | required | required | no | no | no | | HTML validity, axe, links | no | on fixture pages | required | required | no | | JS per page or route (brotli) | n/a | n/a | 0 KB unless the page has islands; ≤ 50 KB with | ≤ 170 KB per route | n/a | -| Extra laws | W-18 | W-18, W-22, W-37, W-47; W-27 when Astro | W-20–W-31, W-37, W-42–W-46, W-47 | W-20–W-29, W-37, W-42–W-46, W-47; W-27 when Astro | W-06 strict | +| Extra laws | W-18 | W-18, W-22, W-37, W-47; W-27 when Astro | W-20–W-31, W-37, W-42–W-46, W-47, W-49 | W-20–W-29, W-37, W-42–W-46, W-47; W-27 when Astro | W-06 strict | | Required layers | hygiene, tests, coverage, crap, mutation, build-output, laws | hygiene, tests, coverage, crap, mutation, build-output, laws | hygiene, tests, coverage, crap, mutation, build-output, laws | hygiene, tests, coverage, crap, mutation, build-output, laws | hygiene, tests, coverage, crap, mutation, laws | There is one CRAP cap per class, the same for every author; there is no per-author cap. The cap @@ -703,7 +703,7 @@ law: the bad twin breaks each enabled rule on purpose, with an `// expect: `, ``) with dimensions | A | an | | | W-31 | Frontmatter logic beyond 10 statements moves to a `.ts` module, where it can be tested | A | an | | +| W-49 | Astro components use the Astro API correctly: no deprecated APIs, conflicting directives or exports from components | R | tl: `eslint-plugin-astro` `recommended` | | **Tests, suppressions, security, build** @@ -810,7 +811,7 @@ the readers. | W-47 | React hooks follow the rules of hooks: called only at the top level of a component or custom hook, with complete dependency arrays | R | tl: `eslint-plugin-react-hooks` `rules-of-hooks`, `exhaustive-deps` | | | W-48 | No unused exports, files or dependencies | A | tbd: `knip` over all three (M3) | | -**v0.1 target:** 26 of 48 laws judged. Most are delegated, because the TypeScript and web +**v0.1 target:** 26 of 49 laws judged. Most are delegated, because the TypeScript and web ecosystem already ships the checks. Class-specific laws are `skip` for other classes. ### 8.3 Law metadata diff --git a/laws/W-49.yaml b/laws/W-49.yaml new file mode 100644 index 0000000..3319880 --- /dev/null +++ b/laws/W-49.yaml @@ -0,0 +1,22 @@ +# W-49: the source of its row in WEB_TOPS.md section 8.2 (`webtops laws sync` regenerates the table from these files). +id: W-49 +title: "Astro components use the Astro API correctly: no deprecated APIs, conflicting directives or exports from components" +family: "Astro" +severity: R +classes: [astro-site] +reader: + kinds: [tl] + text: "tl: `eslint-plugin-astro` `recommended`" +rules: + - { tool: eslint, name: "astro/missing-client-only-directive-value" } + - { tool: eslint, name: "astro/no-conflict-set-directives" } + - { tool: eslint, name: "astro/no-deprecated-astro-canonicalurl" } + - { tool: eslint, name: "astro/no-deprecated-astro-fetchcontent" } + - { tool: eslint, name: "astro/no-deprecated-astro-resolve" } + - { tool: eslint, name: "astro/no-deprecated-getentrybyslug" } + - { tool: eslint, name: "astro/no-exports-from-components" } + - { tool: eslint, name: "astro/no-prerender-export-outside-pages" } + - { tool: eslint, name: "astro/no-unused-define-vars-in-style" } +judged: m3 +rationale: "A removed API, two directives that fight over the same content, or an export from a component breaks the build or the page." +fix: "Use the current Astro API, set content with one directive, and move the export out of the component." diff --git a/src/cli/laws.test.ts b/src/cli/laws.test.ts index de08db6..bff5fda 100644 --- a/src/cli/laws.test.ts +++ b/src/cli/laws.test.ts @@ -76,27 +76,27 @@ const idsOf = (out: string): string[] => .map((line) => line.slice(0, 4 + 1).trim()); describe("webtops laws list (G1b)", () => { - it("lists all 48 laws with no filter", async () => { + it("lists all 49 laws with no filter", async () => { const { code, out } = await laws(["list"]); expect(code).toBe(0); - expect(out.startsWith("48 of 48 laws\n")).toBe(true); - expect(idsOf(out)).toHaveLength(48); + expect(out.startsWith("49 of 49 laws\n")).toBe(true); + expect(idsOf(out)).toHaveLength(49); }); it("lists the laws a class requires, 22 for a ts-library and 21 for a node-service", async () => { const tsLibrary = await laws(["list", "--class", "ts-library", "--required"]); - expect(tsLibrary.out.split("\n")[0]).toBe("22 of 48 laws (class ts-library, required)"); + expect(tsLibrary.out.split("\n")[0]).toBe("22 of 49 laws (class ts-library, required)"); const service = await laws(["list", "--class=node-service", "--required"]); - expect(service.out.split("\n")[0]).toBe("21 of 48 laws (class node-service, required)"); + expect(service.out.split("\n")[0]).toBe("21 of 49 laws (class node-service, required)"); expect(idsOf(service.out)).not.toContain("W-18"); }); it("lists the laws a class maps with --class alone, and the judged laws with --required alone", async () => { expect((await laws(["list", "--class", "astro-site"])).out.split("\n")[0]).toBe( - "47 of 48 laws (class astro-site)", + "48 of 49 laws (class astro-site)", ); expect((await laws(["list", "--required"])).out.split("\n")[0]).toBe( - "33 of 48 laws (required)", + "34 of 49 laws (required)", ); }); @@ -269,7 +269,7 @@ describe("bun src/cli/main.ts laws: the registered command, in a real process", it("lists the laws a class requires, exit 0", () => { const { status, stdout } = spawnCli("list", "--class", "ts-library", "--required"); expect(status).toBe(0); - expect(stdout.split("\n")[0]).toBe("22 of 48 laws (class ts-library, required)"); + expect(stdout.split("\n")[0]).toBe("22 of 49 laws (class ts-library, required)"); }); it("exits 2 for a law that is not in the catalog, and names it", () => { @@ -287,6 +287,6 @@ describe("laws is registered with the command dispatcher", () => { it("run hands `laws list` to the laws command, in this process", async () => { const { io, out } = capture(); expect(await run(["laws", "list", "--class", "ts-library", "--required"], io)).toBe(0); - expect(out().split("\n")[0]).toBe("22 of 48 laws (class ts-library, required)"); + expect(out().split("\n")[0]).toBe("22 of 49 laws (class ts-library, required)"); }); }); diff --git a/src/config/profiles.ts b/src/config/profiles.ts index 77f704f..fdca0cc 100644 --- a/src/config/profiles.ts +++ b/src/config/profiles.ts @@ -124,7 +124,7 @@ export const PROFILES: readonly Profile[] = [ layers: ["html_validate", "axe", "rendered", "themes"], steps: [...CORE_STEPS, "astro_check", "stylelint"], conditionalSteps: [], - extraLaws: [...lawIds(20, 31), "W-37", ...RENDERED_LAWS, "W-47"], + extraLaws: [...lawIds(20, 31), "W-37", ...RENDERED_LAWS, "W-47", "W-49"], conditionalLaws: [], }, { diff --git a/src/config/required.test.ts b/src/config/required.test.ts index aead6ab..525e627 100644 --- a/src/config/required.test.ts +++ b/src/config/required.test.ts @@ -192,9 +192,9 @@ describe("G3d: section 5.2 states how the caps work (X2)", () => { }); describe("R55: W-47 and W-48 join the catalog, unjudged", () => { - it("counts as many laws as section 8.2 lists, 48", () => { + it("counts as many laws as section 8.2 lists, 49", () => { const rows = spec.split("\n").filter((line) => /^\| W-\d+ /.test(line)); - expect(LAW_COUNT).toBe(48); + expect(LAW_COUNT).toBe(49); expect(rows).toHaveLength(LAW_COUNT); }); diff --git a/src/config/required.ts b/src/config/required.ts index 9a15afb..65f085e 100644 --- a/src/config/required.ts +++ b/src/config/required.ts @@ -34,8 +34,8 @@ export const JUDGED_LAWS: readonly string[] = [ "W-41", ]; -/** W-01 to W-48 (WEB_TOPS.md section 8.2). */ -export const LAW_COUNT = 48; +/** W-01 to W-49 (WEB_TOPS.md section 8.2). */ +export const LAW_COUNT = 49; const ALL_LAWS = Array.from( { length: LAW_COUNT }, (_, index) => `W-${String(index + 1).padStart(2, "0")}`, diff --git a/src/init/catalog.test.ts b/src/init/catalog.test.ts index 2d1f21e..06ea69d 100644 --- a/src/init/catalog.test.ts +++ b/src/init/catalog.test.ts @@ -128,16 +128,17 @@ describe("G8a: section 7 names the presets, page JavaScript and axe's settings", }); describe("G8b: section 8 corrections and new laws", () => { - it("states 48 laws, with one row for each id from W-01 to W-48", () => { - expect(section82).toContain("draft: 48 laws, W-01…W-48"); + it("states 49 laws, with one row for each id from W-01 to W-49", () => { + expect(section82).toContain("draft: 49 laws, W-01…W-49"); const ids = section82 .split("\n") .map((line) => /^\| (W-\d+) \|/.exec(line)?.[1]) .filter((id) => id !== undefined); - expect(ids).toEqual( - Array.from({ length: 48 }, (_, i) => `W-${String(i + 1).padStart(2, "0")}`), + // A family's laws sit together, so W-49 follows W-31 in the Astro table: the set is W-01 to W-49. + expect([...ids].sort()).toEqual( + Array.from({ length: 49 }, (_, i) => `W-${String(i + 1).padStart(2, "0")}`), ); - expect(section82).toContain("**v0.1 target:** 26 of 48 laws judged"); + expect(section82).toContain("**v0.1 target:** 26 of 49 laws judged"); }); it("W-06 no longer says FormData and storage return any", () => { diff --git a/src/laws/catalog/catalog.test.ts b/src/laws/catalog/catalog.test.ts index a29b6b0..b79128d 100644 --- a/src/laws/catalog/catalog.test.ts +++ b/src/laws/catalog/catalog.test.ts @@ -14,7 +14,7 @@ const loaded = loadCatalog(join(ROOT, "laws")); if (!loaded.ok) throw new Error(loaded.problems.map((found) => found.message).join("; ")); const laws: readonly Law[] = loaded.laws; -const LAW_COUNT = 48; +const LAW_COUNT = 49; /** The tick column of section 8.2 (v0.1): the laws judged today. */ const TICKED = [ @@ -73,11 +73,11 @@ const ids = (shown: readonly { id: string }[]): string[] => shown.map((law) => l const numbered = (list: string): string[] => list.split(/[ ,]+/u).filter((word) => word !== ""); describe("the kit's catalog: laws/W-NN.yaml (G1a)", () => { - it("holds a valid file for each of the 48 laws, W-01 to W-48, in order", () => { + it("holds a valid file for each of the 49 laws, W-01 to W-49, in order", () => { expect(ids(laws)).toEqual( Array.from({ length: LAW_COUNT }, (_, index) => `W-${String(index + 1).padStart(2, "0")}`), ); - expect(laws).toHaveLength(48); + expect(laws).toHaveLength(LAW_COUNT); }); it("puts every law in a family the text of section 8.2 has a table for", () => { @@ -126,6 +126,7 @@ describe("the catalog agrees with the profiles and with section 5.2 (G1b)", () = "W-37", "W-39", "W-48", + "W-49", ]); }); diff --git a/src/laws/catalog/query.test.ts b/src/laws/catalog/query.test.ts index ac20555..f117d83 100644 --- a/src/laws/catalog/query.test.ts +++ b/src/laws/catalog/query.test.ts @@ -19,7 +19,7 @@ const ids = (shown: readonly { id: string }[]): string[] => shown.map((law) => l describe("select", () => { it("is every law with no filter", () => { - expect(select(laws, { cls: undefined, required: false })).toHaveLength(48); + expect(select(laws, { cls: undefined, required: false })).toHaveLength(49); }); it("is the laws a class maps, required or not", () => { From c38f2c97ddc9dbe1ab06e1735a360760791c1dfa Mon Sep 17 00:00:00 2001 From: VirtualMachinist Date: Thu, 19 Nov 2026 12:42:51 -0500 Subject: [PATCH 2/4] Name the readers of W-19, W-39 and W-41 (R92) Each had no rule: W-19 gets the dependency-cruiser preset's optional-peer rule, W-39 the secretlint recommended preset, and W-41 the lock file. W-39's note that no rule names the scanner is gone. Section 8.2 is regenerated, and the catalog test lists the two new tool names. The W-19 rule name is a proposal: it is to be confirmed with the owner of the depcruise preset before this merges. Co-Authored-By: Claude Sonnet 5.5 --- laws/W-19.yaml | 3 ++- laws/W-39.yaml | 4 ++-- laws/W-41.yaml | 3 ++- src/laws/catalog/catalog.test.ts | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/laws/W-19.yaml b/laws/W-19.yaml index 96bbd8e..40a6f06 100644 --- a/laws/W-19.yaml +++ b/laws/W-19.yaml @@ -7,7 +7,8 @@ classes: [ts-library, ui-components, astro-site, web-app, node-service] reader: kinds: [tl] text: "tl: `dependency-cruiser`" -rules: [] +rules: + - { tool: depcruise, name: "no-optional-peer-outside-entry" } judged: v0.1 rationale: "An optional peer imported from an entry that does not declare it breaks installs that skip the peer." fix: "Import the peer only from entries that declare it, or declare it for the entry." diff --git a/laws/W-39.yaml b/laws/W-39.yaml index 1c27c3b..120cb07 100644 --- a/laws/W-39.yaml +++ b/laws/W-39.yaml @@ -7,8 +7,8 @@ classes: [ts-library, ui-components, astro-site, web-app, node-service] reader: kinds: [tl] text: "tl: secrets scanner **[verify]**" -rules: [] +rules: + - { tool: secretlint, name: "@secretlint/secretlint-rule-preset-recommend" } judged: m3 rationale: "A secret in source or a fixture is a leaked credential, in history too." fix: "Remove it, rotate it, and load it from the environment." -note: "The scanner is chosen in M3; no rule names it yet." diff --git a/laws/W-41.yaml b/laws/W-41.yaml index f276721..8c17d70 100644 --- a/laws/W-41.yaml +++ b/laws/W-41.yaml @@ -7,7 +7,8 @@ classes: [ts-library, ui-components, astro-site, web-app, node-service] reader: kinds: [an] text: "an" -rules: [] +rules: + - { tool: lock, name: "web-tops.lock" } judged: v0.1 rationale: "A tool version that differs from the lock makes a gate result mean something else on another machine." fix: "Run `webtops lock --update` after a deliberate change, or reinstall the locked version." diff --git a/src/laws/catalog/catalog.test.ts b/src/laws/catalog/catalog.test.ts index b79128d..4ee32e1 100644 --- a/src/laws/catalog/catalog.test.ts +++ b/src/laws/catalog/catalog.test.ts @@ -250,9 +250,11 @@ describe("the rules a law names, for the law probe", () => { "attw", "axe", "bun", + "depcruise", "dependency-cruiser", "eslint", "html-validate", + "lock", "publint", "stylelint", "tsc", From 449c6df5c5a500375bd5178b752b114d4d88635c Mon Sep 17 00:00:00 2001 From: VirtualMachinist Date: Thu, 19 Nov 2026 20:27:06 -0500 Subject: [PATCH 3/4] Give W-19 a live dependency-cruiser rule, no-optional-peer-import (R93) W-19 named a rule the preset did not have. web-tops/depcruise now forbids an import of React, react-dom, three or an @react-three package that the package declares as a peer from anywhere but a react entry or an adapter. A package that depends on the module directly is not touched. The tool is spelled dependency-cruiser in the law, as in W-16 and W-17, and its note is gone. Co-Authored-By: Claude Sonnet 5.5 --- laws/W-19.yaml | 3 +- src/laws/catalog/catalog.test.ts | 1 - src/presets/depcruise.cjs | 13 ++++ src/presets/depcruise.test.ts | 116 +++++++++++++++++++++++++++++++ src/presets/presets.test.ts | 2 +- 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 src/presets/depcruise.test.ts diff --git a/laws/W-19.yaml b/laws/W-19.yaml index 40a6f06..5a2ec8c 100644 --- a/laws/W-19.yaml +++ b/laws/W-19.yaml @@ -8,8 +8,7 @@ reader: kinds: [tl] text: "tl: `dependency-cruiser`" rules: - - { tool: depcruise, name: "no-optional-peer-outside-entry" } + - { tool: dependency-cruiser, name: "no-optional-peer-import" } judged: v0.1 rationale: "An optional peer imported from an entry that does not declare it breaks installs that skip the peer." fix: "Import the peer only from entries that declare it, or declare it for the entry." -note: "The dependency-cruiser rule lands with its reader in M3." diff --git a/src/laws/catalog/catalog.test.ts b/src/laws/catalog/catalog.test.ts index 4570e23..b359f5c 100644 --- a/src/laws/catalog/catalog.test.ts +++ b/src/laws/catalog/catalog.test.ts @@ -247,7 +247,6 @@ describe("the rules a law names, for the law probe", () => { "attw", "axe", "bun", - "depcruise", "dependency-cruiser", "eslint", "html-validate", diff --git a/src/presets/depcruise.cjs b/src/presets/depcruise.cjs index 090d565..50236d5 100644 --- a/src/presets/depcruise.cjs +++ b/src/presets/depcruise.cjs @@ -4,6 +4,8 @@ // resolver reads each package's `exports`, so an import through a path it does not expose cannot be // resolved and fails at no-unresolvable. A rule on the resolved path would flag every normal import, // because a package's own types resolve into its dist. +// W-19: React and R3F, when a package declares them as peers, are imported only from its `react` +// entries and its `adapters`, the only places that may need them (WEB_TOPS.md section 8.2). /** @type {import("dependency-cruiser").IConfiguration} */ module.exports = { forbidden: [ @@ -21,6 +23,17 @@ module.exports = { from: {}, to: { couldNotResolve: true }, }, + { + name: "no-optional-peer-import", + comment: + "W-19: an optional peer (React, R3F) is imported only from a react entry or an adapter.", + severity: "error", + from: { pathNot: "(^|/)(react|adapters)(/|\\.[cm]?[jt]sx?$)" }, + to: { + dependencyTypes: ["npm-peer"], + path: "(^|/)node_modules/(react|react-dom|three|@react-three/[^/]+)(/|$)", + }, + }, ], options: { doNotFollow: { path: "node_modules" }, diff --git a/src/presets/depcruise.test.ts b/src/presets/depcruise.test.ts new file mode 100644 index 0000000..546fed2 --- /dev/null +++ b/src/presets/depcruise.test.ts @@ -0,0 +1,116 @@ +import { spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { afterAll, describe, expect, it } from "vitest"; +import { REAL_TOOL_TIMEOUT } from "../gate/test-support-timeouts.ts"; + +const ROOT = resolve(import.meta.dirname, "../.."); +const made: string[] = []; +afterAll(() => { + for (const dir of made) rmSync(dir, { recursive: true, force: true }); +}); + +/** A package that declares `react` as a peer, with `react` installed, and these files under src. */ +function peerPackage(files: Readonly>, peer = "react"): string { + const dir = mkdtempSync(join(tmpdir(), "wt-depcruise-")); + made.push(dir); + const all: Record = { + "package.json": JSON.stringify({ + name: "probe", + type: "module", + peerDependencies: { [peer]: "*" }, + peerDependenciesMeta: { [peer]: { optional: true } }, + }), + "tsconfig.json": JSON.stringify({ + compilerOptions: { module: "preserve", moduleResolution: "bundler", noEmit: true }, + include: ["src"], + }), + [`node_modules/${peer}/package.json`]: JSON.stringify({ name: peer, main: "index.js" }), + [`node_modules/${peer}/index.js`]: "module.exports = {};\n", + ...files, + }; + for (const [path, text] of Object.entries(all)) { + mkdirSync(dirname(join(dir, path)), { recursive: true }); + writeFileSync(join(dir, path), text); + } + symlinkSync(join(ROOT, "node_modules", "typescript"), join(dir, "node_modules", "typescript")); + return dir; +} + +function cruise(dir: string): { status: number | null; output: string } { + const bin = join(ROOT, "node_modules", ".bin", "depcruise"); + const config = join(ROOT, "src", "presets", "depcruise.cjs"); + const result = spawnSync(bin, ["--config", config, "src"], { cwd: dir, encoding: "utf8" }); + return { status: result.status, output: `${result.stdout}${result.stderr}` }; +} + +const IMPORT = 'import * as peer from "react";\nexport const value = peer;\n'; +const NAME = "no-optional-peer-import"; + +describe("W-19: web-tops/depcruise keeps an optional peer to the entries that declare it", () => { + it( + "flags an import of a peer from a file outside the react entries and the adapters", + () => { + const result = cruise(peerPackage({ "src/index.ts": IMPORT })); + expect(result.status, result.output).toBe(1); + expect(result.output).toContain(NAME); + expect(result.output).toContain("src/index.ts"); + }, + REAL_TOOL_TIMEOUT, + ); + + it.each(["src/react/index.ts", "src/react.ts", "src/adapters/three.ts", "src/lib/react/a.tsx"])( + "lets %s import it", + (file) => { + const result = cruise(peerPackage({ [file]: IMPORT })); + expect(result.output).not.toContain(NAME); + expect(result.status, result.output).toBe(0); + }, + REAL_TOOL_TIMEOUT, + ); + + it( + "flags the R3F and three peers too", + () => { + const result = cruise( + peerPackage( + { "src/index.ts": 'import * as peer from "three";\nexport const v = peer;\n' }, + "three", + ), + ); + expect(result.output).toContain(NAME); + }, + REAL_TOOL_TIMEOUT, + ); + + it( + "leaves a package that depends on react directly alone", + () => { + const dir = peerPackage({ "src/index.ts": IMPORT }); + writeFileSync( + join(dir, "package.json"), + JSON.stringify({ name: "probe", type: "module", dependencies: { react: "*" } }), + ); + const result = cruise(dir); + expect(result.output).not.toContain(NAME); + expect(result.status, result.output).toBe(0); + }, + REAL_TOOL_TIMEOUT, + ); + + it( + "leaves another peer alone", + () => { + const result = cruise( + peerPackage( + { "src/index.ts": 'import * as peer from "left-pad";\nexport const v = peer;\n' }, + "left-pad", + ), + ); + expect(result.output).not.toContain(NAME); + expect(result.status, result.output).toBe(0); + }, + REAL_TOOL_TIMEOUT, + ); +}); diff --git a/src/presets/presets.test.ts b/src/presets/presets.test.ts index 6149849..7cbce48 100644 --- a/src/presets/presets.test.ts +++ b/src/presets/presets.test.ts @@ -98,7 +98,7 @@ describe("G2a: each preset imports from a scratch project", () => { variants: ["base", "react", "astro"], configs: 9, stylelint: 9, - depcruise: ["no-circular", "no-unresolvable"], + depcruise: ["no-circular", "no-unresolvable", "no-optional-peer-import"], }); }, REAL_TOOL_TIMEOUT, From bb546648214b96fdf94fed7d91cafcaa28bb6863 Mon Sep 17 00:00:00 2001 From: VirtualMachinist Date: Fri, 20 Nov 2026 01:04:13 -0500 Subject: [PATCH 4/4] Write the class-own laws without an empty-array branch (W-49) Co-Authored-By: Claude Sonnet 5.5 --- src/config/required.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/required.ts b/src/config/required.ts index 65f085e..6233004 100644 --- a/src/config/required.ts +++ b/src/config/required.ts @@ -57,7 +57,9 @@ const BUILD_OUTPUT: readonly LayerKey[] = [ /** Every law the class maps: the ones no class gates, and the class's own (W-27 only with Astro). */ export function mappedLaws(profile: Profile, project: Project): readonly string[] { - const own = [...profile.extraLaws, ...(project.dependsOnAstro ? profile.conditionalLaws : [])]; + const own = project.dependsOnAstro + ? [...profile.extraLaws, ...profile.conditionalLaws] + : profile.extraLaws; return ALL_LAWS.filter((id) => !GATED.has(id) || own.includes(id)); }