Skip to content

Commit 9284b2b

Browse files
saphidclaude
authored andcommitted
fix(scripts): check:changed lints Astro components and runs knip for them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cbd3e14 commit 9284b2b

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎scripts/check-changed.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,17 @@ it("checks changed source paths through the Windows launcher", () => {
407407
expect(result.stdout).toContain("fixture stderr: lint");
408408
});
409409

410+
it("lints an Astro component and runs knip when only it changed", () => {
411+
using project = launcherFixture();
412+
const page = "packages/example/Page.astro";
413+
project.write(page, "---\nconst title = 1;\n---\n<h1>{title}</h1>\n");
414+
const result = project.run();
415+
expect(result.status, result.stdout + result.stderr).toBe(0);
416+
const calls = project.calls();
417+
expect(calls.find(({ args }) => args[0] === "lint")?.args).toEqual(["lint", page]);
418+
expect(calls.some(({ args }) => args[0] === "exec" && args[1] === "knip")).toBe(true);
419+
});
420+
410421
it.each(["install", "lint"])("reports a failing %s step with its output", (step) => {
411422
using project = launcherFixture();
412423
project.write(project.source, "export const value = 2;\n");

‎scripts/check-changed.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ export const comparisonBase = Effect.fn("checkChanged.comparisonBase")(function*
172172
return closest;
173173
});
174174

175-
const CODE = /\.[cm]?[jt]sx?$/;
175+
// CI's lint and knip also read Astro components' frontmatter.
176+
const CODE = /\.(?:[cm]?[jt]sx?|astro)$/;
176177
const TEST = /\.test\.[cm]?[jt]sx?$/;
177178
// CI runs the .github/scripts tests with `node --test`; vitest passes a failing node:test file.
178179
const NODE_TEST = /^\.github[/\\]scripts[/\\]/;

0 commit comments

Comments
 (0)