Skip to content

Commit f06a1a6

Browse files
committed
ESLint: Always require semicolons.
OutputChannelCode: Removed an unnecessary semicolon. CreateShellSelectionField: In addition to adding a semicolon, also made the nested function cleaner with newlines and indentation. I didn't create an issue or discussion for this.
1 parent badbdb3 commit f06a1a6

37 files changed

+77
-74
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@typescript-eslint/ban-ts-comment": "off",
2222
"no-prototype-builtins": "off",
2323
"@typescript-eslint/no-empty-function": "off",
24-
"@typescript-eslint/no-inferrable-types": "off"
24+
"@typescript-eslint/no-inferrable-types": "off",
25+
"semi": ["error", "always"]
2526
}
2627
}

src/Common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function normalizePath2(path: string) {
154154
const leading_slashes_array = leading_slashes_regexp.exec(path); // An array with only one item.
155155
if (null === leading_slashes_array) {
156156
// It should always match. This exception should never happen, but have it just in case.
157-
throw new Error("normalizePath2(): leading_slashes_regexp did not match.")
157+
throw new Error("normalizePath2(): leading_slashes_regexp did not match.");
158158
}
159159
let leading_slashes = leading_slashes_array[0];
160160

@@ -271,7 +271,7 @@ export function prepareEditorPosition(editor: Editor, caret_line: number, caret_
271271
return {
272272
line: caret_line,
273273
ch: caret_column,
274-
}
274+
};
275275
}
276276

277277
export function getSelectionFromTextarea(textarea_element: HTMLTextAreaElement, return_null_if_empty: true): string | null;

src/Hotkeys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ export function getHotkeysForShellCommand(plugin: SC_Plugin, shell_command_id: s
2929
// @ts-ignore
3030
const app_custom_hotkeys = plugin.app.hotkeyManager?.customKeys;
3131
if (!app_custom_hotkeys) {
32-
debugLog("getHotkeysForShellCommand() failed, will return an empty array.")
32+
debugLog("getHotkeysForShellCommand() failed, will return an empty array.");
3333
return [];
3434
}
3535

3636
// Get only our hotkeys.
3737
const hotkey_index = plugin.getPluginId() + ":" + plugin.generateObsidianCommandId(shell_command_id); // E.g. "obsidian-shellcommands:shell-command-0"
38-
debugLog("getHotkeysForShellCommand() succeeded.")
38+
debugLog("getHotkeysForShellCommand() succeeded.");
3939
return app_custom_hotkeys[hotkey_index] ?? []; // If no hotkey array is set for this command, return an empty array. Although I do believe that all commands do have an array anyway, but have this check just in case.
4040
}
4141

@@ -60,5 +60,5 @@ export function HotkeyToString(hotkey: Hotkey) {
6060
}
6161

6262
export function CmdOrCtrl(): "Cmd" | "Ctrl" {
63-
return Platform.isMacOS ? "Cmd" : "Ctrl"
63+
return Platform.isMacOS ? "Cmd" : "Ctrl";
6464
}

src/Migrations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export async function RunMigrations(plugin: SC_Plugin) {
4242
];
4343
if (should_save.includes(true)) {
4444
// Only save if there were changes to configuration.
45-
debugLog("Saving migrations...")
45+
debugLog("Saving migrations...");
4646
backupSettingsFile(plugin); // Make a backup copy of the old file BEFORE writing the new, migrated settings file.
4747
await plugin.saveSettings();
48-
debugLog("Migrations saved...")
48+
debugLog("Migrations saved...");
4949
}
5050
}
5151

src/Shell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const PlatformShells = {
3535
"PowerShell.exe": "PowerShell 5",
3636
"CMD.EXE": "cmd.exe",
3737
},
38-
}
38+
};
3939

4040
export function getUsersDefaultShell(): string {
4141
if (isWindows()) {

src/ShellCommandExecutor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ export class ShellCommandExecutor {
171171
this.executeShellCommand(shell_command_parsing_result, overriding_output_channel);
172172
} else {
173173
// Parsing has failed.
174-
debugLog("Parsing the rest of the variables failed.")
174+
debugLog("Parsing the rest of the variables failed.");
175175
parsing_process.displayErrorMessages();
176176
}
177177
} else {
178178
// Cancel execution
179-
debugLog("Shell command execution cancelled.")
179+
debugLog("Shell command execution cancelled.");
180180
}
181181
});
182182

@@ -200,7 +200,7 @@ export class ShellCommandExecutor {
200200
outputChannels = {
201201
'stdout': overriding_output_channel,
202202
'stderr': overriding_output_channel,
203-
}
203+
};
204204
}
205205

206206
// Check that the shell command is not empty

src/events/SC_AbstractFileMenuEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export abstract class SC_AbstractFileMenuEvent extends SC_MenuEvent {
3939
this.file = file as TFile;
4040
break;
4141
case "folder":
42-
this.folder = file as TFolder
42+
this.folder = file as TFolder;
4343
break;
4444
}
4545

src/events/SC_Event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export abstract class SC_Event {
8181
*/
8282
private subclass_instance: this;
8383
public getClass() {
84-
return this.subclass_instance.constructor as typeof SC_Event
84+
return this.subclass_instance.constructor as typeof SC_Event;
8585
}
8686

8787
public canRegisterAfterChangingSettings(): boolean {
@@ -176,7 +176,7 @@ export abstract class SC_Event {
176176
public getDefaultConfiguration(enabled: boolean): SC_EventConfiguration {
177177
const configuration = cloneObject<SC_EventConfiguration>(this.default_configuration);
178178
configuration.enabled = enabled;
179-
return configuration
179+
return configuration;
180180
}
181181

182182
protected getConfiguration(t_shell_command: TShellCommand) {

src/events/SC_Event_EveryNSeconds.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export class SC_Event_EveryNSeconds extends SC_Event {
7575
.setButtonText("Apply")
7676
.onClick(async () => {
7777
if (undefined == apply_seconds || apply_seconds === this.getConfiguration(t_shell_command).seconds) {
78-
new Notice("You didn't change the seconds!")
78+
new Notice("You didn't change the seconds!");
7979
} else if (isNaN(apply_seconds)) {
80-
new Notice("The seconds need to be an integer!")
80+
new Notice("The seconds need to be an integer!");
8181
} else if (apply_seconds <= 0) {
82-
new Notice("The seconds need to be at least 1!")
82+
new Notice("The seconds need to be at least 1!");
8383
} else {
8484
// All ok, save.
8585
this.getConfiguration(t_shell_command).seconds = apply_seconds;

src/events/SC_VaultEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export abstract class SC_VaultEvent extends SC_Event {
6262
this.file = file as TFile;
6363
break;
6464
case "folder":
65-
this.folder = file as TFolder
65+
this.folder = file as TFolder;
6666
break;
6767
}
6868

0 commit comments

Comments
 (0)