Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
private overridePaste: boolean = false;
private hasCustomCommands: boolean = false;
private customCommandsLock = new AsyncLock();
private originalSaveCallback?: () => void = null;
private originalSaveCallback?: (checking: boolean) => boolean | void = null;
// The amount of files you can use editor lint on at once is pretty small, so we will use an array
private editorLintFiles: TFile[] = [];
// the amount of files that can be linted as a file can be quite large, so we will want to use a set to make
Expand Down Expand Up @@ -322,15 +322,19 @@
this.originalSaveCallback = saveCommandDefinition?.checkCallback;

if (typeof this.originalSaveCallback === 'function') {
saveCommandDefinition.checkCallback = () => {
this.originalSaveCallback();

if (this.settings.lintOnSave && this.isEnabled) {
const editor = this.getEditor();
if (editor) {
const file = this.app.workspace.getActiveFile();
if (!this.shouldIgnoreFile(file) && this.isMarkdownFile(file) && editor.cm) {
void this.runLinterEditor(editor);
saveCommandDefinition.checkCallback = (checking: boolean) => {

Check failure on line 325 in src/main.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Block must not be padded by blank lines

if (checking) {
return this.originalSaveCallback(checking);
} else {
this.originalSaveCallback(checking)

Check failure on line 330 in src/main.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
if (this.settings.lintOnSave && this.isEnabled) {
const editor = this.getEditor();
if (editor) {
const file = this.app.workspace.getActiveFile();
if (!this.shouldIgnoreFile(file) && this.isMarkdownFile(file) && editor.cm) {
void this.runLinterEditor(editor);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/typings/obsidian-ex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface ObsidianCommandInterface {
executeCommandById(id: string): void;
commands: {
'editor:save-file': {
checkCallback(): void;
checkCallback(checking: boolean): boolean | void;
};
};
listCommands(): Command[];
Expand Down
Loading