Mark fire-and-forget promises with void (no-floating-promises)

This commit is contained in:
James Clifford Spratt 2026-06-27 19:28:22 +01:00
parent 3f0d320c51
commit 8d1c5a345a
14 changed files with 52 additions and 64 deletions

1
lintreport.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -214,7 +214,7 @@ export class RefreshManager {
if (view.previewMode && typeof view.previewMode.rerender === 'function') {
view.previewMode.rerender(true);
} else {
leaf.setViewState(leaf.getViewState());
void leaf.setViewState(leaf.getViewState());
}
});
}

View file

@ -91,7 +91,7 @@ export class MacrosCalcRenderer {
private saveMetricsConfig(): void {
this.plugin.settings.macroscalcMetricsConfigs = this.metricsConfigs;
this.plugin.saveSettings();
void this.plugin.saveSettings();
}
// Add this method to get display options from metrics config
@ -590,7 +590,7 @@ export class MacrosCalcRenderer {
this.setNeedsRefresh();
// Force re-render the entire component with fresh calculations
this.render(this.lastCalculatedTotals, this.lastBreakdownData);
void this.render(this.lastCalculatedTotals, this.lastBreakdownData);
}
private refreshDashboard(): void {
@ -979,7 +979,7 @@ export class MacrosCalcRenderer {
const loadingMessage = detailCell.createEl('p', { text: t('general.loading') });
(async () => {
void (async () => {
try {
const context = await this.plugin.dataManager.getDocumentContext(item.id);
const detailContent = detailCell.createDiv();
@ -1793,11 +1793,4 @@ export class MacrosCalcRenderer {
this.chartLoader.destroyChart(caloriesChartId);
}
} catch (e) {
this.plugin.logger.error('Error destroying chart:', e);
}
});
this.charts = [];
}
}
}
this.plugin.logger.er

View file

@ -30,7 +30,7 @@ export function registerMacrosCalcProcessor(plugin: MacrosPlugin): void {
// Add a global event listener for refresh events
plugin.registerEvent(
plugin.app.workspace.on('layout-change', () => {
forceRefreshAllRenderers(plugin);
void forceRefreshAllRenderers(plugin);
})
);

View file

@ -855,10 +855,10 @@ export class NutritionalSettingTab extends PluginSettingTab {
previewCanvas.id = this.chartId;
window.setTimeout(() => {
this.initChartPreview(previewCanvas);
void this.initChartPreview(previewCanvas);
}, 50);
this.initChartPreview(previewCanvas);
void this.initChartPreview(previewCanvas);
}
private renderFoodSourcesTab(containerEl: HTMLElement): void {
@ -1987,7 +1987,4 @@ export class NutritionalSettingTab extends PluginSettingTab {
this.previewChart.update();
}
} catch (error) {
console.error('Error creating preview chart:', error);
}
}
}
console.error('Error creating previ

View file

@ -299,9 +299,9 @@ export class LiveFoodSearchModal extends Modal {
this.currentSearchAbortController = null;
}
if (this.isBarcodeSearch) {
this.performBarcodeSearch(currentQuery);
void this.performBarcodeSearch(currentQuery);
} else if (!this.restoreResultsFromCache(currentQuery)) {
this.performSearch(currentQuery);
void this.performSearch(currentQuery);
}
}
@ -546,9 +546,9 @@ export class LiveFoodSearchModal extends Modal {
// Detect if this looks like a barcode (all numbers, 8-14 digits)
if (/^\d{8,14}$/.test(searchTerm)) {
this.isBarcodeSearch = true;
this.performBarcodeSearch(searchTerm);
void this.performBarcodeSearch(searchTerm);
} else {
this.performSearch(searchTerm);
void this.performSearch(searchTerm);
}
}
}, 300);
@ -569,7 +569,7 @@ export class LiveFoodSearchModal extends Modal {
this.scrollToSelectedResult();
} else if (event.key === 'Enter' && this.selectedIndex >= 0) {
event.preventDefault();
this.handleFoodSelection(this.results[this.selectedIndex]);
void this.handleFoodSelection(this.results[this.selectedIndex]);
}
};
@ -1144,7 +1144,7 @@ export class LiveFoodSearchModal extends Modal {
}
this.component.registerDomEvent(foodDiv, 'click', () => {
this.handleFoodSelection(food);
void this.handleFoodSelection(food);
});
this.component.registerDomEvent(foodDiv, 'mouseenter', () => {
@ -1485,7 +1485,7 @@ ${food.description}
// Create new scroll handler
// Fixed: Prefix unused parameter with underscore
this.scrollHandler = (_event: Event) => {
this.handleScroll();
void this.handleScroll();
};
// Add new scroll listener
@ -1872,3 +1872,4 @@ class FileNameModal extends Modal {
this.contentEl.empty();
}
}

View file

@ -292,7 +292,7 @@ export class AddMealTemplateModal extends Modal {
});
this.component.registerDomEvent(addButton, 'click', () => {
this.addFood(food);
void this.addFood(food);
});
}
});
@ -730,12 +730,12 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(editButton, 'click', () => {
this.editFoodServing(food);
void this.editFoodServing(food);
});
}
this.component.registerDomEvent(removeButton, 'click', () => {
this.removeFood(food);
void this.removeFood(food);
});
foodCard.addClass('selected');
@ -748,7 +748,7 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(addButton, 'click', () => {
this.addFood(food);
void this.addFood(food);
});
}
});
@ -870,7 +870,7 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(removeButton, 'click', () => {
this.removeFood(food);
void this.removeFood(food);
});
});
}

