Update ESLint rules and resolve bot review feedback #8

Merged
AlexKucera merged 24 commits from obsidian-bot-review into master 2025-11-09 12:06:31 +01:00
Showing only changes of commit 1ac2807320 - Show all commits
+7 -1
View File
@@ -3,7 +3,7 @@
* Handles registration of all plugin commands and their callbacks
*/
import { Editor, MarkdownView } from 'obsidian';
import { Editor, MarkdownView, Notice } from 'obsidian';
import type { obsidianTypstPDFExport } from '../../main';
export class CommandRegistry {
@@ -20,6 +20,8 @@ export class CommandRegistry {
editorCallback: (editor: Editor, view: MarkdownView) => {
this.plugin.exportCurrentNote(view).catch(error => {
console.error('Failed to export current note:', error);
const errorMessage = error?.message ?? String(error);
new Notice(`Failed to export current note: ${errorMessage}`);
});
}
});
@@ -31,6 +33,8 @@ export class CommandRegistry {
editorCallback: (editor: Editor, view: MarkdownView) => {
this.plugin.showExportModal(view).catch(error => {
console.error('Failed to show export modal:', error);
coderabbitai[bot] commented 2025-11-05 13:54:26 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟠 Major

Error handling should notify users, not just log to console

When a user-initiated command fails, logging to console provides no feedback to the user. They won't know why the export didn't happen. Consider showing a Notice with the error message so users understand what went wrong.

Apply this pattern for user-facing error handling:

-				this.plugin.exportCurrentNote(view).catch(error => {
-					console.error('Failed to export current note:', error);
-				});
+				this.plugin.exportCurrentNote(view).catch(error => {
+					console.error('Failed to export current note:', error);
+					new Notice(`Export failed: ${error.message}`);
+				});

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/plugin/CommandRegistry.ts around lines 21 to 23, the catch currently only
logs the error to console which gives no user feedback; instead import and use
Obsidian's Notice to show a user-facing message (e.g., new Notice(`Failed to
export current note: ${error?.message ?? String(error)}`)) and optionally retain
console.error for debugging; ensure Notice is imported from 'obsidian' and that
the error is safely stringified so users see a readable explanation.

✅ Addressed in commits f0daebc to c1c02ee

_⚠️ Potential issue_ | _🟠 Major_ **Error handling should notify users, not just log to console** When a user-initiated command fails, logging to console provides no feedback to the user. They won't know why the export didn't happen. Consider showing a Notice with the error message so users understand what went wrong. Apply this pattern for user-facing error handling: ```diff - this.plugin.exportCurrentNote(view).catch(error => { - console.error('Failed to export current note:', error); - }); + this.plugin.exportCurrentNote(view).catch(error => { + console.error('Failed to export current note:', error); + new Notice(`Export failed: ${error.message}`); + }); ``` > Committable suggestion skipped: line range outside the PR's diff. <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/plugin/CommandRegistry.ts around lines 21 to 23, the catch currently only logs the error to console which gives no user feedback; instead import and use Obsidian's Notice to show a user-facing message (e.g., new Notice(`Failed to export current note: ${error?.message ?? String(error)}`)) and optionally retain console.error for debugging; ensure Notice is imported from 'obsidian' and that the error is safely stringified so users see a readable explanation. ``` </details> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits f0daebc to c1c02ee
const errorMessage = error?.message ?? String(error);
new Notice(`Failed to show export modal: ${errorMessage}`);
});
}
});
@@ -42,6 +46,8 @@ export class CommandRegistry {
callback: () => {
this.plugin.showDependencyStatus().catch(error => {
console.error('Failed to show dependency status:', error);
const errorMessage = error?.message ?? String(error);
new Notice(`Failed to show dependency status: ${errorMessage}`);
});
}
});