chore: run Obsidian Linter after automatic linker formatting

This commit is contained in:
Kodai Nakamura 2025-12-01 15:13:33 +09:00
parent 54a457b3d1
commit d3a02df3c1
3 changed files with 8 additions and 7 deletions

View file

@ -378,14 +378,15 @@ export default class AutomaticLinkerPlugin extends Plugin {
if (checking) {
return saveCallback?.(checking);
} else {
// Run Obsidian Linter before formatting if enabled
if (this.settings.runLinterBeforeFormatting) {
await this.formatOnSave();
// Run Obsidian Linter after formatting if enabled
if (this.settings.runLinterAfterFormatting) {
//@ts-expect-error
await this.app?.commands?.executeCommandById(
"obsidian-linter:lint-file",
);
}
await this.formatOnSave();
}
};
}

View file

@ -18,7 +18,7 @@ export type AutomaticLinkerSettings = {
excludeDirsFromAutoLinking: string[]; // Optional: List of directories to exclude from auto-linking
preventSelfLinking: boolean; // Prevent linking text to its own file
removeAliasInDirs: string[]; // Remove aliases for links in specified directories
runLinterBeforeFormatting: boolean; // Run Obsidian Linter before automatic linker formatting
runLinterAfterFormatting: boolean; // Run Obsidian Linter after automatic linker formatting
};
export const DEFAULT_SETTINGS: AutomaticLinkerSettings = {
@ -41,5 +41,5 @@ export const DEFAULT_SETTINGS: AutomaticLinkerSettings = {
excludeDirsFromAutoLinking: [], // Default: no excluded directories
preventSelfLinking: false, // Default: allow self-linking (backward compatibility)
removeAliasInDirs: [], // Default: no directories for alias removal
runLinterBeforeFormatting: false, // Default: do not run linter before formatting
runLinterAfterFormatting: false, // Default: do not run linter after formatting
};

View file

@ -37,9 +37,9 @@ export class AutomaticLinkerPluginSettingsTab extends PluginSettingTab {
)
.addToggle((toggle) => {
toggle
.setValue(this.plugin.settings.runLinterBeforeFormatting)
.setValue(this.plugin.settings.runLinterAfterFormatting)
.onChange(async (value) => {
this.plugin.settings.runLinterBeforeFormatting = value;
this.plugin.settings.runLinterAfterFormatting = value;
await this.plugin.saveData(this.plugin.settings);
});
});