View file

@ -573,7 +573,7 @@ export class AddToMacrosModal extends Modal {
// When the modal closes, refresh the meals list
addMealModal.onClose = () => {
// Reload meal data and re-render
this.loadData().then(() => {
void this.loadData().then(() => {
this.filterAndRender(this.searchInput.value);
});
};
@ -664,7 +664,7 @@ export class AddToMacrosModal extends Modal {
});
this.component.registerDomEvent(addButton, 'click', () => {
this.addMeal(meal);
void this.addMeal(meal);
});
// Add selection state
@ -744,7 +744,7 @@ export class AddToMacrosModal extends Modal {
});
this.component.registerDomEvent(addButton, 'click', () => {
this.addFood(food);
void this.addFood(food);
});
// Check if already selected
@ -837,7 +837,7 @@ export class AddToMacrosModal extends Modal {
new Notice(t('meals.addTo.enterGroupNameFirst'));
return;
}
this.addFoodToGroup(food);
void this.addFoodToGroup(food);
});
// Check if already selected for group

View file

@ -179,7 +179,7 @@ export class ContextMenuManager {
.setTitle(t('comments.contextMenu.removeComment'))
.setIcon('trash-2')
.onClick(() => {
this.removeComment(target, onCommentUpdate);
void this.removeComment(target, onCommentUpdate);
})
);
} else {
@ -210,7 +210,7 @@ export class ContextMenuManager {
.setTitle(t('timestamps.contextMenu.removeTimestamp'))
.setIcon('trash-2')
.onClick(() => {
this.removeTimestamp(target, onCommentUpdate);
void this.removeTimestamp(target, onCommentUpdate);
})
);
} else {
@ -307,7 +307,7 @@ export class ContextMenuManager {
.setTitle(t('comments.contextMenu.removeComment'))
.setIcon('trash-2')
.onClick(() => {
this.removeComment(target, onCommentUpdate);
void this.removeComment(target, onCommentUpdate);
})
);
} else {
@ -338,7 +338,7 @@ export class ContextMenuManager {
.setTitle(t('timestamps.contextMenu.removeTimestamp'))
.setIcon('trash-2')
.onClick(() => {
this.removeTimestamp(target, onCommentUpdate);
void this.removeTimestamp(target, onCommentUpdate);
})
);
} else {
@ -369,7 +369,7 @@ export class ContextMenuManager {
.setTitle(t('tolerances.contextMenu.removeTolerance'))
.setIcon('trash-2')
.onClick(() => {
this.removeTolerance(target, onCommentUpdate);
void this.removeTolerance(target, onCommentUpdate);
})
);
} else {
@ -469,7 +469,7 @@ export class ContextMenuManager {
.setTitle(t('comments.contextMenu.removeComment'))
.setIcon('trash-2')
.onClick(() => {
this.removeComment(target, onCommentUpdate);
void this.removeComment(target, onCommentUpdate);
})
);
} else {
@ -500,7 +500,7 @@ export class ContextMenuManager {
.setTitle(t('timestamps.contextMenu.removeTimestamp'))
.setIcon('trash-2')
.onClick(() => {
this.removeTimestamp(target, onCommentUpdate);
void this.removeTimestamp(target, onCommentUpdate);
})
);
} else {
@ -531,7 +531,7 @@ export class ContextMenuManager {
.setTitle(t('tolerances.contextMenu.removeTolerance'))
.setIcon('trash-2')
.onClick(() => {
this.removeTolerance(target, onCommentUpdate);
void this.removeTolerance(target, onCommentUpdate);
})
);
} else {
@ -956,8 +956,4 @@ export class ContextMenuManager {
};
}
} catch (error) {
this.plugin.logger.error('Error creating comment target:', error);
return null;
}
}
}
this.plugin.logger.error('Error creating comment target:', error)

