Skip to content

Commit 35060af

Browse files
authored
♻️ Migrate operational review documents from Show to built-in <If> (#406)
The review library shipped its own `Show.md` conditional before the engine had one. `<If>` is now a native structural directive, so the seven operational documents that still invoked `Show` duplicated engine behavior and let the review system drift from the documented language. Rename the thirteen conditional blocks in place — `when` becomes `condition`, bodies and whitespace are unchanged — and delete `.reviews/components/Show.md`. None of the conditions had a fallback and every one already evaluates to a boolean, so no `<Else>` branch is introduced and issue #258's possible truthiness change stays independent. Deleting the component and scanning for its tag proves retirement but not behavior, so the review-infrastructure suite now executes the real sources of all seven documents with no `If.md` or `Show.md` in the stub filesystem: the structural name has to win before filesystem component resolution. Compact outputs and every suppressed case are asserted by exact trimmed equality, which locks the summary, table, and section whitespace the tags surround. `ExtraneousCodePolicy.md` carries the provider contract — a counting `Sample` records zero calls below the review threshold and exactly one above it, so the empty case is non-execution rather than a probe that never wired up. Co-authored-by: Taras Mankovski <[email protected]>
1 parent 0f11a5e commit 35060af

11 files changed

Lines changed: 339 additions & 64 deletions

File tree

‎.reviews/components/CommentReview.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ props:
1111
<CommentReviewData pr={props.pr} as="reviewData" />
1212

1313
<Capture as="classificationResult">
14-
<Show when={reviewData.hasRepliesToClassify}>
14+
<If condition={reviewData.hasRepliesToClassify}>
1515

1616
<Sample>
1717

@@ -28,11 +28,11 @@ Format: [index] DISMISS or [index] ACCEPT
2828

2929
</Sample>
3030

31-
</Show>
31+
</If>
3232
</Capture>
3333

3434
<Capture as="sampleResult">
35-
<Show when={reviewData.hasPairs}>
35+
<If condition={reviewData.hasPairs}>
3636

3737
<Sample>
3838

@@ -47,7 +47,7 @@ If none are obvious: "No obvious comments found."
4747

4848
</Sample>
4949

50-
</Show>
50+
</If>
5151
</Capture>
5252

5353
<CommentReviewState
@@ -58,14 +58,14 @@ If none are obvious: "No obvious comments found."
5858
as="state"
5959
/>
6060

61-
<Show when={state.hasFindings}>
61+
<If condition={state.hasFindings}>
6262

6363
<SuggestRemoval findings={state.pendingFindings} dismissedReplies={state.newDismissReplies} />
6464

65-
</Show>
65+
</If>
6666

67-
<Show when={state.hasChecklist}>
67+
<If condition={state.hasChecklist}>
6868

6969
{state.checklistMd}
7070

71-
</Show>
71+
</If>

‎.reviews/components/Finding.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ props:
1717
const icon = props.severity === "error" ? "\ud83d\udd34" : "\ud83d\udfe1";
1818
```
1919

20-
<Show when={props.when}>
20+
<If condition={props.when}>
2121

2222
{icon} {props.message}
2323

24-
</Show>
24+
</If>

‎.reviews/components/OxlintSummary.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ props:
1313
<ReviewSection heading="Static Analysis"
1414
clean="✅ Oxlint found no issues.">
1515

16-
<Show when={!props.doctor.oxlintInstalled}>
16+
<If condition={!props.doctor.oxlintInstalled}>
1717

1818
🟡 Oxlint not installed. Static analysis skipped.
1919

20-
</Show>
20+
</If>
2121

22-
<Show when={props.doctor.oxlintInstalled && props.diagnostics.total > 0}>
22+
<If condition={props.doctor.oxlintInstalled && props.diagnostics.total > 0}>
2323

2424
{props.diagnostics.summary}
2525

26-
</Show>
26+
</If>
2727

28-
<Show when={props.doctor.bloatRulesMissing.length > 0
28+
<If condition={props.doctor.bloatRulesMissing.length > 0
2929
&& props.doctor.oxlintInstalled}>
3030

3131
*{props.doctor.bloatRulesMissing.length} type-aware rules unavailable
3232
— install `oxlint-tsgolint` for full coverage.*
3333

34-
</Show>
34+
</If>
3535

3636
</ReviewSection>

‎.reviews/components/ReleaseSpecWarning.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ const changedList = releaseChanged.join(", ");
3838

3939
<Output>
4040

41-
<Show when={releaseChanged.length > 0 && !props.files.includes("specs/release-process-spec.md")}>
41+
<If condition={releaseChanged.length > 0 && !props.files.includes("specs/release-process-spec.md")}>
4242

4343
> [!WARNING]
4444
> This PR changes release configuration ({changedList}) without touching
4545
> `specs/release-process-spec.md`. Review the spec and update it to match, or
4646
> state `spec-reviewed: no changes needed` in the PR description (AGENTS.md
4747
> rule 8).
4848
49-
</Show>
49+
</If>
5050

5151
</Output>

‎.reviews/components/Show.md‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎.reviews/components/UnusedInDiff.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const summary = icon + " " + props.message
5151
.replace("{count}", String(unused.length));
5252
```
5353

54-
<Show when={hasUnused}>
54+
<If condition={hasUnused}>
5555

5656
<details>
5757
<summary>{summary}</summary>
@@ -63,4 +63,4 @@ const summary = icon + " " + props.message
6363

6464
</details>
6565

66-
</Show>
66+
</If>

‎.reviews/policies/ExtraneousCodePolicy.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ props:
1515
<ReviewSection heading="Correctness"
1616
clean="✅ Small PR — correctness review skipped.">
1717

18-
<Show when={props.pr.stats.totalChanges > 20}>
18+
<If condition={props.pr.stats.totalChanges > 20}>
1919

2020
<Sample>
2121

@@ -61,6 +61,6 @@ DIFF:
6161

6262
</Sample>
6363

64-
</Show>
64+
</If>
6565

6666
</ReviewSection>

‎.reviews/policies/RepoCleanupPolicy.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ props:
1717
<ReviewSection heading="Cleanup Policy"
1818
clean="✅ No code health issues detected.">
1919

20-
<Show when={props.diagnostics.total > 0 && !!props.cleanupAnalysis}>
20+
<If condition={props.diagnostics.total > 0 && !!props.cleanupAnalysis}>
2121

2222
<Sample>
2323

@@ -61,12 +61,12 @@ Example of a good item:
6161

6262
</Sample>
6363

64-
</Show>
64+
</If>
6565

66-
<Show when={props.diagnostics.total > 0 && !props.cleanupAnalysis}>
66+
<If condition={props.diagnostics.total > 0 && !props.cleanupAnalysis}>
6767

6868
{props.diagnostics.summary}
6969

70-
</Show>
70+
</If>
7171

7272
</ReviewSection>

‎packages/core/tests/unused-in-diff.test.ts‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ function doc(lines: AddedLine[], construct: string): string {
3232
].join("\n");
3333
}
3434

