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
2 changed files with 15 additions and 2 deletions
Showing only changes of commit 6c28b82a16 - Show all commits

No files matched your search

+14 -1
View File
@@ -154,7 +154,20 @@ export class ModalRenderer {
text: 'Export',
coderabbitai[bot] commented 2025-11-05 19:26:59 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟠 Major

Handle potential promise rejection from async onSubmit.

The void operator correctly discards the promise, but if onSubmit is async and throws an error, it will result in an unhandled promise rejection. This could lead to unexpected behavior or silent failures.

Apply this diff to add proper error handling:

-		this.submitButton.addEventListener('click', () => void this.callbacks.onSubmit());
+		this.submitButton.addEventListener('click', async () => {
+			try {
+				await this.callbacks.onSubmit();
+			} catch (error) {
+				console.error('Export failed:', error);
+				// Optionally show error to user via validation errors
+				this.showValidationErrors([`Export failed: ${error instanceof Error ? error.message : String(error)}`]);
+			}
+		});

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

🤖 Prompt for AI Agents
In src/ui/modal/ModalRenderer.ts around line 157, the click handler currently
calls this.callbacks.onSubmit() with the void operator which discards the
returned promise and can create unhandled promise rejections if onSubmit is
async; change the handler to capture the promise and attach error handling
(e.g., call Promise.resolve(this.callbacks.onSubmit()).catch(err => { /*
handle/log error and update UI state */ })) or wrap the invocation in an async
function with try/catch so any thrown/rejected error is caught and handled
appropriately (log the error and provide user-facing feedback or disable the
submit button as needed).

✅ Addressed in commits f0daebc to c1c02ee

_⚠️ Potential issue_ | _🟠 Major_ **Handle potential promise rejection from async onSubmit.** The `void` operator correctly discards the promise, but if `onSubmit` is async and throws an error, it will result in an unhandled promise rejection. This could lead to unexpected behavior or silent failures. Apply this diff to add proper error handling: ```diff - this.submitButton.addEventListener('click', () => void this.callbacks.onSubmit()); + this.submitButton.addEventListener('click', async () => { + try { + await this.callbacks.onSubmit(); + } catch (error) { + console.error('Export failed:', error); + // Optionally show error to user via validation errors + this.showValidationErrors([`Export failed: ${error instanceof Error ? error.message : String(error)}`]); + } + }); ``` > Committable suggestion skipped: line range outside the PR's diff. <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/ui/modal/ModalRenderer.ts around line 157, the click handler currently calls this.callbacks.onSubmit() with the void operator which discards the returned promise and can create unhandled promise rejections if onSubmit is async; change the handler to capture the promise and attach error handling (e.g., call Promise.resolve(this.callbacks.onSubmit()).catch(err => { /* handle/log error and update UI state */ })) or wrap the invocation in an async function with try/catch so any thrown/rejected error is caught and handled appropriately (log the error and provide user-facing feedback or disable the submit button as needed). ``` </details> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits f0daebc to c1c02ee
cls: 'mod-cta'
});
this.submitButton.addEventListener('click', () => void this.callbacks.onSubmit());
this.submitButton.addEventListener('click', () => {
this.setExportingState(true);
Promise.resolve(this.callbacks.onSubmit()).catch(err => {
// Log the error for debugging
console.error('Export submission failed:', err);
// Show user-facing error feedback
const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred during export';
this.showValidationErrors([errorMessage]);
// Re-enable buttons so user can try again or cancel
this.setExportingState(false);
});
});
}
/**
+1 -1
View File
@@ -75,7 +75,7 @@ export class GeneralSection implements ModalSection {
coderabbitai[bot] commented 2025-11-05 19:26:59 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟡 Minor

Description contradicts absolute path handling.

The description states "relative to vault root", but the code on lines 84-85 now accepts and preserves absolute paths. Either update the description to clarify that absolute paths are supported, or remove the absolute path handling to match the description.

If absolute paths are intended, consider updating the description:

-			.setDesc('Location for exported PDF files (relative to vault root)')
+			.setDesc('Location for exported PDF files (relative to vault root, or absolute path)')
🤖 Prompt for AI Agents
In src/ui/modal/sections/GeneralSection.ts around line 78, the UI description
currently reads "Location for exported PDF files (relative to vault root)" but
the code now accepts and preserves absolute paths; update the description to
accurately reflect that both relative paths (resolved against vault root) and
absolute paths are supported (e.g., "Location for exported PDF files (relative
to vault root or absolute path)") or, if absolute paths are not intended, remove
the absolute-path handling in the code so the behavior matches the original
"relative" wording; ensure text is concise and consistent with the actual path
handling logic.

✅ Addressed in commits f0daebc to c1c02ee

_⚠️ Potential issue_ | _🟡 Minor_ **Description contradicts absolute path handling.** The description states "relative to vault root", but the code on lines 84-85 now accepts and preserves absolute paths. Either update the description to clarify that absolute paths are supported, or remove the absolute path handling to match the description. If absolute paths are intended, consider updating the description: ```diff - .setDesc('Location for exported PDF files (relative to vault root)') + .setDesc('Location for exported PDF files (relative to vault root, or absolute path)') ``` <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/ui/modal/sections/GeneralSection.ts around line 78, the UI description currently reads "Location for exported PDF files (relative to vault root)" but the code now accepts and preserves absolute paths; update the description to accurately reflect that both relative paths (resolved against vault root) and absolute paths are supported (e.g., "Location for exported PDF files (relative to vault root or absolute path)") or, if absolute paths are not intended, remove the absolute-path handling in the code so the behavior matches the original "relative" wording; ensure text is concise and consistent with the actual path handling logic. ``` </details> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits f0daebc to c1c02ee
new Setting(this.container)
.setName('Output folder')
.setDesc('Location for exported PDF files (relative to vault root)')
.setDesc('Location for exported PDF files (relative to vault root or absolute path)')
.addText(text => {
const input = text
.setPlaceholder('PDF exports')
1