aaronsb_obsidian-mcp-plugin/tests/setup.ts
Aaron Bockelie c65fcf5d28 fix(lint): use window timers + window.console; drop forbidden eslint-disables (closes #226)
Obsidian's source-code review forbids disabling obsidianmd/prefer-window-timers
and obsidianmd/no-global-this (and flags undescribed directive comments). The
0.11.32 review failed on five such disables.

- router.ts, obsidian-api.ts, session-manager.ts: global set/clearInterval and
  setTimeout → window.* equivalents.
- debug.ts: drop the globalThis console fallback → window.console.
- tests/setup.ts: alias window to globalThis in the node test env so the
  window.* timers/console resolve under Jest (Obsidian always provides window
  at runtime).
- session-manager cleanupInterval typed number (window.setInterval's return).

All five eslint-disable directives removed. Lint clean, build green, 336 tests pass.
2026-06-09 11:13:48 -05:00

16 lines
No EOL
614 B
TypeScript

// Jest setup file for Obsidian plugin testing
// Source code uses window.* timers and window.console (per obsidianmd's
// prefer-window-timers / no-global-this rules — Obsidian always provides
// window at runtime). The node test env has no window, so alias it to
// globalThis, which supplies setTimeout/setInterval/clearInterval/console.
if (typeof (globalThis as { window?: unknown }).window === 'undefined') {
(globalThis as { window?: unknown }).window = globalThis;
}
// Mock performance API if not available
if (!global.performance) {
global.performance = {
now: () => Date.now(),
} as any;
}