diff --git a/fixvoid.js b/fixvoid.js new file mode 100644 index 0000000..aab4e04 --- /dev/null +++ b/fixvoid.js @@ -0,0 +1,40 @@ +// One-off: prefix `void` to no-floating-promises in the 4 large files +// that couldn't be edited remotely. Reads locations from lintreport.json. +// Run from the repo root: node fixvoid.js +const fs = require('fs'); + +const targets = [ + 'MacrosCalcRenderer.ts', + 'StorageService.ts', + 'LiveSearchModal.ts', + 'ContextMenuManager.ts', +]; + +const report = JSON.parse(fs.readFileSync('lintreport.json', 'utf8')); +let n = 0; + +for (const file of report) { + if (!targets.some((t) => file.filePath.endsWith(t))) continue; + + const lineNos = new Set( + file.messages + .filter((m) => m.ruleId === '@typescript-eslint/no-floating-promises') + .map((m) => m.line) + ); + if (lineNos.size === 0) continue; + + const lines = fs.readFileSync(file.filePath, 'utf8').split('\n'); + for (const ln of lineNos) { + const i = ln - 1; + const s = lines[i]; + const stripped = s.replace(/^[ \t]*/, ''); + if (stripped.startsWith('void ')) continue; // idempotent + const lead = s.slice(0, s.length - stripped.length); + lines[i] = lead + 'void ' + stripped; + n++; + } + fs.writeFileSync(file.filePath, lines.join('\n')); + console.log('updated', file.filePath.split(/[\\/]/).pop()); +} + +console.log('prefixed', n, 'statements'); diff --git a/src/processors/macroscalc/MacrosCalcRenderer.ts b/src/processors/macroscalc/MacrosCalcRenderer.ts index 21a7c05..9465356 100644 --- a/src/processors/macroscalc/MacrosCalcRenderer.ts +++ b/src/processors/macroscalc/MacrosCalcRenderer.ts @@ -1793,4 +1793,11 @@ export class MacrosCalcRenderer { this.chartLoader.destroyChart(caloriesChartId); } } catch (e) { - this.plugin.logger.er \ No newline at end of file + this.plugin.logger.error('Error destroying chart:', e); + } + }); + + this.charts = []; + } + } +} diff --git a/src/settings/StorageService.ts b/src/settings/StorageService.ts index 00bd819..656b0f0 100644 --- a/src/settings/StorageService.ts +++ b/src/settings/StorageService.ts @@ -1987,4 +1987,7 @@ export class NutritionalSettingTab extends PluginSettingTab { this.previewChart.update(); } } catch (error) { - console.error('Error creating previ \ No newline at end of file + console.error('Error creating preview chart:', error); + } + } +} diff --git a/src/ui/live-search/LiveSearchModal.ts b/src/ui/live-search/LiveSearchModal.ts index a104e32..e31d192 100644 --- a/src/ui/live-search/LiveSearchModal.ts +++ b/src/ui/live-search/LiveSearchModal.ts @@ -1872,4 +1872,3 @@ class FileNameModal extends Modal { this.contentEl.empty(); } } - \ No newline at end of file diff --git a/src/ui/modals/ContextMenuManager.ts b/src/ui/modals/ContextMenuManager.ts index 31079a3..e1a1ac3 100644 --- a/src/ui/modals/ContextMenuManager.ts +++ b/src/ui/modals/ContextMenuManager.ts @@ -956,4 +956,8 @@ export class ContextMenuManager { }; } } catch (error) { - this.plugin.logger.error('Error creating comment target:', error) \ No newline at end of file + this.plugin.logger.error('Error creating comment target:', error); + return null; + } + } +}