Update ESLint rules and resolve bot review feedback #8
No files matched your search
@@ -38,7 +38,7 @@ export class CommandRegistry {
|
||||
// Check dependencies command
|
||||
this.plugin.addCommand({
|
||||
id: 'check-dependencies',
|
||||
name: 'Check Pandoc and Typst dependencies',
|
||||
name: 'Check pandoc and typst dependencies',
|
||||
callback: () => {
|
||||
this.plugin.showDependencyStatus().catch(error => {
|
||||
console.error('Failed to show dependency status:', error);
|
||||
|
||||
@@ -88,7 +88,7 @@ export class EmbedProcessor {
|
||||
* Returns the local path if successful, null if failed
|
||||
*/
|
||||
private async downloadRemoteImage(imageUrl: string, tempDir: string): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
// Parse URL to get filename
|
||||
const urlObj = new URL(imageUrl);
|
||||
@@ -124,7 +124,7 @@ export class EmbedProcessor {
|
||||
const absoluteRedirectUrl = new URL(redirectUrl, imageUrl).href;
|
||||
console.debug(`Export:Following redirect to: ${absoluteRedirectUrl}`);
|
||||
// Recursively follow redirect with resolved absolute URL
|
||||
this.downloadRemoteImage(absoluteRedirectUrl, tempDir).then(resolve);
|
||||
this.downloadRemoteImage(absoluteRedirectUrl, tempDir).then(resolve).catch(reject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,8 @@ export class EmbedProcessor {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
response.on('end', async () => {
|
||||
response.on('end', () => {
|
||||
void (async () => {
|
||||
try {
|
||||
// Check if file already exists to avoid overwriting
|
||||
const exists = await this.pathUtils.fileExists(outputPath);
|
||||
@@ -165,7 +166,8 @@ export class EmbedProcessor {
|
||||
console.error(`Export: Error writing image file: ${err.message}`);
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
||||
response.on('error', (err) => {
|
||||
console.error(`Export: Error receiving image data: ${err.message}`);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class EventHandlers {
|
||||
if (file.extension === 'md') {
|
||||
menu.addItem((item) => {
|
||||
item
|
||||
.setTitle('Export to PDF (Typst)')
|
||||
.setTitle('Export to PDF')
|
||||
.setIcon('file-output')
|
||||
.onClick(() => {
|
||||
this.plugin.exportFile(file).catch(error => {
|
||||
@@ -37,7 +37,7 @@ export class EventHandlers {
|
||||
this.plugin.app.workspace.on('editor-menu', (menu: Menu, editor: Editor, view: MarkdownView) => {
|
||||
menu.addItem((item) => {
|
||||
item
|
||||
.setTitle('Export to PDF (Typst)')
|
||||
.setTitle('Export to PDF')
|
||||
.setIcon('file-output')
|
||||
.onClick(() => {
|
||||
this.plugin.exportCurrentNote(view).catch(error => {
|
||||
@@ -57,7 +57,7 @@ export class EventHandlers {
|
||||
if (markdownFiles.length > 0) {
|
||||
menu.addItem((item) => {
|
||||
item
|
||||
.setTitle(`Export to PDF (Typst)`)
|
||||
.setTitle(`Export to PDF`)
|
||||
.setIcon('file-output')
|
||||
.onClick(() => {
|
||||
this.plugin.exportFiles(markdownFiles).catch(error => {
|
||||
|
||||
@@ -162,9 +162,9 @@ export class ExportOrchestrator {
|
||||
cls: 'mod-warning'
|
||||
});
|
||||
cancelButton.addEventListener('click', () => this.cancelExport());
|
||||
progressNotice.setMessage('Preprocessing markdown content...');
|
||||
progressNotice.setMessage('Preprocessing Markdown content...');
|
||||
|
||||
// Preprocess markdown
|
||||
// Preprocess Markdown
|
||||
const preprocessor = new MarkdownPreprocessor({
|
||||
vaultPath: vaultPath,
|
||||
options: {
|
||||
@@ -322,7 +322,7 @@ export class ExportOrchestrator {
|
||||
const markdownFiles = folder.children.filter((file) => this.plugin.isMarkdownFile(file));
|
||||
|
||||
if (markdownFiles.length === 0) {
|
||||
new Notice('No markdown files found in this folder');
|
||||
new Notice('No Markdown files found in this folder');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+11
-15
@@ -28,10 +28,6 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Typst PDF Export Settings')
|
||||
.setHeading();
|
||||
|
||||
// Executable paths section
|
||||
this.createExecutablePathsSection(containerEl);
|
||||
|
||||
@@ -66,9 +62,9 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Pandoc path')
|
||||
.setDesc('Path to pandoc executable (leave empty to use system PATH)')
|
||||
.setDesc('Path to pandoc executable (leave empty to use system path)')
|
||||
.addText(text => text
|
||||
.setPlaceholder('pandoc')
|
||||
.setPlaceholder('Pandoc')
|
||||
.setValue(this.plugin.settings.pandocPath)
|
||||
.onChange(async (value) => {
|
||||
if (!SecurityUtils.validateExecutablePath(value)) {
|
||||
@@ -81,9 +77,9 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Typst path')
|
||||
.setDesc('Path to typst executable (leave empty to use system PATH)')
|
||||
.setDesc('Path to typst executable (leave empty to use system path)')
|
||||
.addText(text => text
|
||||
.setPlaceholder('typst')
|
||||
.setPlaceholder('Typst')
|
||||
.setValue(this.plugin.settings.typstPath)
|
||||
.onChange(async (value) => {
|
||||
if (!SecurityUtils.validateExecutablePath(value)) {
|
||||
@@ -95,10 +91,10 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('ImageMagick path')
|
||||
.setDesc('Path to ImageMagick executable (leave empty to use system PATH)')
|
||||
.setName('Imagemagick path')
|
||||
.setDesc('Path to imagemagick executable (leave empty to use system path)')
|
||||
.addText(text => text
|
||||
.setPlaceholder('magick')
|
||||
.setPlaceholder('Magick')
|
||||
.setValue(this.plugin.settings.executablePaths.imagemagickPath)
|
||||
.onChange(async (value) => {
|
||||
if (!SecurityUtils.validateExecutablePath(value)) {
|
||||
@@ -141,7 +137,7 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Default template')
|
||||
.setDesc('Default Typst template for exports')
|
||||
.setDesc('Default typst template for exports')
|
||||
.addDropdown(async (dropdown) => {
|
||||
try {
|
||||
const templates = await this.plugin.templateManager.getAvailableTemplates();
|
||||
@@ -163,7 +159,7 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
} catch (error) {
|
||||
console.error('Failed to load templates:', error);
|
||||
// Fallback to text input
|
||||
dropdown.addOption('default.typ', 'default.typ');
|
||||
dropdown.addOption('default.typ', 'Default.typ');
|
||||
dropdown.setValue(this.plugin.settings.exportDefaults.template);
|
||||
}
|
||||
});
|
||||
@@ -182,10 +178,10 @@ export class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Output folder')
|
||||
.setDesc('Default folder for exported PDFs (relative to vault root)')
|
||||
.setDesc('Folder for exported pdfs (relative to vault root)')
|
||||
.addText(text => {
|
||||
text
|
||||
.setPlaceholder('exports')
|
||||
.setPlaceholder('Exports')
|
||||
.setValue(this.plugin.settings.outputFolder)
|
||||
.onChange(async (value) => {
|
||||
const normalizedValue = normalizePath(value);
|
||||
|
||||
@@ -154,7 +154,7 @@ export class ModalRenderer {
|
||||
text: 'Export',
|
||||
|
|
||||
cls: 'mod-cta'
|
||||
});
|
||||
this.submitButton.addEventListener('click', () => this.callbacks.onSubmit());
|
||||
this.submitButton.addEventListener('click', () => void this.callbacks.onSubmit());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,10 +74,10 @@ export class GeneralSection implements ModalSection {
|
||||
|
||||
new Setting(this.container)
|
||||
|
⚠️ 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: 🤖 Prompt for AI Agents_⚠️ 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
|
||||
.setName('Output folder')
|
||||
.setDesc('Folder where PDFs will be saved (relative to vault root)')
|
||||
.setDesc('Location for exported PDF files (relative to vault root)')
|
||||
.addText(text => {
|
||||
const input = text
|
||||
.setPlaceholder('exports')
|
||||
.setPlaceholder('PDF exports')
|
||||
.setValue(state.settings.outputFolder || 'exports')
|
||||
.onChange(value => {
|
||||
const normalizedValue = normalizePath(value);
|
||||
|
||||
Reference in new issue
Block a user
⚠️ Potential issue | 🟠 Major
Handle potential promise rejection from async onSubmit.
The
voidoperator correctly discards the promise, but ifonSubmitis 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:
🤖 Prompt for AI Agents
✅ Addressed in commits
f0daebctoc1c02ee