From 48794ce097a8348ebaa3fdfe7fff27322e112179 Mon Sep 17 00:00:00 2001 From: Zero Liu Date: Wed, 13 May 2026 01:09:06 -0700 Subject: [PATCH] chore(eslint): enable obsidianmd/prefer-active-doc (#2411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flip the rule from "off" to "error" to catch accidental references to the global `document` (which always points at the main window even when the user is interacting with a popout). The only flagged site was a `document` field on the `RelevantNoteEntry` type — not a DOM reference, but the rule pattern-matches the identifier. Rename it to `note` so `entry.note.path/title` reads naturally next to `entry.metadata.*`, and remove the suppression. Co-authored-by: Claude Opus 4.7 (1M context) --- eslint.config.mjs | 2 +- .../chat-components/RelevantNotes.tsx | 38 +++++++++---------- src/search/findRelevantNotes.test.ts | 20 +++++----- src/search/findRelevantNotes.ts | 4 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index fb235290..1b7ad4e4 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -74,7 +74,7 @@ export default [ // obsidianmd: defer to follow-up PRs "obsidianmd/vault/iterate": "error", - "obsidianmd/prefer-active-doc": "off", + "obsidianmd/prefer-active-doc": "error", "obsidianmd/object-assign": "off", "obsidianmd/ui/sentence-case": "off", "obsidianmd/no-unsupported-api": "off", diff --git a/src/components/chat-components/RelevantNotes.tsx b/src/components/chat-components/RelevantNotes.tsx index 117f432a..43926fd1 100644 --- a/src/components/chat-components/RelevantNotes.tsx +++ b/src/components/chat-components/RelevantNotes.tsx @@ -112,7 +112,7 @@ function RelevantNote({ const loadContent = useCallback(async () => { if (fileContent) return; // Don't load if we already have content - const file = app.vault.getAbstractFileByPath(note.document.path); + const file = app.vault.getAbstractFileByPath(note.note.path); if (file instanceof TFile) { const content = await app.vault.cachedRead(file); @@ -128,7 +128,7 @@ function RelevantNote({ // Take first 1000 characters as preview setFileContent(cleanContent.slice(0, 1000) + (cleanContent.length > 1000 ? "..." : "")); } - }, [fileContent, note.document.path]); + }, [fileContent, note.note.path]); useEffect(() => { if (isOpen) { @@ -161,7 +161,7 @@ function RelevantNote({ { - const file = app.vault.getAbstractFileByPath(note.document.path); + const file = app.vault.getAbstractFileByPath(note.note.path); if (file instanceof TFile) { handleDragStart(e, file); } @@ -179,9 +179,9 @@ function RelevantNote({ } }} className="tw-block tw-w-full tw-truncate tw-text-sm tw-font-bold tw-text-normal" - title={`${note.document.title} - drag to insert wikilink`} + title={`${note.note.title} - drag to insert wikilink`} > - {note.document.title} + {note.note.title} @@ -198,7 +198,7 @@ function RelevantNote({
- {note.document.path} + {note.note.path}
{fileContent && (
@@ -243,11 +243,11 @@ function RelevantNotePopover({ children: React.ReactNode; }) { return ( - + {children} - {note.document.title} - {note.document.path} + {note.note.title} + {note.note.path}