35-
// The real components are read before useStubFs replaces the filesystem, so
36-
// the tests exercise the shipped .reviews sources rather than a copy.
35+
// The real component is read before useStubFs replaces the filesystem, so the
36+
// tests exercise the shipped .reviews source rather than a copy. Its `<If>` is
37+
// a native directive, so the stub filesystem supplies no component for it.
3738
function* render(lines: AddedLine[], construct: string): Operation<string> {
3839
const unusedInDiff = yield* readTextFile(".reviews/components/UnusedInDiff.md");
39-
const show = yield* readTextFile(".reviews/components/Show.md");
4040

4141
yield* useStubFs({
4242
"components/UnusedInDiff.md": unusedInDiff,
43-
"components/Show.md": show,
4443
"doc.md": doc(lines, construct),
4544
});
4645

@@ -52,11 +51,21 @@ describe("UnusedInDiff", () => {
5251
it("renders the disclosure with symbol, location, count and reason", function* () {
5352
const output = yield* render([added("core/src/a.ts", 24, "type Orphan = string;")], "type");
5453

55-
expect(output).toContain("<details>");
56-
expect(output).toContain("<summary>🟡 1 with no consumers: Orphan.</summary>");
57-
expect(output).toContain("| `Orphan` | `core/src/a.ts:24` | 1 |");
58-
expect(output).toContain(WHY);
59-
expect(output).not.toContain("ERROR");
54+
// Exact so the selected branch's summary line, table header and row
55+
// whitespace are locked, not merely present somewhere in the output.
56+
expect(output.trim()).toBe(
57+
[
58+
"<details>",
59+
"<summary>🟡 1 with no consumers: Orphan.</summary>",
60+
"",
61+
"| Symbol | Declared at | Refs in diff | Why flagged |",
62+
"| --- | --- | --- | --- |",
63+
`| \`Orphan\` | \`core/src/a.ts:24\` | 1 | ${WHY} (pre-existing usages not counted) |`,
64+
"",
65+
"",
66+
"</details>",
67+
].join("\n"),
68+
);
6069
});
6170

6271
it("does not flag a type named only by an import specifier", function* () {

0 commit comments

Comments
 (0)