feat: exclude _fresh dir from everything (#1788)
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
"check:types": "deno check **/*.ts && deno check **/*.tsx",
|
||||
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test"
|
||||
},
|
||||
"exclude": [
|
||||
"**/_fresh/*"
|
||||
],
|
||||
"importMap": "./.vscode/import_map.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -564,11 +564,8 @@ const config = {
|
||||
rules: {
|
||||
tags: ["fresh", "recommended"],
|
||||
},
|
||||
exclude: ["_fresh"],
|
||||
},
|
||||
fmt: {
|
||||
exclude: ["_fresh"],
|
||||
},
|
||||
exclude: ["**/_fresh/*"],
|
||||
imports: {} as Record<string, string>,
|
||||
compilerOptions: {
|
||||
jsx: "react-jsx",
|
||||
|
||||
@@ -91,6 +91,7 @@ export interface DenoConfig {
|
||||
fmt?: {
|
||||
exclude?: string[];
|
||||
};
|
||||
exclude?: string[];
|
||||
compilerOptions?: {
|
||||
jsx?: string;
|
||||
jsxImportSource?: string;
|
||||
|
||||
+2
-3
@@ -92,11 +92,10 @@ Deno.test({
|
||||
assert(json.tasks.preview, "Missing 'preview' task");
|
||||
|
||||
// Check lint settings
|
||||
assertEquals(json.lint.exclude, ["_fresh"]);
|
||||
assertEquals(json.lint.rules.tags, ["fresh", "recommended"]);
|
||||
|
||||
// Check fmt settings
|
||||
assertEquals(json.fmt.exclude, ["_fresh"]);
|
||||
// Check exclude settings
|
||||
assertEquals(json.exclude, ["**/_fresh/*"]);
|
||||
});
|
||||
|
||||
await t.step("start up the server and access the root page", async () => {
|
||||
|
||||
+26
-2
@@ -76,8 +76,7 @@ Deno.test("fresh-update", async function fn(t) {
|
||||
assertExists(json.tasks?.preview, "Missing 'preview' task");
|
||||
|
||||
assertEquals(json.lint?.rules?.tags, ["fresh", "recommended"]);
|
||||
assertEquals(json.lint?.exclude, ["_fresh"]);
|
||||
assertEquals(json.fmt?.exclude, ["_fresh"]);
|
||||
assertEquals(json.exclude, ["**/_fresh/*"]);
|
||||
});
|
||||
|
||||
const comment = "// This is a test comment";
|
||||
@@ -223,3 +222,28 @@ Deno.test(
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Deno.test(
|
||||
"fresh-update migrates old exclude to top level exclude",
|
||||
async (t) => {
|
||||
// Preparation
|
||||
const tmpDirName = await initProject();
|
||||
const denoJsonFile = path.join(tmpDirName, "deno.json");
|
||||
const denoJson = JSON.parse(await Deno.readTextFile(denoJsonFile));
|
||||
delete denoJson.exclude;
|
||||
if (!denoJson.fmt) denoJson.fmt = {};
|
||||
if (!denoJson.lint) denoJson.lint = {};
|
||||
denoJson.fmt.exclude = ["_fresh"];
|
||||
denoJson.lint.exclude = ["_fresh"];
|
||||
await Deno.writeTextFile(denoJsonFile, JSON.stringify(denoJson, null, 2));
|
||||
|
||||
await executeUpdateCommand(t, tmpDirName);
|
||||
|
||||
const denoJsonAfter = JSON.parse(Deno.readTextFileSync(denoJsonFile));
|
||||
assertEquals(denoJsonAfter.exclude, ["**/_fresh/*"]);
|
||||
assertEquals(denoJsonAfter.lint, {
|
||||
rules: { tags: ["fresh", "recommended"] },
|
||||
});
|
||||
assertEquals(denoJsonAfter.fmt, undefined);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -87,22 +87,37 @@ if (!denoJson.lint.rules.tags.includes("fresh")) {
|
||||
if (!denoJson.lint.rules.tags.includes("recommended")) {
|
||||
denoJson.lint.rules.tags.push("recommended");
|
||||
}
|
||||
if (!denoJson.lint.exclude) {
|
||||
denoJson.lint.exclude = [];
|
||||
}
|
||||
if (!denoJson.lint.exclude.includes("_fresh")) {
|
||||
denoJson.lint.exclude.push("_fresh");
|
||||
|
||||
// Remove old _fresh exclude where we added it separately to
|
||||
// "lint" and "fmt"
|
||||
const fmtExcludeIdx = denoJson?.fmt?.exclude?.indexOf("_fresh");
|
||||
if (fmtExcludeIdx > -1) {
|
||||
denoJson.fmt.exclude.splice(fmtExcludeIdx, 1);
|
||||
if (denoJson.fmt.exclude.length === 0) {
|
||||
delete denoJson.fmt.exclude;
|
||||
}
|
||||
if (Object.keys(denoJson.fmt).length === 0) {
|
||||
delete denoJson.fmt;
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude _fresh dir from linting
|
||||
if (!denoJson.fmt) {
|
||||
denoJson.fmt = {};
|
||||
const lintExcludeIdx = denoJson?.lint?.exclude?.indexOf("_fresh");
|
||||
if (lintExcludeIdx > -1) {
|
||||
denoJson.lint.exclude.splice(lintExcludeIdx, 1);
|
||||
if (denoJson.lint.exclude.length === 0) {
|
||||
delete denoJson.lint.exclude;
|
||||
}
|
||||
if (Object.keys(denoJson.lint).length === 0) {
|
||||
delete denoJson.lint;
|
||||
}
|
||||
}
|
||||
if (!denoJson.fmt.exclude) {
|
||||
denoJson.fmt.exclude = [];
|
||||
|
||||
// Exclude _fresh dir from everything
|
||||
if (!denoJson.exclude) {
|
||||
denoJson.exclude = [];
|
||||
}
|
||||
if (!denoJson.fmt.exclude.includes("_fresh")) {
|
||||
denoJson.fmt.exclude.push("_fresh");
|
||||
if (!denoJson.exclude.includes("**/_fresh/*")) {
|
||||
denoJson.exclude.push("**/_fresh/*");
|
||||
}
|
||||
|
||||
if (!denoJson.tasks) {
|
||||
|
||||
Reference in New Issue
Block a user