style: formatting

This commit is contained in:
2026-07-18 07:52:01 +05:00
parent 81f5be4cd3
commit 4c14d0ae25
13 changed files with 41 additions and 36 deletions
+2 -2
View File
@@ -137,8 +137,8 @@ tags:
- frontend - frontend
``` ```
Если `config.yml` есть, теги вне каталога — warning (Quick Fix: **Add tag "…" Если `config.yml` есть, теги вне каталога — warning (Quick Fix: **Add tag "…" to
to project**). Hover на `tags`**Edit tags…**. project**). Hover на `tags`**Edit tags…**.
## Dashboard ## Dashboard
+2 -2
View File
@@ -20,8 +20,8 @@ describe("deleteTask", () => {
const created = await repo.create(folder, { const created = await repo.create(folder, {
title: "To delete", title: "To delete",
description: "", description: "",
status: TaskStatus.OPEN, status: TaskStatus.OPEN,
priority: TaskPriority.MEDIUM, priority: TaskPriority.MEDIUM,
tags: [], tags: [],
assignee: "", assignee: "",
}); });
+4 -1
View File
@@ -59,7 +59,10 @@ describe("buildDashboardView", () => {
}); });
expect(view.visibleTasks.map((t) => t.id)).toEqual(["1", "3"]); expect(view.visibleTasks.map((t) => t.id)).toEqual(["1", "3"]);
expect(view.groups.map((g) => g.key)).toEqual([TaskPriority.HIGH, TaskPriority.MEDIUM]); expect(view.groups.map((g) => g.key)).toEqual([
TaskPriority.HIGH,
TaskPriority.MEDIUM,
]);
}); });
it("resolves selected task by id from the full task list", () => { it("resolves selected task by id from the full task list", () => {
+6 -2
View File
@@ -63,12 +63,16 @@ describe("filterTasks", () => {
}); });
it("filters by multiple statuses", () => { it("filters by multiple statuses", () => {
const result = filterTasks(tasks, { statuses: [TaskStatus.OPEN, TaskStatus.DONE] }); const result = filterTasks(tasks, {
statuses: [TaskStatus.OPEN, TaskStatus.DONE],
});
expect(result.map((t) => t.id)).toEqual(["1", "3", "4"]); expect(result.map((t) => t.id)).toEqual(["1", "3", "4"]);
}); });
it("filters by priority", () => { it("filters by priority", () => {
const result = filterTasks(tasks, { priorities: [TaskPriority.HIGH, TaskPriority.CRITICAL] }); const result = filterTasks(tasks, {
priorities: [TaskPriority.HIGH, TaskPriority.CRITICAL],
});
expect(result.map((t) => t.id)).toEqual(["1", "4"]); expect(result.map((t) => t.id)).toEqual(["1", "4"]);
}); });
+7 -7
View File
@@ -31,7 +31,11 @@ describe("replaceFrontmatterField", () => {
}); });
it("replaces priority value", () => { it("replaces priority value", () => {
const result = replaceFrontmatterField(sample, "priority", TaskPriority.CRITICAL); const result = replaceFrontmatterField(
sample,
"priority",
TaskPriority.CRITICAL,
);
expect(result.ok).toBe(true); expect(result.ok).toBe(true);
if (!result.ok) return; if (!result.ok) return;
expect(result.content).toContain("priority: critical"); expect(result.content).toContain("priority: critical");
@@ -60,9 +64,7 @@ describe("findFieldRange", () => {
describe("formatTagsYamlValue", () => { describe("formatTagsYamlValue", () => {
it("formats empty and simple lists", () => { it("formats empty and simple lists", () => {
expect(formatTagsYamlValue([])).toBe("[]"); expect(formatTagsYamlValue([])).toBe("[]");
expect(formatTagsYamlValue(["bug", "frontend"])).toBe( expect(formatTagsYamlValue(["bug", "frontend"])).toBe("[bug, frontend]");
"[bug, frontend]",
);
}); });
it("quotes tags with spaces", () => { it("quotes tags with spaces", () => {
@@ -118,9 +120,7 @@ describe("extractFrontmatterBlock", () => {
}); });
it("handles --- with trailing whitespace", () => { it("handles --- with trailing whitespace", () => {
const block = extractFrontmatterBlock( const block = extractFrontmatterBlock("--- \ntitle: Hello\n--- \nbody");
"--- \ntitle: Hello\n--- \nbody",
);
expect(block).not.toBeNull(); expect(block).not.toBeNull();
expect(block!.yaml).toBe("title: Hello"); expect(block!.yaml).toBe("title: Hello");
expect(block!.closeLine).toBe(2); expect(block!.closeLine).toBe(2);
+7 -2
View File
@@ -19,7 +19,9 @@ function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
} }
export function extractFrontmatterBlock(content: string): FrontmatterBlock | null { export function extractFrontmatterBlock(
content: string,
): FrontmatterBlock | null {
const NOT_FOUND = -1; const NOT_FOUND = -1;
const lines = content.split(/\r?\n/); const lines = content.split(/\r?\n/);
if (lines.length === 0 || lines[0].trim() !== "---") { if (lines.length === 0 || lines[0].trim() !== "---") {
@@ -62,7 +64,10 @@ export function extractFrontmatterBlock(content: string): FrontmatterBlock | nul
}; };
} }
export function findFieldRange(content: string, key: string): TextRange | undefined { export function findFieldRange(
content: string,
key: string,
): TextRange | undefined {
const block = extractFrontmatterBlock(content); const block = extractFrontmatterBlock(content);
if (!block || block.closeLine < 0) { if (!block || block.closeLine < 0) {
return block?.range; return block?.range;
+1 -3
View File
@@ -13,9 +13,7 @@ describe("projectConfig model", () => {
it("joins folder path with config.yml", () => { it("joins folder path with config.yml", () => {
expect(getProjectConfigPath("/ws/.xflow")).toBe("/ws/.xflow/config.yml"); expect(getProjectConfigPath("/ws/.xflow")).toBe("/ws/.xflow/config.yml");
expect(getProjectConfigPath("C:\\proj\\.xflow")).toMatch( expect(getProjectConfigPath("C:\\proj\\.xflow")).toMatch(/config\.yml$/);
/config\.yml$/,
);
}); });
it("empty config has no tags", () => { it("empty config has no tags", () => {
+1 -3
View File
@@ -23,9 +23,7 @@ export function parseProjectConfig(
data = yaml.load(content); data = yaml.load(content);
} catch (error) { } catch (error) {
const detail = error instanceof Error ? error.message : "invalid YAML"; const detail = error instanceof Error ? error.message : "invalid YAML";
return err( return err(appError(AppErrorVariant.INVALID_PROJECT_CONFIG, { detail }));
appError(AppErrorVariant.INVALID_PROJECT_CONFIG, { detail }),
);
} }
if (data === null || data === undefined) { if (data === null || data === undefined) {
+1 -3
View File
@@ -279,9 +279,7 @@ export async function runEditTaskTags(
seen.add(tag); seen.add(tag);
items.push({ items.push({
label: tag, label: tag,
description: catalog.includes(tag) description: catalog.includes(tag) ? undefined : "will add to config",
? undefined
: "will add to config",
tag, tag,
}); });
} }
+3 -3
View File
@@ -31,8 +31,8 @@ describe("resolveTaskFolderForPath", () => {
{ scope: TaskScope.PROJECT, folderPath: "/ws" }, { scope: TaskScope.PROJECT, folderPath: "/ws" },
{ scope: TaskScope.GLOBAL, folderPath: "/ws/.xflow" }, { scope: TaskScope.GLOBAL, folderPath: "/ws/.xflow" },
]; ];
expect( expect(resolveTaskFolderForPath("/ws/.xflow/a.xflow.md", nested)).toBe(
resolveTaskFolderForPath("/ws/.xflow/a.xflow.md", nested), "/ws/.xflow",
).toBe("/ws/.xflow"); );
}); });
}); });
+1 -2
View File
@@ -58,8 +58,7 @@ export function registerTaskCodeActions(
selector, selector,
new TaskCodeActionProvider(), new TaskCodeActionProvider(),
{ {
providedCodeActionKinds: providedCodeActionKinds: TaskCodeActionProvider.providedCodeActionKinds,
TaskCodeActionProvider.providedCodeActionKinds,
}, },
), ),
); );
+1 -5
View File
@@ -268,11 +268,7 @@ export function registerTaskCommands(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"xboctukFlow.addTagToProject", "xboctukFlow.addTagToProject",
(uri?: string, tag?: string) => (uri?: string, tag?: string) =>
runAddTagToProject( runAddTagToProject({ fs: deps.fs, config: deps.config }, uri, tag),
{ fs: deps.fs, config: deps.config },
uri,
tag,
),
), ),
vscode.commands.registerCommand("xboctukFlow.openDashboard", () => vscode.commands.registerCommand("xboctukFlow.openDashboard", () =>
runOpenDashboard(deps), runOpenDashboard(deps),
+5 -1
View File
@@ -19,7 +19,11 @@ export function unknownTagDiagnosticCode(tag: string): string {
} }
export function parseUnknownTagFromDiagnosticCode( export function parseUnknownTagFromDiagnosticCode(
code: string | number | { value: string | number; target: vscode.Uri } | undefined, code:
| string
| number
| { value: string | number; target: vscode.Uri }
| undefined,
): string | undefined { ): string | undefined {
const raw = const raw =
typeof code === "string" typeof code === "string"