Skip to content

Commit 9bab1b9

Browse files
committed
test: add evals for deep import rule (barrel vs page-specific components)
1 parent 6201a38 commit 9bab1b9

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.flue/evals/style-guide.eval.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,73 @@ describeEval("style-guide reviewer", { harness }, (it) => {
330330
"submit_style_guide",
331331
);
332332
});
333+
334+
it("flags a barrel-exported component imported via a deep path", async ({
335+
run,
336+
}) => {
337+
const result = await run({
338+
pullRequest: PR,
339+
headSha: HEAD_SHA,
340+
filename: "src/content/docs/workers/example.mdx",
341+
addedLines: [
342+
{
343+
line: 3,
344+
content: 'import { Tabs } from "~/components/ui/tabs.astro";',
345+
},
346+
],
347+
});
348+
349+
const findings = (result.output as { findings?: Finding[] })?.findings;
350+
expect(findings).toBeDefined();
351+
352+
const importFinding = (findings ?? []).find(
353+
(f) =>
354+
f.rule?.toLowerCase().includes("import") ||
355+
f.rule?.toLowerCase().includes("component") ||
356+
f.rule?.toLowerCase().includes("barrel") ||
357+
f.evidence?.includes("~/components/ui/"),
358+
);
359+
expect(importFinding).toBeDefined();
360+
expect(importFinding!.severity).toBe("warning");
361+
expect(importFinding!.path).toBe("src/content/docs/workers/example.mdx");
362+
expect(importFinding!.line).toBe(3);
363+
364+
expect(toolCalls(result).map((c) => c.name)).toContain(
365+
"submit_style_guide",
366+
);
367+
});
368+
369+
it("does not flag a page-specific wrapper component imported via a deep path", async ({
370+
run,
371+
}) => {
372+
const result = await run({
373+
pullRequest: PR,
374+
headSha: HEAD_SHA,
375+
filename: "src/content/docs/ai/models/index.mdx",
376+
addedLines: [
377+
{
378+
line: 15,
379+
content:
380+
'import AIModelCatalog from "~/components/models/AIModelCatalog.astro";',
381+
},
382+
],
383+
});
384+
385+
const findings = (result.output as { findings?: Finding[] })?.findings;
386+
expect(findings).toBeDefined();
387+
388+
const importWarnings = (findings ?? []).filter(
389+
(f) =>
390+
f.severity === "warning" &&
391+
(f.rule?.toLowerCase().includes("import") ||
392+
f.rule?.toLowerCase().includes("component") ||
393+
f.rule?.toLowerCase().includes("barrel") ||
394+
f.evidence?.includes("~/components/models/")),
395+
);
396+
expect(importWarnings).toHaveLength(0);
397+
398+
expect(toolCalls(result).map((c) => c.name)).toContain(
399+
"submit_style_guide",
400+
);
401+
});
333402
});

0 commit comments

Comments
 (0)