fix: ensure deno task check passes in initialized projects (#2529)

There were two issues with initialized projects:
1. not every file was formatted properly
2. linting wasn't passing when using `verbatim-module-syntax`. This
isn't enabled right now, due to it not having the `recommended` tag, but
it seems like a good idea. Actually initializing a project with this can
be done in a separate PR.
This commit is contained in:
Reed von Redwitz
2024-06-23 17:44:07 +02:00
committed by GitHub
parent febbc52727
commit 5a7184ad99
2 changed files with 45 additions and 28 deletions
+28 -4
View File
@@ -31,9 +31,11 @@ async function patchProject(dir: string): Promise<void> {
json.imports = rootJson.imports;
json.imports["fresh"] = "../src/mod.ts";
json.imports["fresh/dev"] = "../src/dev/mod.ts";
json.imports["@fresh/plugin-tailwind"] = "../plugin-tailwindcss/mod.ts";
json.imports["@fresh/plugin-tailwind"] = "../plugin-tailwindcss/src/mod.ts";
// assert with this stricter rule, before adding it to initialized projects
json.lint.rules.include = ["verbatim-module-syntax"];
await Deno.writeTextFile(jsonPath, JSON.stringify(json, null, 2));
await Deno.writeTextFile(jsonPath, JSON.stringify(json, null, 2) + "\n");
}
function mockUserInput(steps: Record<string, unknown>) {
@@ -125,7 +127,7 @@ Deno.test("init - with vscode", async () => {
});
});
Deno.test("init - type check project", async () => {
Deno.test("init - fmt, lint, and type check project", async () => {
await withTmpDir(async (dir) => {
const mock = mockUserInput({
[InitStep.ProjectName]: ".",
@@ -137,7 +139,29 @@ Deno.test("init - type check project", async () => {
await patchProject(dir);
const check = await new Deno.Command(Deno.execPath(), {
args: ["check", "main.ts", "dev.ts"],
args: ["task", "check"],
cwd: dir,
stderr: "inherit",
stdout: "inherit",
}).output();
expect(check.code).toEqual(0);
});
});
Deno.test("init with tailwind - fmt, lint, and type check project", async () => {
await withTmpDir(async (dir) => {
const mock = mockUserInput({
[InitStep.ProjectName]: ".",
[InitStep.Tailwind]: true,
});
await initProject(dir, [], {}, mock.tty);
await expectProjectFile(dir, "main.ts");
await expectProjectFile(dir, "dev.ts");
await patchProject(dir);
const check = await new Deno.Command(Deno.execPath(), {
args: ["task", "check"],
cwd: dir,
stderr: "inherit",
stdout: "inherit",