mirror of
https://github.com/kdnk/obsidian-automatic-linker.git
synced 2026-07-22 12:00:30 +00:00
chore: add option to run Obsidian Linter before formatting
This commit is contained in:
parent
72be0ca238
commit
39a2c418ed
3 changed files with 24 additions and 4 deletions
11
src/main.ts
11
src/main.ts
|
|
@ -378,10 +378,13 @@ export default class AutomaticLinkerPlugin extends Plugin {
|
|||
if (checking) {
|
||||
return saveCallback?.(checking);
|
||||
} else {
|
||||
//@ts-expect-error
|
||||
await this.app?.commands?.executeCommandById(
|
||||
"obsidian-linter:lint-file",
|
||||
);
|
||||
// Run Obsidian Linter before formatting if enabled
|
||||
if (this.settings.runLinterBeforeFormatting) {
|
||||
//@ts-expect-error
|
||||
await this.app?.commands?.executeCommandById(
|
||||
"obsidian-linter:lint-file",
|
||||
);
|
||||
}
|
||||
await this.formatOnSave();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,6 +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
|
||||
};
|
||||
|
||||
export const DEFAULT_SETTINGS: AutomaticLinkerSettings = {
|
||||
|
|
@ -40,4 +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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,21 @@ export class AutomaticLinkerPluginSettingsTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
|
||||
// Toggle for running linter before formatting
|
||||
new Setting(containerEl)
|
||||
.setName("Run Obsidian Linter before formatting")
|
||||
.setDesc(
|
||||
"When enabled, Obsidian Linter will be executed before Automatic Linker formatting. This requires the Obsidian Linter plugin to be installed.",
|
||||
)
|
||||
.addToggle((toggle) => {
|
||||
toggle
|
||||
.setValue(this.plugin.settings.runLinterBeforeFormatting)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.runLinterBeforeFormatting = value;
|
||||
await this.plugin.saveData(this.plugin.settings);
|
||||
});
|
||||
});
|
||||
|
||||
// Setting for base directories.
|
||||
new Setting(containerEl)
|
||||
.setName("Base directory")
|
||||
|
|
|
|||
Loading…
Reference in a new issue