diff --git a/package.json b/package.json index 7b13a40465..63233f9755 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "symlink:win": "rm -rf ./jslib && cmd /c mklink /J .\\jslib ..\\jslib", "symlink:mac": "npm run symlink:lin", "symlink:lin": "rm -rf ./jslib && ln -s ../jslib ./jslib", - "lint": "tslint src/**/*.ts", - "lint:fix": "tslint src/**/*.ts --fix", + "lint": "tslint 'src/**/*.ts'", + "lint:fix": "tslint 'src/**/*.ts' --fix", "build": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\"", "build:main": "webpack --config webpack.main.js", "build:renderer": "gulp prebuild:renderer && webpack --config webpack.renderer.js", diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index d0ebe32eb6..3b0fcc6841 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -1,7 +1,7 @@ import { Component, - OnDestroy, NgZone, + OnDestroy, } from '@angular/core'; import { ActivatedRoute, @@ -43,7 +43,7 @@ export class LockComponent extends BaseLockComponent implements OnDestroy { async ngOnInit() { await super.ngOnInit(); - this.route.queryParams.subscribe((params) => { + this.route.queryParams.subscribe(params => { if (this.supportsBiometric && params.promptBiometric) { setTimeout(() => this.unlockBiometric(), 1000); } diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts index d0d0ba0b13..22835b7b76 100644 --- a/src/app/accounts/login.component.ts +++ b/src/app/accounts/login.component.ts @@ -1,8 +1,8 @@ import { Component, ComponentFactoryResolver, - OnDestroy, NgZone, + OnDestroy, ViewChild, ViewContainerRef, } from '@angular/core'; diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts index c2e26bb916..7f06183d31 100644 --- a/src/app/accounts/register.component.ts +++ b/src/app/accounts/register.component.ts @@ -1,8 +1,8 @@ import { Component, + NgZone, OnDestroy, OnInit, - NgZone, } from '@angular/core'; import { Router } from '@angular/router'; diff --git a/src/app/accounts/set-password.component.ts b/src/app/accounts/set-password.component.ts index b412c5b515..ff112a8962 100644 --- a/src/app/accounts/set-password.component.ts +++ b/src/app/accounts/set-password.component.ts @@ -1,7 +1,7 @@ import { Component, - OnDestroy, NgZone, + OnDestroy, } from '@angular/core'; import { diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 28279334b9..faa7f45ab2 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -22,8 +22,8 @@ import { ConstantsService } from 'jslib/services/constants.service'; import { ElectronConstants } from 'jslib/electron/electronConstants'; -import { Utils } from 'jslib/misc/utils'; import { isWindowsStore } from 'jslib/electron/utils'; +import { Utils } from 'jslib/misc/utils'; @Component({ selector: 'app-settings', @@ -81,15 +81,15 @@ export class SettingsComponent implements OnInit { this.enableTrayDescText = this.i18nService.t(trayKey + 'Desc'); const minToTrayKey = isMac ? 'enableMinToMenuBar' : 'enableMinToTray'; - this.enableMinToTrayText = this.i18nService.t(minToTrayKey) + this.enableMinToTrayText = this.i18nService.t(minToTrayKey); this.enableMinToTrayDescText = this.i18nService.t(minToTrayKey + 'Desc'); const closeToTrayKey = isMac ? 'enableCloseToMenuBar' : 'enableCloseToTray'; - this.enableCloseToTrayText = this.i18nService.t(closeToTrayKey) + this.enableCloseToTrayText = this.i18nService.t(closeToTrayKey); this.enableCloseToTrayDescText = this.i18nService.t(closeToTrayKey + 'Desc'); const startToTrayKey = isMac ? 'startToMenuBar' : 'startToTray'; - this.startToTrayText = this.i18nService.t(startToTrayKey) + this.startToTrayText = this.i18nService.t(startToTrayKey); this.startToTrayDescText = this.i18nService.t(startToTrayKey + 'Desc'); this.vaultTimeouts = [ @@ -114,7 +114,7 @@ export class SettingsComponent implements OnInit { ]); const localeOptions: any[] = []; - i18nService.supportedTranslationLocales.forEach((locale) => { + i18nService.supportedTranslationLocales.forEach(locale => { let name = locale; if (i18nService.localeNames.has(locale)) { name += (' - ' + i18nService.localeNames.get(locale)); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 17854135e9..7cb20ea035 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -90,8 +90,8 @@ import localePtBr from '@angular/common/locales/pt'; import localePtPt from '@angular/common/locales/pt-PT'; import localeRo from '@angular/common/locales/ro'; import localeRu from '@angular/common/locales/ru'; -import localeSr from '@angular/common/locales/sr'; import localeSk from '@angular/common/locales/sk'; +import localeSr from '@angular/common/locales/sr'; import localeSv from '@angular/common/locales/sv'; import localeTh from '@angular/common/locales/th'; import localeTr from '@angular/common/locales/tr'; diff --git a/src/app/main.ts b/src/app/main.ts index 0c8496b342..ae73640ad1 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -15,5 +15,5 @@ if (!isDev()) { platformBrowserDynamic().bootstrapModule(AppModule, { preserveWhitespaces: true }); // Disable drag and drop to prevent malicious links from executing in the context of the app -document.addEventListener('dragover', (event) => event.preventDefault()); -document.addEventListener('drop', (event) => event.preventDefault()); +document.addEventListener('dragover', event => event.preventDefault()); +document.addEventListener('drop', event => event.preventDefault()); diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index 1dd27e2b38..ebc3d93b03 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -1,8 +1,8 @@ import { Component, + NgZone, OnChanges, OnDestroy, - NgZone, } from '@angular/core'; import { AuditService } from 'jslib/abstractions/audit.service'; diff --git a/src/app/vault/export.component.ts b/src/app/vault/export.component.ts index 8d42599f18..0427d478ee 100644 --- a/src/app/vault/export.component.ts +++ b/src/app/vault/export.component.ts @@ -1,8 +1,8 @@ import { Component, + NgZone, OnDestroy, OnInit, - NgZone, } from '@angular/core'; import { CryptoService } from 'jslib/abstractions/crypto.service'; diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index fd80e97581..f0bb25ccee 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -194,7 +194,7 @@ export class VaultComponent implements OnInit, OnDestroy { async load() { let loaded = false; - const queryParamsSub = this.route.queryParams.subscribe(async (params) => { + const queryParamsSub = this.route.queryParams.subscribe(async params => { if (loaded) { return; } @@ -423,7 +423,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.attachmentsModalRef.createComponent(factory).instance; const childComponent = this.modal.show(AttachmentsComponent, this.attachmentsModalRef, - true, (comp) => comp.cipherId = cipher.id); + true, comp => comp.cipherId = cipher.id); let madeAttachmentChanges = false; childComponent.onUploadedAttachment.subscribe(() => madeAttachmentChanges = true); childComponent.onDeletedAttachment.subscribe(() => madeAttachmentChanges = true); @@ -445,7 +445,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.shareModalRef.createComponent(factory).instance; const childComponent = this.modal.show(ShareComponent, this.shareModalRef, true, - (comp) => comp.cipherId = cipher.id); + comp => comp.cipherId = cipher.id); childComponent.onSharedCipher.subscribe(async () => { this.modal.close(); @@ -465,7 +465,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.collectionsModalRef.createComponent(factory).instance; const childComponent = this.modal.show(CollectionsComponent, this.collectionsModalRef, - true, (comp) => comp.cipherId = cipher.id); + true, comp => comp.cipherId = cipher.id); childComponent.onSavedCollections.subscribe(() => { this.modal.close(); @@ -484,7 +484,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.passwordHistoryModalRef.createComponent(factory).instance; this.modal.show(PasswordHistoryComponent, - this.passwordHistoryModalRef, true, (comp) => comp.cipherId = cipher.id); + this.passwordHistoryModalRef, true, comp => comp.cipherId = cipher.id); this.modal.onClosed.subscribe(async () => { this.modal = null; }); @@ -505,7 +505,7 @@ export class VaultComponent implements OnInit, OnDestroy { async filterFavorites() { this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchFavorites'); - await this.ciphersComponent.reload((c) => c.favorite); + await this.ciphersComponent.reload(c => c.favorite); this.clearFilters(); this.favorites = true; this.go(); @@ -522,7 +522,7 @@ export class VaultComponent implements OnInit, OnDestroy { async filterCipherType(type: CipherType) { this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchType'); - await this.ciphersComponent.reload((c) => c.type === type); + await this.ciphersComponent.reload(c => c.type === type); this.clearFilters(); this.type = type; this.go(); @@ -531,7 +531,7 @@ export class VaultComponent implements OnInit, OnDestroy { async filterFolder(folderId: string) { folderId = folderId === 'none' ? null : folderId; this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchFolder'); - await this.ciphersComponent.reload((c) => c.folderId === folderId); + await this.ciphersComponent.reload(c => c.folderId === folderId); this.clearFilters(); this.folderId = folderId == null ? 'none' : folderId; this.go(); @@ -539,7 +539,7 @@ export class VaultComponent implements OnInit, OnDestroy { async filterCollection(collectionId: string) { this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchCollection'); - await this.ciphersComponent.reload((c) => c.collectionIds != null && + await this.ciphersComponent.reload(c => c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1); this.clearFilters(); this.collectionId = collectionId; @@ -555,7 +555,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.passwordGeneratorModalRef.createComponent(factory).instance; const childComponent = this.modal.show(PasswordGeneratorComponent, - this.passwordGeneratorModalRef, true, (comp) => comp.showSelect = showSelect); + this.passwordGeneratorModalRef, true, comp => comp.showSelect = showSelect); childComponent.onSelected.subscribe((password: string) => { this.modal.close(); @@ -596,7 +596,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.folderAddEditModalRef.createComponent(factory).instance; const childComponent = this.modal.show( - FolderAddEditComponent, this.folderAddEditModalRef, true, (comp) => comp.folderId = null); + FolderAddEditComponent, this.folderAddEditModalRef, true, comp => comp.folderId = null); childComponent.onSavedFolder.subscribe(async (folder: FolderView) => { this.modal.close(); @@ -616,7 +616,7 @@ export class VaultComponent implements OnInit, OnDestroy { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); this.modal = this.folderAddEditModalRef.createComponent(factory).instance; const childComponent = this.modal.show( - FolderAddEditComponent, this.folderAddEditModalRef, true, (comp) => comp.folderId = folderId); + FolderAddEditComponent, this.folderAddEditModalRef, true, comp => comp.folderId = folderId); childComponent.onSavedFolder.subscribe(async (folder: FolderView) => { this.modal.close(); @@ -699,7 +699,7 @@ export class VaultComponent implements OnInit, OnDestroy { private updateCollectionProperties() { if (this.collectionId != null) { - const collection = this.groupingsComponent.collections.filter((c) => c.id === this.collectionId); + const collection = this.groupingsComponent.collections.filter(c => c.id === this.collectionId); if (collection.length > 0) { this.addOrganizationId = collection[0].organizationId; this.addCollectionIds = [this.collectionId]; diff --git a/src/entry.ts b/src/entry.ts index d4cd12cfe6..57d82518de 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -16,7 +16,7 @@ if (process.argv.some(arg => arg.indexOf('chrome-extension://') !== -1 || arg.in }); } - process.stdout.on('error', (e) => { + process.stdout.on('error', e => { if (e.code === 'EPIPE') { process.exit(0); } diff --git a/src/main.ts b/src/main.ts index d2d2350a52..0dc0700186 100644 --- a/src/main.ts +++ b/src/main.ts @@ -75,7 +75,7 @@ export class Main { app.setPath('logs', path.join(app.getPath('userData'), 'logs')); const args = process.argv.slice(1); - const watch = args.some((val) => val === '--watch'); + const watch = args.some(val => val === '--watch'); if (watch) { // tslint:disable-next-line @@ -92,7 +92,7 @@ export class Main { this.storageService = new ElectronStorageService(app.getPath('userData'), storageDefaults); this.windowMain = new WindowMain(this.storageService, true, undefined, undefined, - (arg) => this.processDeepLink(arg), (win) => this.trayMain.setupWindowListeners(win)); + arg => this.processDeepLink(arg), win => this.trayMain.setupWindowListeners(win)); this.messagingMain = new MessagingMain(this, this.storageService); this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain, 'desktop', () => { this.menuMain.updateMenuItem.enabled = false; @@ -105,7 +105,7 @@ export class Main { this.powerMonitorMain = new PowerMonitorMain(this); this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.storageService); - this.messagingService = new ElectronMainMessagingService(this.windowMain, (message) => { + this.messagingService = new ElectronMainMessagingService(this.windowMain, message => { this.messagingMain.onMessage(message); }); @@ -172,7 +172,7 @@ export class Main { } private processDeepLink(argv: string[]): void { - argv.filter((s) => s.indexOf('bitwarden://') === 0).forEach((s) => { + argv.filter(s => s.indexOf('bitwarden://') === 0).forEach(s => { const url = new URL(s); const code = url.searchParams.get('code'); const receivedState = url.searchParams.get('state'); diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index 665fd30a57..ad0c7456af 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -37,7 +37,7 @@ export class MessagingMain { break; case 'minimizeOnCopy': this.storageService.get(ElectronConstants.minimizeOnCopyToClipboardKey).then( - (shouldMinimize) => { + shouldMinimize => { if (shouldMinimize && this.main.windowMain.win !== null) { this.main.windowMain.win.minimize(); } diff --git a/src/main/nativeMessaging.main.ts b/src/main/nativeMessaging.main.ts index 7d13ba5870..9ab6c47268 100644 --- a/src/main/nativeMessaging.main.ts +++ b/src/main/nativeMessaging.main.ts @@ -1,11 +1,11 @@ -import { promises as fs, existsSync } from 'fs'; +import { existsSync, promises as fs } from 'fs'; import * as ipc from 'node-ipc'; +import { homedir, userInfo } from 'os'; import * as path from 'path'; import * as util from 'util'; -import { homedir, userInfo } from 'os'; -import { LogService } from 'jslib/abstractions/log.service'; import { ipcMain } from 'electron'; +import { LogService } from 'jslib/abstractions/log.service'; import { WindowMain } from 'jslib/electron/window.main'; export class NativeMessagingMain { @@ -31,11 +31,11 @@ export class NativeMessagingMain { if (this.socket != null && msg != null) { this.send(msg, this.socket); } - }) + }); ipc.server.on('connect', () => { this.connected = true; - }) + }); ipc.server.on( 'socket.disconnected', @@ -66,7 +66,7 @@ export class NativeMessagingMain { 'description': 'Bitwarden desktop <-> browser bridge', 'path': this.binaryPath(), 'type': 'stdio', - } + }; const firefoxJson = {...baseJson, ...{ 'allowed_extensions': ['{446900e4-71c2-419f-a6a7-df9c091e268b}']}}; const chromeJson = {...baseJson, ...{ @@ -168,11 +168,11 @@ export class NativeMessagingMain { const createKey = util.promisify(regedit.createKey); const putValue = util.promisify(regedit.putValue); - this.logService.debug(`Adding registry: ${location}`) + this.logService.debug(`Adding registry: ${location}`); // Check installed try { - await list(check) + await list(check); } catch { this.logService.warning(`Not finding registry ${check} skipping.`); return; @@ -188,7 +188,7 @@ export class NativeMessagingMain { value: jsonFile, type: 'REG_DEFAULT', }, - } + }; return putValue(obj); } catch (error) { @@ -202,7 +202,7 @@ export class NativeMessagingMain { const list = util.promisify(regedit.list); const deleteKey = util.promisify(regedit.deleteKey); - this.logService.debug(`Removing registry: ${key}`) + this.logService.debug(`Removing registry: ${key}`); try { await list(key); diff --git a/src/proxy/ipc.ts b/src/proxy/ipc.ts index 33dde2c72d..addbc87b5c 100644 --- a/src/proxy/ipc.ts +++ b/src/proxy/ipc.ts @@ -10,7 +10,7 @@ if (process.platform === 'darwin') { } export default class IPC { - onMessage: (message: object) => void + onMessage: (message: object) => void; private connected = false; @@ -24,7 +24,7 @@ export default class IPC { ); // Notify browser extension, connection is established to desktop application. - this.onMessage({command: 'connected'}) + this.onMessage({command: 'connected'}); }); ipc.of.bitwarden.on('disconnect', () => { @@ -32,7 +32,7 @@ export default class IPC { console.error('disconnected from world'); // Notify browser extension, no connection to desktop application. - this.onMessage({command: 'disconnected'}) + this.onMessage({command: 'disconnected'}); }); ipc.of.bitwarden.on('message', (message: any) => { diff --git a/src/proxy/native-messaging-proxy.ts b/src/proxy/native-messaging-proxy.ts index f308016ead..34bc505fd2 100644 --- a/src/proxy/native-messaging-proxy.ts +++ b/src/proxy/native-messaging-proxy.ts @@ -1,5 +1,5 @@ -import NativeMessage from './nativemessage'; import IPC from './ipc'; +import NativeMessage from './nativemessage'; // Proxy is a lightweight application which provides bi-directional communication // between the browser extension and a running desktop application. diff --git a/src/services/nativeMessaging.service.ts b/src/services/nativeMessaging.service.ts index 910e5fd094..88ed58e8e9 100644 --- a/src/services/nativeMessaging.service.ts +++ b/src/services/nativeMessaging.service.ts @@ -10,10 +10,10 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { UserService } from 'jslib/abstractions/user.service'; import { VaultTimeoutService } from 'jslib/abstractions/vaultTimeout.service'; -import { Utils } from 'jslib/misc/utils'; -import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey'; import { StorageService } from 'jslib/abstractions'; import { ElectronConstants } from 'jslib/electron/electronConstants'; +import { Utils } from 'jslib/misc/utils'; +import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey'; const MessageValidTimeout = 10 * 1000; const EncryptionAlgorithm = 'sha1'; diff --git a/tslint.json b/tslint.json index 7e4320f723..49f3444b9a 100644 --- a/tslint.json +++ b/tslint.json @@ -49,6 +49,15 @@ "check-separator", "check-type" ], - "max-classes-per-file": false + "max-classes-per-file": false, + "ordered-imports": true, + "arrow-parens": [ + true, + "ban-single-arg-parens" + ], + "semicolon": [ + true, + "always" + ] } }