diff --git a/eslint.config.mjs b/eslint.config.mjs index d38bd18..e0e087d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -62,6 +62,14 @@ export default tseslint.config( }, }, + // D-08 — Ambient .d.ts shims are excluded from no-explicit-any. Hand-typing + // untyped third-party libraries (ical.js) is out of scope; the cheapest + // correct close per CONTEXT.md D-08. + { + files: ["**/*.d.ts"], + rules: { "@typescript-eslint/no-explicit-any": "off" }, + }, + // --------------------------------------------------------------------------- // Phase 8 — DIR-01 / DIR-09 / DIR-10 will remove these when type-hygiene // and console-discipline land. diff --git a/src/services/CalendarService.ts b/src/services/CalendarService.ts index 335161a..cc4a414 100644 --- a/src/services/CalendarService.ts +++ b/src/services/CalendarService.ts @@ -1,5 +1,5 @@ import { requestUrl, Platform, Notice, TFile } from "obsidian"; -import { Component, Event as ICalEvent, parse, Time } from "ical.js"; +import { Component, Duration, Event as ICalEvent, parse, Time } from "ical.js"; import { CalendarSource } from "../settings/types"; import MemoChron from "../main"; import { @@ -314,9 +314,12 @@ export class CalendarService { return JSON.parse(cacheFile); } - private isValidCache(cache: any): cache is CacheData { + private isValidCache(cache: unknown): cache is CacheData { + if (!cache || typeof cache !== "object") return false; + const c = cache as Record; return ( - cache && cache.timestamp && cache.events && Array.isArray(cache.events) + typeof c.timestamp === "number" && + Array.isArray(c.events) ); } @@ -768,8 +771,8 @@ export class CalendarService { const exdateProps = vevent.getAllProperties("exdate"); for (const exdateProp of exdateProps) { const values = exdateProp.getValues(); - values.forEach((value: any) => { - if (value?.toJSDate) { + values.forEach((value: Time | Duration | string) => { + if (value instanceof Time) { excludedDates.push(value.toJSDate()); } }); @@ -937,7 +940,7 @@ export class CalendarService { // Also check if the type is 'date' in the jCal representation // This handles cases where ical.js represents date-only values differently - const jcal = (dtstart as any).jCal; + const jcal = dtstart.jCal; if (jcal && jcal[2] === "date") return true; return false; diff --git a/src/services/IcsImportService.ts b/src/services/IcsImportService.ts index a982da2..4605ae6 100644 --- a/src/services/IcsImportService.ts +++ b/src/services/IcsImportService.ts @@ -97,7 +97,7 @@ export class IcsImportService { // Also check if the type is 'date' in the jCal representation // This handles cases where ical.js represents date-only values differently - const jcal = (dtstart as any).jCal; + const jcal = dtstart.jCal; if (jcal && jcal[2] === "date") return true; return false; diff --git a/src/settings/SettingsTab.ts b/src/settings/SettingsTab.ts index 1cb6540..21ff063 100644 --- a/src/settings/SettingsTab.ts +++ b/src/settings/SettingsTab.ts @@ -12,6 +12,7 @@ import { } from "obsidian"; import MemoChron from "../main"; import { CalendarSource } from "./types"; +import { CalendarEvent } from "../services/CalendarService"; import { isValidColor } from "../utils/colorValidation"; import { errorMessage } from "../utils/errors"; @@ -1177,7 +1178,10 @@ export class SettingsTab extends PluginSettingTab { } } - private generatePreviewPath(template: string, event: any): string { + private generatePreviewPath( + template: string, + event: Pick + ): string { const monthNames = [ "January", "February", diff --git a/src/types/ical.d.ts b/src/types/ical.d.ts index 3c62124..b0401f3 100644 --- a/src/types/ical.d.ts +++ b/src/types/ical.d.ts @@ -11,7 +11,8 @@ declare module "ical.js" { export class Property { getFirstValue(): any; getParameter(name: string): string; - getValues(): any[]; + getValues(): Array