From dc9508f80d71c4ce5d53cb747a67ab8ce1a71807 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 24 Jul 2019 11:24:57 +0200 Subject: [PATCH] lint & enabled linter on Azure pipelines --- .eslintrc.yml | 1 + app/src/plugins.ts | 2 +- azure-pipelines.yml | 3 +++ terminus-core/src/components/appRoot.component.ts | 4 ++-- terminus-core/src/components/tabHeader.component.ts | 4 ++-- terminus-core/src/services/app.service.ts | 6 +++--- terminus-core/src/services/config.service.ts | 4 ++-- terminus-core/src/services/docking.service.ts | 12 ++++++------ terminus-core/src/services/updater.service.ts | 13 ++++++------- .../src/components/settingsTab.component.ts | 8 ++++---- terminus-ssh/src/services/ssh.service.ts | 2 +- .../src/api/baseTerminalTab.component.ts | 4 ++-- terminus-terminal/src/services/sessions.service.ts | 2 +- 13 files changed, 34 insertions(+), 31 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 20da7bad..2a645c35 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -31,6 +31,7 @@ rules: '@typescript-eslint/promise-function-async': off '@typescript-eslint/no-unnecessary-type-assertion': off '@typescript-eslint/require-array-sort-compare': off + '@typescript-eslint/no-floating-promises': off '@typescript-eslint/no-use-before-define': - error - classes: false diff --git a/app/src/plugins.ts b/app/src/plugins.ts index 04905fd4..7f033a59 100644 --- a/app/src/plugins.ts +++ b/app/src/plugins.ts @@ -176,7 +176,7 @@ export async function loadPlugins (foundPlugins: PluginInfo[], progress: Progres pluginModule['bootstrap'] = packageModule.bootstrap plugins.push(pluginModule) console.timeEnd(label) - await (new Promise(x => setTimeout(x, 50))) + await new Promise(x => setTimeout(x, 50)) } catch (error) { console.error(`Could not load ${foundPlugin.name}:`, error) } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf9e910b..ebd1bfe4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -86,6 +86,9 @@ jobs: - script: yarn run build displayName: 'Build' + - script: yarn run lint + displayName: 'Lint' + - script: node scripts/prepackage-plugins.js displayName: 'Prepackage plugins' diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index 3787a7ee..cecb43cf 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -128,8 +128,8 @@ export class AppRootComponent { }) this.hostApp.windowCloseRequest$.subscribe(async () => { - await this.app.closeAllTabs() && this.hostApp.closeWindow(); - }); + await this.app.closeAllTabs() && this.hostApp.closeWindow() + }) if (window['safeModeReason']) { ngbModal.open(SafeModeModalComponent) diff --git a/terminus-core/src/components/tabHeader.component.ts b/terminus-core/src/components/tabHeader.component.ts index 4abe4c0c..62fd40bc 100644 --- a/terminus-core/src/components/tabHeader.component.ts +++ b/terminus-core/src/components/tabHeader.component.ts @@ -10,7 +10,7 @@ import { AppService } from '../services/app.service' import { HostAppService, Platform } from '../services/hostApp.service' /** @hidden */ -export interface ISortableComponent { +export interface SortableComponentProxy { setDragHandle (_: HTMLElement) } @@ -34,7 +34,7 @@ export class TabHeaderComponent { private hostApp: HostAppService, private ngbModal: NgbModal, private hotkeys: HotkeysService, - @Inject(SortableComponent) private parentDraggable: ISortableComponent, + @Inject(SortableComponent) private parentDraggable: SortableComponentProxy, @Optional() @Inject(TabContextMenuItemProvider) protected contextMenuProviders: TabContextMenuItemProvider[], ) { this.hotkeys.matchedHotkey.subscribe((hotkey) => { diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 8c799d89..b5826ccb 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -209,16 +209,16 @@ export class AppService { /** * Attempts to close all tabs, returns false if one of the tabs blocked closure */ - async closeAllTabs () : Promise { + async closeAllTabs (): Promise { for (const tab of this.tabs) { if (!await tab.canClose()) { - return false; + return false } } for (const tab of this.tabs) { tab.destroy() } - return true; + return true } /** @hidden */ diff --git a/terminus-core/src/services/config.service.ts b/terminus-core/src/services/config.service.ts index 157521c4..5ab96373 100644 --- a/terminus-core/src/services/config.service.ts +++ b/terminus-core/src/services/config.service.ts @@ -71,8 +71,8 @@ export class ConfigProxy { } } - getValue (_key: string): any { } - setValue (_key: string, _value: any) { } + getValue (_key: string): any { } // eslint-disable-line @typescript-eslint/no-empty-function + setValue (_key: string, _value: any) { } // eslint-disable-line @typescript-eslint/no-empty-function } @Injectable({ providedIn: 'root' }) diff --git a/terminus-core/src/services/docking.service.ts b/terminus-core/src/services/docking.service.ts index a4a0289f..9d4a619f 100644 --- a/terminus-core/src/services/docking.service.ts +++ b/terminus-core/src/services/docking.service.ts @@ -30,8 +30,8 @@ export class DockingService { } const newBounds: Bounds = { x: 0, y: 0, width: 0, height: 0 } - - const fill = this.config.store.appearance.dockFill <= 1 ? this.config.store.appearance.dockFill : 1; + + const fill = this.config.store.appearance.dockFill <= 1 ? this.config.store.appearance.dockFill : 1 const [minWidth, minHeight] = this.hostApp.getWindow().getMinimumSize() if (dockSide === 'left' || dockSide === 'right') { @@ -64,15 +64,15 @@ export class DockingService { } getScreens () { - const primaryDisplayID = this.electron.screen.getPrimaryDisplay().id; - return this.electron.screen.getAllDisplays().sort((a,b) => ( + const primaryDisplayID = this.electron.screen.getPrimaryDisplay().id + return this.electron.screen.getAllDisplays().sort((a, b) => a.bounds.x === b.bounds.x ? a.bounds.y - b.bounds.y : a.bounds.x - b.bounds.x - )).map((display,index) => { + ).map((display,index) => { return { id: display.id, name: display.id === primaryDisplayID ? 'Primary Display' : `Display ${index +1}`, } - }); + }) } private repositionWindow () { diff --git a/terminus-core/src/services/updater.service.ts b/terminus-core/src/services/updater.service.ts index 74ef004e..8620ddc1 100644 --- a/terminus-core/src/services/updater.service.ts +++ b/terminus-core/src/services/updater.service.ts @@ -29,7 +29,7 @@ export class UpdaterService { this.autoUpdater = electron.remote.require('electron-updater').autoUpdater - this.autoUpdater.autoInstallOnAppQuit = !!config.store.enableAutomaticUpdates; + this.autoUpdater.autoInstallOnAppQuit = !!config.store.enableAutomaticUpdates this.autoUpdater.on('update-available', () => { this.logger.info('Update available') @@ -76,20 +76,19 @@ export class UpdaterService { this.electron.shell.openExternal(this.updateURL) } else { if (process.platform === 'win32') { - let downloadpath = await this.autoUpdater.downloadUpdate(); + let downloadpath = await this.autoUpdater.downloadUpdate() fs.exists(downloadpath[0], (exists) => { if (exists) { fs.copyFile(downloadpath[0], os.tmpdir() + 'terminus-installer-temp.exe', (err) => { if (!err) { - spawn(os.tmpdir() + 'terminus-installer-temp.exe', ['--force-run'], {detached: true, stdio: 'ignore'}); + spawn(os.tmpdir() + 'terminus-installer-temp.exe', ['--force-run'], { detached: true, stdio: 'ignore' }) } - }); - + }) } }) } else { - await this.downloaded; - this.autoUpdater.quitAndInstall(false, true); + await this.downloaded + this.autoUpdater.quitAndInstall(false, true) } } } diff --git a/terminus-settings/src/components/settingsTab.component.ts b/terminus-settings/src/components/settingsTab.component.ts index 454f11b4..44a30543 100644 --- a/terminus-settings/src/components/settingsTab.component.ts +++ b/terminus-settings/src/components/settingsTab.component.ts @@ -70,12 +70,12 @@ export class SettingsTabComponent extends BaseTabComponent { onConfigChange() const onScreenChange = () => { - this.zone.run(() => this.screens = this.docking.getScreens()); + this.zone.run(() => this.screens = this.docking.getScreens()) } - electron.screen.on('display-added', onScreenChange); - electron.screen.on('display-removed', onScreenChange); - electron.screen.on('display-metrics-changed', onScreenChange); + electron.screen.on('display-added', onScreenChange) + electron.screen.on('display-removed', onScreenChange) + electron.screen.on('display-metrics-changed', onScreenChange) hotkeys.getHotkeyDescriptions().then(descriptions => { this.hotkeyDescriptions = descriptions diff --git a/terminus-ssh/src/services/ssh.service.ts b/terminus-ssh/src/services/ssh.service.ts index 0e493e54..124bea5a 100644 --- a/terminus-ssh/src/services/ssh.service.ts +++ b/terminus-ssh/src/services/ssh.service.ts @@ -138,7 +138,7 @@ export class SSHService { let agent: string = null if (this.hostApp.platform === Platform.Windows) { const pageantRunning = new Promise(resolve => { - windowsProcessTreeNative.getProcessList(list => { + windowsProcessTreeNative.getProcessList(list => { // eslint-disable-line block-scoped-var resolve(list.some(x => x.name === 'pageant.exe')) }, 0) }) diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index ef5739d2..ab22708b 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -15,7 +15,7 @@ import { TerminalContextMenuItemProvider } from './contextMenuProvider' /** @hidden */ -export interface IToastrService { +export interface ToastrServiceProxy { info (_: string) } /** @@ -80,7 +80,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit protected sessions: SessionsService, protected electron: ElectronService, protected terminalContainersService: TerminalFrontendService, - @Inject(ToastrService) protected toastr: IToastrService, + @Inject(ToastrService) protected toastr: ToastrServiceProxy, protected log: LogService, @Optional() @Inject(TerminalDecorator) protected decorators: TerminalDecorator[], @Optional() @Inject(TerminalContextMenuItemProvider) protected contextMenuProviders: TerminalContextMenuItemProvider[], diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index 50c5bf50..c066aadf 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -284,7 +284,7 @@ export class Session extends BaseSession { } catch (e) { return null } - let cwd = lines[(lines[1] === 'fcwd') ? 2 : 1].substring(1) + let cwd = lines[lines[1] === 'fcwd' ? 2 : 1].substring(1) if (cwd.startsWith(catalinaDataVolumePrefix)) { cwd = cwd.substring(catalinaDataVolumePrefix.length) }