diff --git a/main.ts b/main.ts index 082f690..bb3092f 100644 --- a/main.ts +++ b/main.ts @@ -756,7 +756,7 @@ class ParallelReaderPlugin extends Plugin { try { const pos = cm.posAtCoords({ x: rect.left + 20, y: topY }); if (pos != null) topLine = cm.state.doc.lineAt(pos).number - 1; - } catch (_: unknown) { + } catch { /* posAtCoords/lineAt can throw during editor state transitions — safe to ignore */ return; } @@ -801,7 +801,7 @@ class ParallelReaderPlugin extends Plugin { try { mdView.editor.setCursor({ line, ch: 0 }); mdView.editor.scrollIntoView({ from: { line, ch: 0 }, to: { line, ch: 0 } }, true); - } catch (_: unknown) { + } catch { /* setCursor/scrollIntoView can throw during view transitions — safe to ignore */ } } diff --git a/src/cache-manager.ts b/src/cache-manager.ts index a0aaf7e..7708289 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -53,7 +53,7 @@ export class CacheManager { try { if (typeof this.adapter.exists === 'function' && (await this.adapter.exists(dir))) return; await this.adapter.mkdir(dir); - } catch (_) { + } catch { /* ignore race */ } } diff --git a/src/cli.ts b/src/cli.ts index a41acff..766b0cc 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -44,7 +44,7 @@ export function resolveCliPath(name: string, override: string): string { const p = path.join(dir, name + ext); try { if (fs.existsSync(p)) return p; - } catch (_) { + } catch { // Ignore unreadable candidate paths and keep searching. } } diff --git a/src/schema.ts b/src/schema.ts index 1ec015a..320699a 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -48,7 +48,7 @@ export function extractJson(text: string): string { try { JSON.parse(raw); return raw; - } catch (_) { + } catch { /* continue */ } @@ -58,7 +58,7 @@ export function extractJson(text: string): string { try { JSON.parse(fenced); return fenced; - } catch (_) { + } catch { /* continue */ } } @@ -69,7 +69,7 @@ export function extractJson(text: string): string { try { JSON.parse(c); return c; - } catch (_) { + } catch { /* skip */ } } @@ -94,7 +94,7 @@ export function repairTruncatedCardsJson(text: string): string | null { try { JSON.parse(c); validCards.push(c); - } catch (_) { + } catch { /* skip malformed card */ } } @@ -107,7 +107,7 @@ export function parseCardsJson(text: string, settings?: PluginSettings | null): let parsed: unknown; try { parsed = JSON.parse(jsonText); - } catch (_e) { + } catch { // Attempt to salvage complete cards from truncated output const repaired = repairTruncatedCardsJson(text); if (repaired) { @@ -119,7 +119,7 @@ export function parseCardsJson(text: string, settings?: PluginSettings | null): 'complete cards. Consider increasing max tokens.', ); return normalizeCardsPayload(parsed, settings); - } catch (_) { + } catch { /* repair failed, fall through to error */ } } diff --git a/src/streaming.ts b/src/streaming.ts index 7c81bc1..b07db1e 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -150,18 +150,22 @@ export async function streamingRequestUrl( if (signal) { if (signal.aborted) throw new Error('Streaming request aborted'); - abortPromise = new Promise((_, reject) => { - abortListener = () => reject(new Error('Streaming request aborted')); - signal.addEventListener('abort', abortListener, { once: true }); - }); + abortPromise = (async () => { + await new Promise((resolve) => { + abortListener = resolve; + signal.addEventListener('abort', abortListener, { once: true }); + }); + throw new Error('Streaming request aborted'); + })(); } let timeoutId: number | null = null; - const timeoutPromise = new Promise((_, reject) => { - timeoutId = activeWindow.setTimeout(() => { - reject(new Error(`Streaming timed out after ${timeoutMs}ms`)); - }, timeoutMs); - }); + const timeoutPromise = (async () => { + await new Promise((resolve) => { + timeoutId = activeWindow.setTimeout(resolve, timeoutMs); + }); + throw new Error(`Streaming timed out after ${timeoutMs}ms`); + })(); try { const requestPromise = doStreamingRequestUrl( diff --git a/src/vault.ts b/src/vault.ts index 7953e09..2588a8f 100644 --- a/src/vault.ts +++ b/src/vault.ts @@ -14,7 +14,11 @@ export function folderPathsForTarget(folderPath: string): string[] { const normalized = normalizeVaultPath(folderPath); if (!normalized) return []; const parts = normalized.split('/'); - return parts.map((_, idx) => parts.slice(0, idx + 1).join('/')); + const folders: string[] = []; + for (let idx = 0; idx < parts.length; idx++) { + folders.push(parts.slice(0, idx + 1).join('/')); + } + return folders; } export async function ensureVaultFolder(app: App, folderPath: string) {