diff --git a/.eslintrc.yml b/.eslintrc.yml index f65859a9..a2921cbd 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -36,7 +36,9 @@ rules: '@typescript-eslint/prefer-readonly': off '@typescript-eslint/require-await': off '@typescript-eslint/strict-boolean-expressions': off - '@typescript-eslint/no-misused-promises': off + '@typescript-eslint/no-misused-promises': + - error + - checksVoidReturn: false '@typescript-eslint/typedef': off '@typescript-eslint/consistent-type-imports': off '@typescript-eslint/sort-type-union-intersection-members': off @@ -95,7 +97,9 @@ rules: - error - single - allowTemplateLiterals: true - '@typescript-eslint/no-confusing-void-expression': off + '@typescript-eslint/no-confusing-void-expression': + - error + - ignoreArrowShorthand: true '@typescript-eslint/no-non-null-assertion': off '@typescript-eslint/no-unnecessary-condition': - error diff --git a/tabby-core/src/components/splitTab.component.ts b/tabby-core/src/components/splitTab.component.ts index 221fac51..5e5d6a74 100644 --- a/tabby-core/src/components/splitTab.component.ts +++ b/tabby-core/src/components/splitTab.component.ts @@ -453,7 +453,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit async splitTab (tab: BaseTabComponent, dir: SplitDirection): Promise { const newTab = await this.tabsService.duplicate(tab) if (newTab) { - this.addTab(newTab, tab, dir) + await this.addTab(newTab, tab, dir) } return newTab } diff --git a/tabby-core/src/components/welcomeTab.component.ts b/tabby-core/src/components/welcomeTab.component.ts index d0fac0c9..7a85ad0d 100644 --- a/tabby-core/src/components/welcomeTab.component.ts +++ b/tabby-core/src/components/welcomeTab.component.ts @@ -21,13 +21,13 @@ export class WelcomeTabComponent extends BaseTabComponent { this.setTitle('Welcome') } - closeAndDisable () { + async closeAndDisable () { this.config.store.enableWelcomeTab = false this.config.store.pluginBlacklist = [] if (!this.enableGlobalHotkey) { this.config.store.hotkeys['toggle-window'] = [] } - this.config.save() + await this.config.save() this.hostWindow.reload() } } diff --git a/tabby-core/src/services/config.service.ts b/tabby-core/src/services/config.service.ts index ca1c3ae2..aa1953eb 100644 --- a/tabby-core/src/services/config.service.ts +++ b/tabby-core/src/services/config.service.ts @@ -88,7 +88,7 @@ export class ConfigProxy { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function setValue (_key: string, _value: any) { } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function - getDefault (_key: string) { } + getDefault (_key: string): any { } } @Injectable({ providedIn: 'root' }) @@ -195,10 +195,10 @@ export class ConfigService { /** * Writes config YAML as string */ - writeRaw (data: string): void { + async writeRaw (data: string): Promise { this._store = yaml.load(data) - this.save() - this.load() + await this.save() + await this.load() this.emitChange() } diff --git a/tabby-core/src/services/hotkeys.service.ts b/tabby-core/src/services/hotkeys.service.ts index 26996cf2..78596b60 100644 --- a/tabby-core/src/services/hotkeys.service.ts +++ b/tabby-core/src/services/hotkeys.service.ts @@ -46,10 +46,9 @@ export class HotkeysService { } }) }) - this.config.ready$.toPromise().then(() => { - this.getHotkeyDescriptions().then(hotkeys => { - this.hotkeyDescriptions = hotkeys - }) + this.config.ready$.toPromise().then(async () => { + const hotkeys = await this.getHotkeyDescriptions() + this.hotkeyDescriptions = hotkeys }) // deprecated diff --git a/tabby-core/src/services/vault.service.ts b/tabby-core/src/services/vault.service.ts index 150513a7..7e13e1a1 100644 --- a/tabby-core/src/services/vault.service.ts +++ b/tabby-core/src/services/vault.service.ts @@ -270,7 +270,7 @@ export class VaultFileProvider extends FileProvider { } const transfer = transfers[0] const id = (await wrapPromise(this.zone, promisify(crypto.randomBytes)(32))).toString('hex') - this.vault.addSecret({ + await this.vault.addSecret({ type: VAULT_SECRET_TYPE_FILE, key: { id, diff --git a/tabby-electron/src/services/updater.service.ts b/tabby-electron/src/services/updater.service.ts index e29fa2ae..ab58a4fc 100644 --- a/tabby-electron/src/services/updater.service.ts +++ b/tabby-electron/src/services/updater.service.ts @@ -120,7 +120,7 @@ export class ElectronUpdaterService extends UpdaterService { async update (): Promise { if (!this.electronUpdaterAvailable) { - this.electron.shell.openExternal(this.updateURL) + await this.electron.shell.openExternal(this.updateURL) } else { if ((await this.platform.showMessageBox( { diff --git a/tabby-local/src/session.ts b/tabby-local/src/session.ts index 8b1c2d18..27db5c75 100644 --- a/tabby-local/src/session.ts +++ b/tabby-local/src/session.ts @@ -264,7 +264,8 @@ export class Session extends BaseSession { return new Promise((resolve, reject) => { psNode.lookup({ ppid: this.truePID }, (err, processes) => { if (err) { - return reject(err) + reject(err) + return } resolve(processes as ChildProcess[]) }) diff --git a/tabby-ssh/src/api.ts b/tabby-ssh/src/api.ts index abd18139..3feb1181 100644 --- a/tabby-ssh/src/api.ts +++ b/tabby-ssh/src/api.ts @@ -176,7 +176,8 @@ export class SFTPFileHandle { while (true) { const wait = this.sftp.write(this.handle, chunk, 0, chunk.length, this.position, err => { if (err) { - return reject(err) + reject(err) + return } this.position += chunk.length resolve() @@ -405,7 +406,8 @@ export class SSHSession extends BaseSession { const forward = this.forwardedPorts.find(x => x.port === details.destPort) if (!forward) { this.emitServiceMessage(colors.bgRed.black(' X ') + ` Rejected incoming forwarded connection for unrecognized port ${details.destPort}`) - return reject() + reject() + return } const socket = new Socket() socket.connect(forward.targetPort, forward.targetAddress) @@ -560,7 +562,8 @@ export class SSHSession extends BaseSession { if (err) { // eslint-disable-next-line @typescript-eslint/no-base-to-string this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`) - return reject() + reject() + return } const socket = accept() stream.pipe(socket) @@ -587,7 +590,8 @@ export class SSHSession extends BaseSession { if (err) { // eslint-disable-next-line @typescript-eslint/no-base-to-string this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote rejected port forwarding for ${fw}: ${err}`) - return reject(err) + reject(err) + return } resolve() }) diff --git a/tabby-ssh/src/components/sftpDeleteModal.component.ts b/tabby-ssh/src/components/sftpDeleteModal.component.ts index b134c4b2..b2a362cb 100644 --- a/tabby-ssh/src/components/sftpDeleteModal.component.ts +++ b/tabby-ssh/src/components/sftpDeleteModal.component.ts @@ -19,11 +19,10 @@ export class SFTPDeleteModalComponent extends BaseComponent { super() } - ngOnInit (): void { + async ngOnInit (): Promise { this.destroyed$.subscribe(() => this.cancel()) - this.run(this.item).then(() => { - this.modalInstance.close() - }) + await this.run(this.item) + this.modalInstance.close() } cancel (): void { diff --git a/tabby-ssh/src/components/sftpPanel.component.ts b/tabby-ssh/src/components/sftpPanel.component.ts index dfa8c42d..a0f3f59a 100644 --- a/tabby-ssh/src/components/sftpPanel.component.ts +++ b/tabby-ssh/src/components/sftpPanel.component.ts @@ -33,7 +33,7 @@ export class SFTPPanelComponent { async ngOnInit (): Promise { this.sftp = await this.session.openSFTP() - this.navigate(this.path) + await this.navigate(this.path) } async navigate (newPath: string): Promise { @@ -75,25 +75,23 @@ export class SFTPPanelComponent { async open (item: SFTPFile): Promise { if (item.isDirectory) { - this.navigate(item.fullPath) + await this.navigate(item.fullPath) } else if (item.isSymlink) { const target = path.resolve(this.path, await this.sftp.readlink(item.fullPath)) const stat = await this.sftp.stat(target) if (stat.isDirectory) { - this.navigate(item.fullPath) + await this.navigate(item.fullPath) } else { - this.download(item.fullPath, stat.size) + await this.download(item.fullPath, stat.size) } } else { - this.download(item.fullPath, item.size) + await this.download(item.fullPath, item.size) } } async upload (): Promise { const transfers = await this.platform.startUpload({ multiple: true }) - for (const transfer of transfers) { - this.uploadOne(transfer) - } + await Promise.all(transfers.map(t => this.uploadOne(t))) } async uploadOne (transfer: FileUpload): Promise { @@ -111,7 +109,7 @@ export class SFTPPanelComponent { handle.close() transfer.close() if (this.path === savedPath) { - this.navigate(this.path) + await this.navigate(this.path) } } catch (e) { transfer.cancel() diff --git a/tabby-ssh/src/components/sshTab.component.ts b/tabby-ssh/src/components/sshTab.component.ts index 28f6a067..d4736592 100644 --- a/tabby-ssh/src/components/sshTab.component.ts +++ b/tabby-ssh/src/components/sshTab.component.ts @@ -98,7 +98,8 @@ export class SSHTabComponent extends BaseTerminalTabComponent { (err, stream) => { if (err) { jumpSession.emitServiceMessage(colors.bgRed.black(' X ') + ` Could not set up port forward on ${jumpConnection.name}`) - return reject(err) + reject(err) + return } resolve(stream) }