Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exclude _fresh dir from lint + fmt #1656

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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