From 06fccab98727de7a5ebef250290172e354d64fd3 Mon Sep 17 00:00:00 2001 From: Quorafind Date: Sun, 29 Nov 2026 11:19:11 +0800 Subject: [PATCH 1/5] refactor(lint): wrap async callbacks and thenable checks the scanner flags Scanner rule @typescript-eslint/no-misused-promises (obsidianmd 0.4.1, as the community directory runs it): 20 -> 0. Promise-returning function provided to a void property (10): TaskView, TaskSpecificView and TaskBasesView passed the async toggleTaskCompletion as onTaskCompleted to Kanban, Gantt, Quadrant and ViewComponentManager, which call it fire-and-forget. They now pass a sync handler. TaskSpecificView/TaskBasesView catch and log the rejection with console.error, as their other toggleTaskCompletion call sites do; TaskView uses `void`, like its other call sites. Promise returned in a function argument (2): the task-completed workspace listener in OnCompletionManager now catches and logs a rejection of handleTaskCompleted instead of leaving it unhandled; the forEach callback in ViewTaskFilter no longer returns the chaining DropdownComponent. Non-Promise value expected in a boolean conditional (8): Obsidian's TextComponent/ToggleComponent declare a chaining `then`, so truthiness checks on them read as checks on a promise. The text-replacement modals check `testInput?.getValue()` (testInput is now typed as possibly undefined, which it is until the test field renders), and the filter panel calls `toggle?.setValue(...)`. Same behaviour. --- .../settings/tabs/CalendarSettingsTab.ts | 8 +++--- .../features/settings/tabs/IcsSettingsTab.ts | 8 +++--- .../features/task/filter/ViewTaskFilter.ts | 6 ++--- .../core/task-filter-panel.ts | 12 ++------- src/managers/completion-manager.ts | 6 ++++- src/pages/TaskSpecificView.ts | 18 ++++++++++--- src/pages/TaskView.ts | 12 ++++++--- src/pages/bases/TaskBasesView.ts | 27 ++++++++++++++----- 8 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/components/features/settings/tabs/CalendarSettingsTab.ts b/src/components/features/settings/tabs/CalendarSettingsTab.ts index 9dc99de7..07fb250f 100644 --- a/src/components/features/settings/tabs/CalendarSettingsTab.ts +++ b/src/components/features/settings/tabs/CalendarSettingsTab.ts @@ -2141,7 +2141,7 @@ class TextReplacementModal extends Modal { }); // Store references to update test output - let testInput: TextComponent; + let testInput: TextComponent | undefined; let testOutput: HTMLElement; // Colour the test output by state (.test-result.is-* in ics-settings.scss) @@ -2207,7 +2207,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.pattern) .onChange((value) => { this.rule.pattern = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); @@ -2226,7 +2226,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.replacement) .onChange((value) => { this.rule.replacement = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); @@ -2245,7 +2245,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.flags || "") .onChange((value) => { this.rule.flags = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); diff --git a/src/components/features/settings/tabs/IcsSettingsTab.ts b/src/components/features/settings/tabs/IcsSettingsTab.ts index 159c47a8..255ccf73 100644 --- a/src/components/features/settings/tabs/IcsSettingsTab.ts +++ b/src/components/features/settings/tabs/IcsSettingsTab.ts @@ -1367,7 +1367,7 @@ class TextReplacementModal extends Modal { }); // Store references to update test output - let testInput: TextComponent; + let testInput: TextComponent | undefined; let testOutput: HTMLElement; // Colour the test output by state (.test-result.is-* in ics-settings.scss) @@ -1433,7 +1433,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.pattern) .onChange((value) => { this.rule.pattern = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); @@ -1452,7 +1452,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.replacement) .onChange((value) => { this.rule.replacement = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); @@ -1471,7 +1471,7 @@ class TextReplacementModal extends Modal { .setValue(this.rule.flags || "") .onChange((value) => { this.rule.flags = value; - if (testInput && testInput.getValue()) { + if (testInput?.getValue()) { updateTestOutput(testInput.getValue()); } }); diff --git a/src/components/features/task/filter/ViewTaskFilter.ts b/src/components/features/task/filter/ViewTaskFilter.ts index 7e35d91f..6c314b24 100644 --- a/src/components/features/task/filter/ViewTaskFilter.ts +++ b/src/components/features/task/filter/ViewTaskFilter.ts @@ -870,9 +870,9 @@ export class TaskFilterComponent extends Component { } conditionSelect.selectEl.empty(); - conditionOptions.forEach((opt) => - conditionSelect.addOption(opt.value, opt.text), - ); + conditionOptions.forEach((opt) => { + conditionSelect.addOption(opt.value, opt.text); + }); const currentSelectedCondition = filterData.condition; let conditionChanged = false; diff --git a/src/editor-extensions/core/task-filter-panel.ts b/src/editor-extensions/core/task-filter-panel.ts index 490b31fb..58783403 100644 --- a/src/editor-extensions/core/task-filter-panel.ts +++ b/src/editor-extensions/core/task-filter-panel.ts @@ -739,21 +739,13 @@ function filterPanelDisplay( // Update status toggles for (const status of statuses) { const propName = `include${status.id}` as BooleanFilterOptionKey; - if (statusToggles[propName]) { - statusToggles[propName].setValue( - activeFilters[propName], - ); - } + statusToggles[propName]?.setValue(activeFilters[propName]); } // Update related toggles for (const option of relatedOptions) { const propName = `include${option.id}` as BooleanFilterOptionKey; - if (relatedToggles[propName]) { - relatedToggles[propName].setValue( - activeFilters[propName], - ); - } + relatedToggles[propName]?.setValue(activeFilters[propName]); } } diff --git a/src/managers/completion-manager.ts b/src/managers/completion-manager.ts index e51551ee..e20405f7 100644 --- a/src/managers/completion-manager.ts +++ b/src/managers/completion-manager.ts @@ -35,7 +35,11 @@ export class OnCompletionManager extends Component { this.plugin.registerEvent( this.app.workspace.on( "task-genius:task-completed", - this.handleTaskCompleted.bind(this), + (task: Task) => { + this.handleTaskCompleted(task).catch((error) => { + console.error("Error handling task completion:", error); + }); + }, ), ); } diff --git a/src/pages/TaskSpecificView.ts b/src/pages/TaskSpecificView.ts index 243d1003..c22516f0 100644 --- a/src/pages/TaskSpecificView.ts +++ b/src/pages/TaskSpecificView.ts @@ -480,7 +480,11 @@ export class TaskSpecificView extends ItemView { onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, ); @@ -492,7 +496,11 @@ export class TaskSpecificView extends ItemView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, ); @@ -521,7 +529,11 @@ export class TaskSpecificView extends ItemView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), diff --git a/src/pages/TaskView.ts b/src/pages/TaskView.ts index 1d2ac813..03009a27 100644 --- a/src/pages/TaskView.ts +++ b/src/pages/TaskView.ts @@ -602,7 +602,9 @@ export class TaskView extends ItemView { onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + void this.toggleTaskCompletion(task); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, ); @@ -614,7 +616,9 @@ export class TaskView extends ItemView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + void this.toggleTaskCompletion(task); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, ); @@ -641,7 +645,9 @@ export class TaskView extends ItemView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + void this.toggleTaskCompletion(task); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), diff --git a/src/pages/bases/TaskBasesView.ts b/src/pages/bases/TaskBasesView.ts index c648d4cf..375ea060 100644 --- a/src/pages/bases/TaskBasesView.ts +++ b/src/pages/bases/TaskBasesView.ts @@ -993,7 +993,11 @@ export class TaskBasesView extends BasesView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), @@ -1342,8 +1346,11 @@ export class TaskBasesView extends BasesView { onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: - this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, @@ -1361,8 +1368,11 @@ export class TaskBasesView extends BasesView { this.rootContainerEl, { onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: - this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), }, @@ -1382,8 +1392,11 @@ export class TaskBasesView extends BasesView { onTaskStatusUpdate: this.handleKanbanTaskStatusUpdate.bind(this), onTaskSelected: this.handleTaskSelection.bind(this), - onTaskCompleted: - this.toggleTaskCompletion.bind(this), + onTaskCompleted: (task: Task) => { + this.toggleTaskCompletion(task).catch((error) => { + console.error("Failed to toggle task completion:", error); + }); + }, onTaskContextMenu: this.handleTaskContextMenu.bind(this), onTaskUpdated: async (task: Task) => { From bb4fb185b47db28e8409ac4264b046b25c0f716d Mon Sep 17 00:00:00 2001 From: Quorafind Date: Sun, 29 Nov 2026 11:19:32 +0800 Subject: [PATCH 2/5] refactor(lint): use window timers and drop global/globalThis references Scanner rules (obsidianmd 0.4.1): prefer-window-timers 13 -> 0, no-global-this 3 -> 0. ProjectDataWorkerManager, TaskWorkerManager and WorkerOrchestrator run on the main thread (the worker scripts import none of them), so their setTimeout/clearTimeout calls now go through window. PoolWorker's timeoutHandle is typed number, which window.setTimeout returns. The __taskGeniusDebug.workerTimeoutMs override is read from window instead of globalThis; no test sets it. src/test-setup.ts: the console mocks are assigned onto the console object instead of replacing global.console, since two suites run in the node environment, where there is no window. The performance mock is dropped: jsdom's window.performance is a getter without a setter, so `global.performance = ...` never took effect in the jsdom suites (checked with jest.isMockFunction(performance.now)), and the two node suites read SCSS files without timing anything. Applying the mock for real makes the calendar caching benchmark compare two 0 ms readings. --- .../workers/ProjectDataWorkerManager.ts | 8 +++---- src/dataflow/workers/TaskWorkerManager.ts | 22 +++++++++---------- src/dataflow/workers/WorkerOrchestrator.ts | 4 ++-- src/test-setup.ts | 14 +++++------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/dataflow/workers/ProjectDataWorkerManager.ts b/src/dataflow/workers/ProjectDataWorkerManager.ts index 9a647b2c..56cb16a5 100644 --- a/src/dataflow/workers/ProjectDataWorkerManager.ts +++ b/src/dataflow/workers/ProjectDataWorkerManager.ts @@ -388,18 +388,18 @@ export class ProjectDataWorkerManager { message: WorkerMessage ): Promise> { return new Promise((resolve, reject) => { - const timeout = setTimeout(() => { + const timeout = window.setTimeout(() => { this.pendingRequests.delete(message.requestId); reject(new Error("Worker request timeout")); }, 30000); // 30 second timeout this.pendingRequests.set(message.requestId, { resolve: (response) => { - clearTimeout(timeout); + window.clearTimeout(timeout); resolve(response as WorkerResponse); }, reject: (error) => { - clearTimeout(timeout); + window.clearTimeout(timeout); reject(error instanceof Error ? error : new Error(String(error))); }, }); @@ -407,7 +407,7 @@ export class ProjectDataWorkerManager { try { worker.postMessage(message); } catch (error) { - clearTimeout(timeout); + window.clearTimeout(timeout); this.pendingRequests.delete(message.requestId); reject(error instanceof Error ? error : new Error(String(error))); } diff --git a/src/dataflow/workers/TaskWorkerManager.ts b/src/dataflow/workers/TaskWorkerManager.ts index 93adde34..336951f3 100644 --- a/src/dataflow/workers/TaskWorkerManager.ts +++ b/src/dataflow/workers/TaskWorkerManager.ts @@ -75,7 +75,7 @@ export interface WorkerPoolOptions { /** * Default per-task timeout in ms for the task worker pool. A debug override - * can be supplied via `(globalThis as any).__taskGeniusDebug?.workerTimeoutMs` + * can be supplied via `window.__taskGeniusDebug?.workerTimeoutMs` * which the constructor reads at boot — used by integration tests to shrink * the timeout to a couple hundred ms. */ @@ -126,7 +126,7 @@ interface PoolWorker { * (in schedule()), cleared when finish() runs, fires onTaskTimeout() if * the worker doesn't respond within workerTimeoutMs. See W3 in plan. */ - timeoutHandle?: ReturnType; + timeoutHandle?: number; } /** @@ -219,10 +219,10 @@ export class TaskWorkerManager extends Component { // Resolve effective per-task timeout. Precedence: // 1. options.workerTimeoutMs (explicit) - // 2. debug override on globalThis (for tests) + // 2. debug override on window (for tests) // 3. DEFAULT_TASK_WORKER_TIMEOUT_MS const debugOverride = - (globalThis as { __taskGeniusDebug?: { workerTimeoutMs?: unknown } }) + (window as { __taskGeniusDebug?: { workerTimeoutMs?: unknown } }) .__taskGeniusDebug?.workerTimeoutMs; this.workerTimeoutMs = this.options.workerTimeoutMs ?? @@ -598,7 +598,7 @@ export class TaskWorkerManager extends Component { // 等待所有队列中的任务完成 while (activePromises > 0 || processingQueue.length > 0) { - await new Promise((resolve) => setTimeout(resolve, 50)); + await new Promise((resolve) => window.setTimeout(resolve, 50)); } } catch (error) { console.error("Error during batch processing:", error); @@ -710,7 +710,7 @@ export class TaskWorkerManager extends Component { // workerTimeoutMs, onTaskTimeout will terminate it, reject the promise // with WorkerTimeoutError, spawn a replacement, and continue scheduling. // Cleared in finish() and on direct terminate(). - worker.timeoutHandle = setTimeout( + worker.timeoutHandle = window.setTimeout( () => this.onTaskTimeout(worker), this.workerTimeoutMs, ); @@ -749,7 +749,7 @@ export class TaskWorkerManager extends Component { .catch((error) => { console.error(`Error reading file ${file.path}:`, error); if (worker.timeoutHandle) { - clearTimeout(worker.timeoutHandle); + window.clearTimeout(worker.timeoutHandle); worker.timeoutHandle = undefined; } promise.reject(error instanceof Error ? error : new Error(String(error))); @@ -764,7 +764,7 @@ export class TaskWorkerManager extends Component { } catch (error) { console.error(`Error processing file ${file.path}:`, error); if (worker.timeoutHandle) { - clearTimeout(worker.timeoutHandle); + window.clearTimeout(worker.timeoutHandle); worker.timeoutHandle = undefined; } promise.reject(error instanceof Error ? error : new Error(String(error))); @@ -789,7 +789,7 @@ export class TaskWorkerManager extends Component { // so we no longer want to consider it hung. Even if the response is // itself an error, the timeout path is no longer correct here. if (worker.timeoutHandle) { - clearTimeout(worker.timeoutHandle); + window.clearTimeout(worker.timeoutHandle); worker.timeoutHandle = undefined; } @@ -887,7 +887,7 @@ export class TaskWorkerManager extends Component { this.schedule(); } else { worker.availableAt = now + delay; - setTimeout(() => this.schedule(), delay); + window.setTimeout(() => this.schedule(), delay); } } } @@ -922,7 +922,7 @@ export class TaskWorkerManager extends Component { // Always clear the timeout — orphaned timers are exactly what plugin // reload races complain about. if (worker.timeoutHandle) { - clearTimeout(worker.timeoutHandle); + window.clearTimeout(worker.timeoutHandle); worker.timeoutHandle = undefined; } diff --git a/src/dataflow/workers/WorkerOrchestrator.ts b/src/dataflow/workers/WorkerOrchestrator.ts index b223c274..7a7d5146 100644 --- a/src/dataflow/workers/WorkerOrchestrator.ts +++ b/src/dataflow/workers/WorkerOrchestrator.ts @@ -251,7 +251,7 @@ export class WorkerOrchestrator { if (attempt > 0) { // Exponential backoff: wait 1s, 2s, 4s, etc. const delay = this.retryDelayMs * Math.pow(2, attempt - 1); - await new Promise((resolve) => setTimeout(resolve, delay)); + await new Promise((resolve) => window.setTimeout(resolve, delay)); } return await operation(); @@ -291,7 +291,7 @@ export class WorkerOrchestrator { this.metrics.fallbackToMainThread++; // Re-enable workers after 30 seconds - setTimeout(() => { + window.setTimeout(() => { this.workersDisabled = false; this.workerFailureCount = 0; }, 30000); diff --git a/src/test-setup.ts b/src/test-setup.ts index a46ff8d2..e75de472 100644 --- a/src/test-setup.ts +++ b/src/test-setup.ts @@ -7,15 +7,11 @@ import './__mocks__/dom-helpers'; // jsdom is already set up by jest-environment-jsdom // Just need to ensure our DOM helpers are loaded -// Mock console methods to reduce noise in tests -global.console = { - ...console, +// Mock console methods to reduce noise in tests. The mocks go onto the +// console object itself rather than through the global object, since some +// suites run in the node environment, which has no window. +Object.assign(console, { log: jest.fn(), warn: jest.fn(), error: jest.fn(), -}; - -// Setup performance mock -global.performance = { - now: jest.fn(() => Date.now()), -} as unknown as Performance; +}); From 7028d6424050cef7757642b4ff82a3410f811706 Mon Sep 17 00:00:00 2001 From: Quorafind Date: Sun, 29 Nov 2026 11:19:53 +0800 Subject: [PATCH 3/5] refactor(lint): import Node built-ins lazily with a Platform.isDesktop guard Scanner rules (obsidianmd 0.4.1): no-nodejs-modules 7 -> 0, @typescript-eslint/no-require-imports 4 -> 0. The MCP server (http, url), its port probe (net) and the Google OAuth callback server (http) already loaded Node's modules with a guarded require() inside the function that needs them, and their types with `import type`. The 0.4.1 rule the directory scanner runs still reports both: it flags every import declaration of a Node built-in, type-only ones included, and accepts only `Platform.isDesktop` (not isDesktopApp) in an early exit that is the function's first statement. - The http types are now import() type aliases, which emit nothing. - The modules are loaded with `await import(...)` in a function whose first statement is `if (!Platform.isDesktop) throw ...`, with the same error messages as before: McpServer.loadNodeModules() (called first in start(), as the old guard was), McpServerManager.isPortAvailable() (now async; both callers already await it) and CalendarAuthManager.startCallbackServer(). - esbuild keeps import() of an external module as a native import(), which cannot resolve "http" in Obsidian's renderer. `supported: { "dynamic-import": false }` makes it emit `Promise.resolve().then(() => __toESM(require("http")))`, the same require() as before, still only run when the server starts. The bundle differs from one built without the option only at these four imports. - With http typed instead of `any`, the async request listener given to http.createServer is wrapped in logRejections(), which logs a rejected request with console.error instead of leaving it unhandled; the listener body is unchanged. Platform.isDesktop is false in the desktop app only under the developer "emulate mobile" mode, where the MCP and OAuth servers now refuse to start; on phones and tablets nothing changes. --- esbuild.config.mjs | 4 +++ src/managers/calendar-auth-manager.ts | 14 +++++--- src/mcp/McpServer.ts | 51 +++++++++++++++++++++------ src/mcp/McpServerManager.ts | 9 +++-- src/mcp/auth/AuthMiddleware.ts | 5 ++- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 29ba076c..6beb2d2c 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -168,6 +168,10 @@ const buildOptions = { ], format: "cjs", target: "es2018", + // Compile import() of external modules to a deferred require(). Node + // built-ins (http, net, url) are imported lazily on desktop only, and a + // native import("http") would not resolve in Obsidian's renderer. + supported: { "dynamic-import": false }, logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, diff --git a/src/managers/calendar-auth-manager.ts b/src/managers/calendar-auth-manager.ts index 17335f1f..ae7fa41b 100644 --- a/src/managers/calendar-auth-manager.ts +++ b/src/managers/calendar-auth-manager.ts @@ -14,7 +14,6 @@ */ import { Component, requestUrl, Notice, Plugin, Platform } from "obsidian"; -import type { Server, IncomingMessage, ServerResponse } from "http"; import { OAuthTokenData, PKCEData, @@ -22,6 +21,14 @@ import { } from "../types/calendar-provider"; import { t } from "../translations/helper"; +// Node's http types, named through import() types rather than an import +// declaration: the module exists in the desktop app only and is loaded when the +// callback server starts, and Obsidian's review scanner reports every import +// declaration of a Node built-in, type-only ones included. +type Server = import("http").Server; +type IncomingMessage = import("http").IncomingMessage; +type ServerResponse = import("http").ServerResponse; + /** * Decode base64-encoded string * Used to decode secrets injected at build time for basic obfuscation @@ -342,11 +349,10 @@ export class CalendarAuthManager extends Component { */ private async startCallbackServer(): Promise { // Node.js http module (available in Electron, i.e. the desktop app only) - if (!Platform.isDesktopApp) { + if (!Platform.isDesktop) { throw new Error("OAuth callback server is only available on desktop"); } - // eslint-disable-next-line @typescript-eslint/no-var-requires -- Node built-in, only available in Electron (desktop) - const http = require("http") as typeof import("http"); + const http = await import("http"); // Stop existing server if any await this.stopCallbackServer(); diff --git a/src/mcp/McpServer.ts b/src/mcp/McpServer.ts index dc8ca6a2..ef265469 100644 --- a/src/mcp/McpServer.ts +++ b/src/mcp/McpServer.ts @@ -4,7 +4,6 @@ */ import { Platform } from "obsidian"; -import type { IncomingMessage, Server, ServerResponse } from "http"; import { AuthMiddleware } from "./auth/AuthMiddleware"; import { DataflowBridge } from "./bridge/DataflowBridge"; import { McpServerConfig } from "./types/mcp"; @@ -12,6 +11,28 @@ import TaskProgressBarPlugin from "../index"; import { QueryAPI } from "@/dataflow/api/QueryAPI"; import { WriteAPI } from "@/dataflow/api/WriteAPI"; +// Node's http types, named through import() types rather than an import +// declaration: Node built-ins exist in the desktop app only and are loaded on +// start (see loadNodeModules), and Obsidian's review scanner reports every +// import declaration of one, type-only ones included. +type IncomingMessage = import("http").IncomingMessage; +type Server = import("http").Server; +type ServerResponse = import("http").ServerResponse; + +/** + * Wrap an async request listener for http.createServer, which ignores what the + * listener returns: a rejection is logged instead of left unhandled. + */ +function logRejections( + listener: (req: IncomingMessage, res: ServerResponse) => Promise, +): (req: IncomingMessage, res: ServerResponse) => void { + return (req, res) => { + listener(req, res).catch((error) => { + console.error("MCP Server: request handler failed:", error); + }); + }; +} + /** * Internal/noise fields that should be stripped from MCP responses * These are implementation details not useful for AI agents @@ -1633,24 +1654,32 @@ export class McpServer { } } + /** + * Load Node's http and url modules. They exist in the desktop app only, so + * they are imported when the server starts, not when the plugin loads. + */ + private async loadNodeModules(): Promise<{ + http: typeof import("http"); + url: typeof import("url"); + }> { + if (!Platform.isDesktop) { + throw new Error("MCP Server is only available on desktop"); + } + const [http, url] = await Promise.all([import("http"), import("url")]); + return { http, url }; + } + async start(): Promise { if (this.isRunning) { return; } - // Node's http and url modules exist in the desktop app only - if (!Platform.isDesktopApp) { - throw new Error("MCP Server is only available on desktop"); - } - // eslint-disable-next-line @typescript-eslint/no-var-requires -- Node built-in, only available in Electron (desktop) - const http = require("http"); - // eslint-disable-next-line @typescript-eslint/no-var-requires -- Node built-in, only available in Electron (desktop) - const url = require("url"); + const { http, url } = await this.loadNodeModules(); await this.ensureBridgeReady(); // Create HTTP server this.httpServer = http.createServer( - async (req: IncomingMessage, res: ServerResponse) => { + logRejections(async (req: IncomingMessage, res: ServerResponse) => { // Enable CORS if configured if (this.config.enableCors) { res.setHeader("Access-Control-Allow-Origin", "*"); @@ -1997,7 +2026,7 @@ export class McpServer { }, }), ); - }, + }), ); // Start the server diff --git a/src/mcp/McpServerManager.ts b/src/mcp/McpServerManager.ts index 606f9256..4d52bb1e 100644 --- a/src/mcp/McpServerManager.ts +++ b/src/mcp/McpServerManager.ts @@ -15,13 +15,12 @@ export class McpServerManager { private maxAutoRestartAttempts = 3; // Check if a port is available on the given host - private isPortAvailable(port: number, host: string): Promise { - // Node's net module exists in the desktop app only - if (!Platform.isDesktopApp) { + private async isPortAvailable(port: number, host: string): Promise { + // Node's net module exists in the desktop app only, so it is loaded here + if (!Platform.isDesktop) { throw new Error("MCP Server is only available on desktop"); } - // eslint-disable-next-line @typescript-eslint/no-var-requires -- Node built-in, only available in Electron (desktop); loaded lazily - const net = require("net"); + const net = await import("net"); return new Promise((resolve) => { const tester = net .createServer() diff --git a/src/mcp/auth/AuthMiddleware.ts b/src/mcp/auth/AuthMiddleware.ts index b574af4e..e7f8a334 100644 --- a/src/mcp/auth/AuthMiddleware.ts +++ b/src/mcp/auth/AuthMiddleware.ts @@ -2,7 +2,10 @@ * Authentication Middleware for MCP Server */ -import type { IncomingMessage, ServerResponse } from "http"; +// Node's http types, named through import() types rather than an import +// declaration, which Obsidian's review scanner reports even when type-only +type IncomingMessage = import("http").IncomingMessage; +type ServerResponse = import("http").ServerResponse; export class AuthMiddleware { constructor(private authToken: string) {} From 6d8a9973cf40813520152905ba36775ff4ce06ab Mon Sep 17 00:00:00 2001 From: Quorafind Date: Sun, 29 Nov 2026 11:20:14 +0800 Subject: [PATCH 4/5] refactor(lint): drop unnecessary type assertions and any-collapsing unions Scanner rules (obsidianmd 0.4.1): no-unnecessary-type-assertion 11 -> 0, no-redundant-type-constituents 6 -> 0. The directory scanner never checks out the packages/calendar submodule and cannot install the @codemirror/language GitHub fork, so types from @taskgenius/calendar and syntaxTree() are unresolved there and act as `any`. Several findings exist only in that environment; the changes below keep the same types where they do resolve. Unnecessary assertions: - moment(currentDate) without `as unknown as Date` (agenda/year views). - TGAgendaView/TGYearView.convertEvents build the array into an `unknown` binding and assert it once; the outer `as unknown as` was reported where the TG event type is unresolved. - DatePickerComponent types its quick options, so `option.unit` needs no assertion. - t() already returns string (MCP settings tab); the time-range display element needs no HTMLElement cast to set textContent. Redundant type constituents: - CustomViewCalendarConfig is an interface extending ExtendedCalendarConfig instead of an intersection. - CalendarComponent.tgCalendar is an optional field instead of `Calendar | null`; it was only ever truth-tested. - dayFilter/timeFilter are typed ViewConfig["dayFilter"/"timeFilter"], the same function types the view config takes. - date-picker-utils names `SyntaxNode | null` as SyntaxNode["parent"]. --- src/components/features/calendar/index.ts | 15 ++++++++------- .../features/calendar/views/tg-agenda-view.ts | 12 ++++++------ .../features/calendar/views/tg-year-view.ts | 10 ++++++---- .../settings/tabs/McpIntegrationSettingsTab.ts | 6 +++--- .../ui/date-picker/DatePickerComponent.ts | 8 ++++++-- .../ui/modals/CalendarViewConfigModal.ts | 2 +- .../date-time/date-picker-utils.ts | 6 ++++-- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/components/features/calendar/index.ts b/src/components/features/calendar/index.ts index 3af3a019..6dd0feeb 100644 --- a/src/components/features/calendar/index.ts +++ b/src/components/features/calendar/index.ts @@ -36,6 +36,7 @@ import type { ExtendedCalendarConfig, EventRenderContext, DateCellContext, + ViewConfig, } from "@taskgenius/calendar"; import * as dateFns from "date-fns"; import { addDays, startOfDay, differenceInDays, isBefore } from "date-fns"; @@ -74,9 +75,9 @@ type AgendaCalendarConfig = CustomCalendarViewConfig["calendarConfig"] & Pick; // Calendar config with the top-level maxEventsPerRow key set for month-based custom views -type CustomViewCalendarConfig = ExtendedCalendarConfig & { +interface CustomViewCalendarConfig extends ExtendedCalendarConfig { maxEventsPerRow?: number; -}; +} // Metadata patch passed to WriteAPI.updateTask, which merges it into the task's metadata type TaskMetadataUpdates = { metadata: Partial }; @@ -109,7 +110,7 @@ export class CalendarComponent extends Component { private plugin: TaskProgressBarPlugin; // @taskgenius/calendar instance (for all views including agenda/year) - private tgCalendar: Calendar | null = null; + private tgCalendar?: Calendar; // View registry for custom views (agenda, year, and user-defined) private viewRegistry: ViewRegistry = new ViewRegistry(); @@ -248,7 +249,7 @@ export class CalendarComponent extends Component { // Clean up @taskgenius/calendar if (this.tgCalendar) { this.tgCalendar.destroy(); - this.tgCalendar = null; + this.tgCalendar = undefined; } this.containerEl.empty(); @@ -597,7 +598,7 @@ export class CalendarComponent extends Component { // Clean up previous views if (this.tgCalendar) { this.tgCalendar.destroy(); - this.tgCalendar = null; + this.tgCalendar = undefined; } // Update view class @@ -731,7 +732,7 @@ export class CalendarComponent extends Component { // Build dayFilter based on config // The filter functions return DayFilterResult which is accepted by the view config - let dayFilter: ReturnType | undefined; + let dayFilter: ViewConfig["dayFilter"]; if (cc.dayFilter) { switch (cc.dayFilter.type) { case "hideWeekends": @@ -754,7 +755,7 @@ export class CalendarComponent extends Component { // Build timeFilter based on config (only for week/day views) // The filter functions return TimeFilterResult which is accepted by the view config - let timeFilter: ReturnType | undefined; + let timeFilter: ViewConfig["timeFilter"]; if ( cc.timeFilter?.enabled && (customConfig.baseViewType === "week" || diff --git a/src/components/features/calendar/views/tg-agenda-view.ts b/src/components/features/calendar/views/tg-agenda-view.ts index 84de2a53..d2cbe456 100644 --- a/src/components/features/calendar/views/tg-agenda-view.ts +++ b/src/components/features/calendar/views/tg-agenda-view.ts @@ -128,9 +128,7 @@ export class TGAgendaView extends BaseView { const currentDate = this.context.adapter.create( this.context.currentDate, ); - const rangeStart = moment(currentDate as unknown as Date).startOf( - "day", - ); + const rangeStart = moment(currentDate).startOf("day"); const rangeEnd = rangeStart .clone() .add(this.daysToShow - 1, "days") @@ -160,14 +158,16 @@ export class TGAgendaView extends BaseView { * Convert TGCalendarEvent to CalendarEvent */ protected convertEvents(events: TGCalendarEvent[]): CalendarEvent[] { - return events.map((e) => ({ + // The TG events are built from tasks, so the results carry every task field + const converted: unknown = events.map((e) => ({ ...e, start: new Date(e.start), end: e.end ? new Date(e.end) : undefined, // Preserve original allDay value; default to true if not specified (most tasks are date-only) allDay: (e as unknown as CalendarEvent).allDay ?? true, metadata: e.metadata as CalendarEvent["metadata"], - })) as unknown as CalendarEvent[]; + })); + return converted as CalendarEvent[]; } /** @@ -350,7 +350,7 @@ export class TGAgendaView extends BaseView { const currentDate = this.context.adapter.create( this.context.currentDate, ); - const start = moment(currentDate as unknown as Date); + const start = moment(currentDate); const end = start.clone().add(this.daysToShow - 1, "days"); if (start.isSame(end, "month")) { diff --git a/src/components/features/calendar/views/tg-year-view.ts b/src/components/features/calendar/views/tg-year-view.ts index 12280402..8be17292 100644 --- a/src/components/features/calendar/views/tg-year-view.ts +++ b/src/components/features/calendar/views/tg-year-view.ts @@ -121,7 +121,7 @@ export class TGYearView extends BaseView { const currentDate = this.context.adapter.create( this.context.currentDate, ); - const year = moment(currentDate as unknown as Date).year(); + const year = moment(currentDate).year(); container.empty(); container.addClass("view-year", "tg-year-view"); @@ -168,14 +168,16 @@ export class TGYearView extends BaseView { * Convert TGCalendarEvent to CalendarEvent */ protected convertEvents(events: TGCalendarEvent[]): CalendarEvent[] { - return events.map((e) => ({ + // The TG events are built from tasks, so the results carry every task field + const converted: unknown = events.map((e) => ({ ...e, start: new Date(e.start), end: e.end ? new Date(e.end) : undefined, // Preserve original allDay value; default to true if not specified (most tasks are date-only) allDay: (e as unknown as CalendarEvent).allDay ?? true, metadata: e.metadata as CalendarEvent["metadata"], - })) as unknown as CalendarEvent[]; + })); + return converted as CalendarEvent[]; } /** @@ -550,7 +552,7 @@ export class TGYearView extends BaseView { const currentDate = this.context.adapter.create( this.context.currentDate, ); - return moment(currentDate as unknown as Date).format("YYYY"); + return moment(currentDate).format("YYYY"); } /** diff --git a/src/components/features/settings/tabs/McpIntegrationSettingsTab.ts b/src/components/features/settings/tabs/McpIntegrationSettingsTab.ts index 483ae67c..d3359361 100644 --- a/src/components/features/settings/tabs/McpIntegrationSettingsTab.ts +++ b/src/components/features/settings/tabs/McpIntegrationSettingsTab.ts @@ -1028,7 +1028,7 @@ export function renderMcpIntegrationSettingsTab( const toolsGrid = toolsSection.createDiv("mcp-tools-grid"); const toolsInfo = toolsSection.createDiv("mcp-tools-info"); - toolsInfo.setText(t("Loading tools...") as string); + toolsInfo.setText(t("Loading tools...")); async function renderDynamicTools() { try { @@ -1081,7 +1081,7 @@ export function renderMcpIntegrationSettingsTab( toolsInfo.setText(""); if (!tools.length) { - toolsInfo.setText(t("No tools available") as string); + toolsInfo.setText(t("No tools available")); return; } @@ -1100,7 +1100,7 @@ export function renderMcpIntegrationSettingsTab( } catch (e) { console.error("[MCP Tools] Failed to load tools:", e); toolsInfo.setText( - t("Failed to load tools. Is the MCP server running?") as string + t("Failed to load tools. Is the MCP server running?"), ); } } diff --git a/src/components/ui/date-picker/DatePickerComponent.ts b/src/components/ui/date-picker/DatePickerComponent.ts index 6d5aac44..4ffd99d2 100644 --- a/src/components/ui/date-picker/DatePickerComponent.ts +++ b/src/components/ui/date-picker/DatePickerComponent.ts @@ -91,7 +91,11 @@ export class DatePickerComponent extends Component { }); // Add quick date options - const quickOptions = [ + const quickOptions: { + amount: number; + unit: moment.unitOfTime.DurationConstructor; + label: string; + }[] = [ { amount: 0, unit: "days", label: t("Today") }, { amount: 1, unit: "days", label: t("Tomorrow") }, { amount: 2, unit: "days", label: t("In 2 days") }, @@ -119,7 +123,7 @@ export class DatePickerComponent extends Component { const date = moment().add( option.amount, - option.unit as moment.unitOfTime.DurationConstructor + option.unit ); const formattedDate = date.format("YYYY-MM-DD"); diff --git a/src/components/ui/modals/CalendarViewConfigModal.ts b/src/components/ui/modals/CalendarViewConfigModal.ts index 752dd4f5..124e7fbd 100644 --- a/src/components/ui/modals/CalendarViewConfigModal.ts +++ b/src/components/ui/modals/CalendarViewConfigModal.ts @@ -489,7 +489,7 @@ export class CalendarViewConfigModal extends Modal { if (!timeFilter) return; const formatHour = (h: number) => `${h.toString().padStart(2, "0")}:00`; - (el as HTMLElement).textContent = + el.textContent = `${formatHour(timeFilter.startHour)} - ${formatHour(timeFilter.endHour)}`; } diff --git a/src/editor-extensions/date-time/date-picker-utils.ts b/src/editor-extensions/date-time/date-picker-utils.ts index 2d29913f..cd59e258 100644 --- a/src/editor-extensions/date-time/date-picker-utils.ts +++ b/src/editor-extensions/date-time/date-picker-utils.ts @@ -8,6 +8,8 @@ import { EditorState, Text, Line } from "@codemirror/state"; import { syntaxTree } from "@codemirror/language"; type SyntaxNode = ReturnType["resolveInner"]>; +/** A syntax node or none, as returned by `SyntaxNode.parent` */ +type SyntaxNodeOrNull = SyntaxNode["parent"]; /** * Whitelist of date emoji markers to prevent false positives @@ -65,7 +67,7 @@ export function isInsideTaskLine(state: EditorState, pos: number): boolean { // Use syntax tree for more precise detection const tree = syntaxTree(state); - let node: SyntaxNode | null = tree.resolveInner(pos, -1); + let node: SyntaxNodeOrNull = tree.resolveInner(pos, -1); // Traverse up to find list-item node while (node) { @@ -323,7 +325,7 @@ export function shouldSkipRendering( const node = tree.resolveInner(from, 1); // Check node and parent nodes for special contexts - let current: SyntaxNode | null = node; + let current: SyntaxNodeOrNull = node; while (current) { const nodeName = current.name.toLowerCase(); const nodeType = current.type.name.toLowerCase(); From fde2830d3b1c7c51ca900421fbd4ac5612af842b Mon Sep 17 00:00:00 2001 From: Quorafind Date: Sun, 29 Nov 2026 11:20:34 +0800 Subject: [PATCH 5/5] refactor(lint): narrow TFile with instanceof, use createEl, drop unused `_` Scanner rules (obsidianmd 0.4.1): no-tfile-tfolder-cast 1 -> 0, prefer-create-el 1 -> 0, @typescript-eslint/no-unused-vars 9 -> 0. - DuplicateActionExecutor narrows the getFileByPath() result with instanceof TFile instead of casting it first; it creates the target file in the same cases as before. - The tray icon canvas is made with createEl("canvas"). - Unused `_` bindings: `catch {}` without a binding (FluentIntegration, FluentLayoutManager, TimelineSidebarView, closed/completed status predicates) and array holes `[symbol, , type]` / `[, mark]` in destructuring (TaskStatusSettingsTab, status-cycler), as elsewhere in the code base. --- src/components/features/fluent/FluentIntegration.ts | 2 +- .../features/fluent/managers/FluentLayoutManager.ts | 2 +- .../features/settings/tabs/TaskStatusSettingsTab.ts | 4 ++-- .../features/timeline-sidebar/TimelineSidebarView.ts | 2 +- src/editor-extensions/task-operations/status-cycler.ts | 2 +- src/executors/completion/duplicate-executor.ts | 8 +++++--- src/managers/desktop-integration-manager.ts | 2 +- src/modules/view-tasks/closedStatusPredicate.ts | 4 ++-- src/modules/view-tasks/completedStatusPredicate.ts | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/features/fluent/FluentIntegration.ts b/src/components/features/fluent/FluentIntegration.ts index 507e6bd2..8c13fc99 100644 --- a/src/components/features/fluent/FluentIntegration.ts +++ b/src/components/features/fluent/FluentIntegration.ts @@ -93,7 +93,7 @@ export class FluentIntegration { ws.rightSplit.expand(); // Restore focus to the currently active (incoming) leaf if (leaf) ws.setActiveLeaf(leaf, { focus: true }); - } catch (_) { + } catch { // noop } finally { this.revealingSideLeaves = false; diff --git a/src/components/features/fluent/managers/FluentLayoutManager.ts b/src/components/features/fluent/managers/FluentLayoutManager.ts index a8ae9eed..44fb3bca 100644 --- a/src/components/features/fluent/managers/FluentLayoutManager.ts +++ b/src/components/features/fluent/managers/FluentLayoutManager.ts @@ -474,7 +474,7 @@ export class FluentLayoutManager extends Component { this.sidebar?.setCollapsed(true); this.rootContainerEl?.addClass("fluent-sidebar-collapsed"); } - } catch (_) { + } catch { // Ignore errors } } diff --git a/src/components/features/settings/tabs/TaskStatusSettingsTab.ts b/src/components/features/settings/tabs/TaskStatusSettingsTab.ts index cd34e7c8..45242542 100644 --- a/src/components/features/settings/tabs/TaskStatusSettingsTab.ts +++ b/src/components/features/settings/tabs/TaskStatusSettingsTab.ts @@ -239,7 +239,7 @@ export function renderTaskStatusSettingsTab( notStarted: [], planned: [], }; - for (const [symbol, _, type] of statuses) { + for (const [symbol, , type] of statuses) { if (type in statusMap) { statusMap[type].push(symbol); } @@ -838,7 +838,7 @@ export function renderTaskStatusSettingsTab( notStarted: [], planned: [], }; - for (const [symbol, _, type] of statuses) { + for (const [symbol, , type] of statuses) { if (type in statusMap) { statusMap[type].push(symbol); } diff --git a/src/components/features/timeline-sidebar/TimelineSidebarView.ts b/src/components/features/timeline-sidebar/TimelineSidebarView.ts index 08e50499..d456efbb 100644 --- a/src/components/features/timeline-sidebar/TimelineSidebarView.ts +++ b/src/components/features/timeline-sidebar/TimelineSidebarView.ts @@ -695,7 +695,7 @@ export class TimelineSidebarView extends ItemView { : `${minutes}m`; timeEl.setAttribute("data-duration", duration); } - } catch (_) { + } catch { // The duration badge is optional; skip it if the times can't be compared } } else { diff --git a/src/editor-extensions/task-operations/status-cycler.ts b/src/editor-extensions/task-operations/status-cycler.ts index 9cfbb51e..7ef76fee 100644 --- a/src/editor-extensions/task-operations/status-cycler.ts +++ b/src/editor-extensions/task-operations/status-cycler.ts @@ -775,7 +775,7 @@ export function handleCycleCompleteStatusTransaction( // If so, we may choose to leave it as is rather than immediately cycling it if (wasCompleteTask) { // Find the corresponding status for this mark - for (const [_, mark] of Object.entries(marks)) { + for (const [, mark] of Object.entries(marks)) { if (mark === currentMark) { break; } diff --git a/src/executors/completion/duplicate-executor.ts b/src/executors/completion/duplicate-executor.ts index 4e64507b..7bb5aefa 100644 --- a/src/executors/completion/duplicate-executor.ts +++ b/src/executors/completion/duplicate-executor.ts @@ -86,10 +86,12 @@ export class DuplicateActionExecutor extends BaseActionExecutor { // Determine target file (default to same file if not specified) let targetFile: TFile; if (duplicateConfig.targetFile) { - targetFile = app.vault.getFileByPath( + const existingTarget = app.vault.getFileByPath( duplicateConfig.targetFile, - ) as TFile; - if (!(targetFile instanceof TFile)) { + ); + if (existingTarget instanceof TFile) { + targetFile = existingTarget; + } else { // Try to create the target file if it doesn't exist try { targetFile = await app.vault.create( diff --git a/src/managers/desktop-integration-manager.ts b/src/managers/desktop-integration-manager.ts index 456ce769..2769fe1c 100644 --- a/src/managers/desktop-integration-manager.ts +++ b/src/managers/desktop-integration-manager.ts @@ -443,7 +443,7 @@ export class DesktopIntegrationManager extends Component { ): Promise { try { const size = Platform.isMacOS ? 14 : 24; - const canvas = document.createElement("canvas"); + const canvas = createEl("canvas"); canvas.width = size; canvas.height = size; const ctx = canvas.getContext("2d"); diff --git a/src/modules/view-tasks/closedStatusPredicate.ts b/src/modules/view-tasks/closedStatusPredicate.ts index 49c25d06..221bd819 100644 --- a/src/modules/view-tasks/closedStatusPredicate.ts +++ b/src/modules/view-tasks/closedStatusPredicate.ts @@ -32,7 +32,7 @@ export function isAbandonedStatusMark( } } } - } catch (_) { + } catch { // Malformed status settings; treat the status as not abandoned } @@ -70,7 +70,7 @@ export function isClosedStatusMark( } } } - } catch (_) { + } catch { // Malformed status settings; treat the status as not closed } diff --git a/src/modules/view-tasks/completedStatusPredicate.ts b/src/modules/view-tasks/completedStatusPredicate.ts index 2b99126a..26c44911 100644 --- a/src/modules/view-tasks/completedStatusPredicate.ts +++ b/src/modules/view-tasks/completedStatusPredicate.ts @@ -38,7 +38,7 @@ export function isCompletedStatusMark( } } } - } catch (_) { + } catch { // Malformed status settings; treat the status as not completed }