View file

@ -252,12 +252,12 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(editButton, 'click', () => {
this.editFoodServing(food);
void this.editFoodServing(food);
});
}
this.component.registerDomEvent(removeButton, 'click', () => {
this.removeFood(food);
void this.removeFood(food);
});
foodCard.addClass('selected');
@ -270,7 +270,7 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(addButton, 'click', () => {
this.addFood(food);
void this.addFood(food);
});
}
});
@ -392,7 +392,7 @@ export class EditMealTemplateModal extends Modal {
});
this.component.registerDomEvent(removeButton, 'click', () => {
this.removeFood(food);
void this.removeFood(food);
});
});
}

View file

@ -39,7 +39,7 @@ export class FoodResultsModal extends Modal {
}
onOpen() {
this.loadPage(0);
void this.loadPage(0);
// Add document-level event handling - register with component for cleanup
this.component.registerDomEvent(activeDocument, 'keydown', this.handleKeyNav);

View file

@ -457,9 +457,9 @@ export class ManualFoodEntryModal extends Modal {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
if (e.ctrlKey || e.metaKey) {
this.handleAddMore();
void this.handleAddMore();
} else {
this.handleSave();
void this.handleSave();
}
}
});
@ -555,11 +555,11 @@ export class ManualFoodEntryModal extends Modal {
});
this.component.registerDomEvent(addMoreBtn, 'click', () => {
this.handleAddMore();
void this.handleAddMore();
});
this.component.registerDomEvent(saveBtn, 'click', () => {
this.handleSave();
void this.handleSave();
});
// Handle Enter key submission
@ -567,9 +567,9 @@ export class ManualFoodEntryModal extends Modal {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
if (e.ctrlKey || e.metaKey) {
this.handleAddMore();
void this.handleAddMore();
} else {
this.handleSave();
void this.handleSave();
}
}
};

View file

@ -655,8 +655,8 @@ export class BarcodeScannerModal extends Modal {
cls: 'barcode-scanner-controls',
});
this.createControlsWithDiagnostics();
this.initializeScanner();
void this.createControlsWithDiagnostics();
void this.initializeScanner();
}
private async createControlsWithDiagnostics(): Promise<void> {

View file

@ -27,7 +27,7 @@ export class MacrosState {
this.plugin.settings.uiCollapseStates = {};
}
this.plugin.settings.uiCollapseStates[key] = isCollapsed;
this.plugin.saveSettings();
void this.plugin.saveSettings();
}
/** Load collapsed/expanded state from plugin settings */
@ -45,7 +45,7 @@ export class MacrosState {
delete states[key];
}
}
this.plugin.saveSettings();
void this.plugin.saveSettings();
}
/** Clear all states for the entire plugin */
@ -57,7 +57,7 @@ export class MacrosState {
delete states[key];
}
}
plugin.saveSettings();
void plugin.saveSettings();
}
/**