From c853c96ae95ae910e16a98f74fc04627b0a3d810 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 27 Jul 2021 20:27:19 +0200 Subject: [PATCH] lint --- tabby-core/src/components/appRoot.component.pug | 2 +- tabby-core/src/components/appRoot.component.ts | 4 ++-- tabby-core/src/services/app.service.ts | 10 +++++----- tabby-core/src/services/vault.service.ts | 15 +++++++++------ tabby-local/src/services/terminal.service.ts | 2 +- .../src/components/vaultSettingsTab.component.ts | 8 +++++--- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/tabby-core/src/components/appRoot.component.pug b/tabby-core/src/components/appRoot.component.pug index 5fbd1679..36b76618 100644 --- a/tabby-core/src/components/appRoot.component.pug +++ b/tabby-core/src/components/appRoot.component.pug @@ -23,7 +23,7 @@ title-bar( *ngFor='let tab of app.tabs; let idx = index', cdkDrag, [cdkDragData]='tab', - (cdkDragStarted)='onTabDragStart()', + (cdkDragStarted)='onTabDragStart(tab)', (cdkDragEnded)='onTabDragEnd()', [index]='idx', [tab]='tab', diff --git a/tabby-core/src/components/appRoot.component.ts b/tabby-core/src/components/appRoot.component.ts index d39348dc..2b94f0f7 100644 --- a/tabby-core/src/components/appRoot.component.ts +++ b/tabby-core/src/components/appRoot.component.ts @@ -182,8 +182,8 @@ export class AppRootComponent { return this.config.store.appearance.tabsLocation === 'left' || this.config.store.appearance.tabsLocation === 'right' } - onTabDragStart () { - this.app.emitTabDragStarted() + onTabDragStart (tab: BaseTabComponent) { + this.app.emitTabDragStarted(tab) } onTabDragEnd () { diff --git a/tabby-core/src/services/app.service.ts b/tabby-core/src/services/app.service.ts index f959e07e..3a1caa9c 100644 --- a/tabby-core/src/services/app.service.ts +++ b/tabby-core/src/services/app.service.ts @@ -56,7 +56,7 @@ export class AppService { private tabOpened = new Subject() private tabRemoved = new Subject() private tabClosed = new Subject() - private tabDragActive = new Subject() + private tabDragActive = new Subject() private ready = new AsyncSubject() private completionObservers = new Map() @@ -66,7 +66,7 @@ export class AppService { get tabsChanged$ (): Observable { return this.tabsChanged } get tabRemoved$ (): Observable { return this.tabRemoved } get tabClosed$ (): Observable { return this.tabClosed } - get tabDragActive$ (): Observable { return this.tabDragActive } + get tabDragActive$ (): Observable { return this.tabDragActive } /** Fires once when the app is ready */ get ready$ (): Observable { return this.ready } @@ -358,13 +358,13 @@ export class AppService { } /** @hidden */ - emitTabDragStarted (): void { - this.tabDragActive.next(true) + emitTabDragStarted (tab: BaseTabComponent): void { + this.tabDragActive.next(tab) } /** @hidden */ emitTabDragEnded (): void { - this.tabDragActive.next(false) + this.tabDragActive.next(null) } /** diff --git a/tabby-core/src/services/vault.service.ts b/tabby-core/src/services/vault.service.ts index 835a4bd1..b7439e51 100644 --- a/tabby-core/src/services/vault.service.ts +++ b/tabby-core/src/services/vault.service.ts @@ -26,7 +26,7 @@ interface StoredVault { export interface VaultSecret { type: string - key: Record + key: VaultSecretKey value: string } @@ -42,6 +42,9 @@ export interface Vault { secrets: VaultSecret[] } +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface VaultSecretKey { } + function migrateVaultContent (content: any): Vault { return { config: content.config, @@ -184,7 +187,7 @@ export class VaultService { return _rememberedPassphrase! } - async getSecret (type: string, key: Record): Promise { + async getSecret (type: string, key: VaultSecretKey): Promise { await this.ready$.toPromise() const vault = await this.load() if (!vault) { @@ -218,7 +221,7 @@ export class VaultService { await this.save(vault) } - async removeSecret (type: string, key: Record): Promise { + async removeSecret (type: string, key: VaultSecretKey): Promise { await this.ready$.toPromise() const vault = await this.load() if (!vault) { @@ -228,7 +231,7 @@ export class VaultService { await this.save(vault) } - private keyMatches (key: Record, secret: VaultSecret): boolean { + private keyMatches (key: VaultSecretKey, secret: VaultSecret): boolean { return Object.keys(key).every(k => secret.key[k] === key[k]) } @@ -267,9 +270,9 @@ export class VaultFileProvider extends FileProvider { if (!vault) { throw new Error('Vault is locked') } - const files = vault.secrets.filter(x => x.type === VAULT_SECRET_TYPE_FILE) + const files = vault.secrets.filter(x => x.type === VAULT_SECRET_TYPE_FILE) as VaultFileSecret[] if (files.length) { - const result = await this.selector.show('Select file', [ + const result = await this.selector.show('Select file', [ { name: 'Add a new file', icon: 'fas fa-plus', diff --git a/tabby-local/src/services/terminal.service.ts b/tabby-local/src/services/terminal.service.ts index ecd86ac7..b22e8dd2 100644 --- a/tabby-local/src/services/terminal.service.ts +++ b/tabby-local/src/services/terminal.service.ts @@ -23,7 +23,7 @@ export class TerminalService { if (!profile) { profile = profiles.filter(x => x.type === 'local' && x.isBuiltin)[0] } - return profile as PartialProfile + return profile } /** diff --git a/tabby-settings/src/components/vaultSettingsTab.component.ts b/tabby-settings/src/components/vaultSettingsTab.component.ts index bd1ed599..d0251bf4 100644 --- a/tabby-settings/src/components/vaultSettingsTab.component.ts +++ b/tabby-settings/src/components/vaultSettingsTab.component.ts @@ -74,13 +74,14 @@ export class VaultSettingsTabComponent extends BaseComponent { getSecretLabel (secret: VaultSecret) { if (secret.type === 'ssh:password') { - return `SSH password for ${secret.key.user}@${secret.key.host}:${secret.key.port}` + return `SSH password for ${(secret as any).key.user}@${(secret as any).key.host}:${(secret as any).key.port}` } if (secret.type === 'ssh:key-passphrase') { - return `Passphrase for a private key with hash ${secret.key.hash.substring(0, 8)}...` + return `Passphrase for a private key with hash ${(secret as any).key.hash.substring(0, 8)}...` } if (secret.type === VAULT_SECRET_TYPE_FILE) { - return `File: ${secret.key.description}` + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return `File: ${(secret as VaultFileSecret).key.description}` } return `Unknown secret of type ${secret.type} for ${JSON.stringify(secret.key)}` } @@ -129,6 +130,7 @@ export class VaultSettingsTabComponent extends BaseComponent { async exportFile (secret: VaultFileSecret) { this.vault.forgetPassphrase() + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion secret = (await this.vault.getSecret(secret.type, secret.key)) as VaultFileSecret const content = Buffer.from(secret.value, 'base64')