Skip to content

Commit

Permalink
fix: exclude _fresh dir from lint + fmt (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Aug 17, 2023
1 parent 06fac31 commit ce4df30
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ const config = {
rules: {
tags: ["fresh", "recommended"],
},
exclude: ["_fresh"],
},
fmt: {
exclude: ["_fresh"],
},
imports: {} as Record<string, string>,
compilerOptions: {
Expand Down
7 changes: 7 additions & 0 deletions src/server/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export interface DenoConfig {
imports?: Record<string, string>;
importMap?: string;
tasks?: Record<string, string>;
lint?: {
rules: { tags?: string[] };
exclude?: string[];
};
fmt?: {
exclude?: string[];
};
compilerOptions?: {
jsx?: string;
jsxImportSource?: string;
Expand Down
12 changes: 12 additions & 0 deletions tests/cli_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ Deno.test({
const configPath = path.join(tmpDirName, "deno.json");
const json = JSON.parse(await Deno.readTextFile(configPath));

// Check tasks
assert(json.tasks.start, "Missing 'start' task");
assert(json.tasks.build, "Missing 'build' task");
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"]);
});

await t.step("start up the server and access the root page", async () => {
Expand Down Expand Up @@ -390,6 +398,10 @@ Deno.test("fresh-update", async function fn(t) {
assert(json.tasks?.start, "Missing 'start' task");
assert(json.tasks?.build, "Missing 'build' task");
assert(json.tasks?.preview, "Missing 'preview' task");

assertEquals(json.lint?.rules?.tags, ["fresh", "recommended"]);
assertEquals(json.lint?.exclude, ["_fresh"]);
assertEquals(json.fmt?.exclude, ["_fresh"]);
});

const comment = "// This is a test comment";
Expand Down
17 changes: 17 additions & 0 deletions update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ 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");
}

// Exclude _fresh dir from linting
if (!denoJson.fmt) {
denoJson.fmt = {};
}
if (!denoJson.fmt.exclude) {
denoJson.fmt.exclude = [];
}
if (!denoJson.fmt.exclude.includes("_fresh")) {
denoJson.fmt.exclude.push("_fresh");
}

if (!denoJson.tasks) {
denoJson.tasks = {};
Expand Down

0 comments on commit ce4df30

Please sign in to comment.