1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

Fixed lint warnings (#1655)

This commit is contained in:
Vincent Salucci 2021-03-02 12:31:52 -06:00 committed by GitHub
parent 1a59c542bd
commit 61d7fcfc85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 48 additions and 41 deletions

View File

@ -1,10 +1,11 @@
import { Component } from '@angular/core';
import { ConstantsService } from 'jslib/services/constants.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { Utils } from 'jslib/misc/utils';

View File

@ -25,6 +25,7 @@ import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib/angular/components/two-factor.component';
import { PopupUtilsService } from '../services/popup-utils.service';
import { BrowserApi } from '../../browser/browserApi';
const BroadcasterSubscriptionId = 'TwoFactorComponent';
@ -81,7 +82,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
}
}
const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => {
const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
if (qParams.sso === 'true') {
super.onSuccessfulLogin = () => {
BrowserApi.reloadOpenWindows();

View File

@ -73,7 +73,7 @@ export class SendAddEditComponent extends BaseAddEditComponent {
this.inPopout = this.popupUtilsService.inPopout(window);
this.inSidebar = this.popupUtilsService.inSidebar(window);
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (params.sendId) {
this.sendId = params.sendId;
}

View File

@ -20,8 +20,8 @@ import { AuditService } from 'jslib/abstractions/audit.service';
import { AuthService as AuthServiceAbstraction } from 'jslib/abstractions/auth.service';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { EventService } from 'jslib/abstractions/event.service';
import { ExportService } from 'jslib/abstractions/export.service';
@ -47,10 +47,10 @@ import { AutofillService } from '../../services/abstractions/autofill.service';
import BrowserMessagingService from '../../services/browserMessaging.service';
import { AuthService } from 'jslib/services/auth.service';
import { ConsoleLogService } from 'jslib/services/consoleLog.service';
import { ConstantsService } from 'jslib/services/constants.service';
import { SearchService } from 'jslib/services/search.service';
import { StateService } from 'jslib/services/state.service';
import { ConsoleLogService } from 'jslib/services/consoleLog.service';
import { Analytics } from 'jslib/misc/analytics';
@ -93,9 +93,9 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
if (theme == null) {
theme = platformUtilsService.getDefaultSystemTheme();
platformUtilsService.onDefaultSystemThemeChange((theme) => {
platformUtilsService.onDefaultSystemThemeChange(sysTheme => {
window.document.documentElement.classList.remove('theme_light', 'theme_dark');
window.document.documentElement.classList.add('theme_' + theme);
window.document.documentElement.classList.add('theme_' + sysTheme);
});
}
window.document.documentElement.classList.add('locale_' + i18nService.translationLocale);

View File

@ -1,18 +1,22 @@
import {
Component,
NgZone,
OnDestroy,
OnInit,
NgZone
} from '@angular/core';
import { Router } from '@angular/router';
import { ConstantsService } from 'jslib/services/constants.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { ConstantsService } from 'jslib/services/constants.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { BrowserApi } from '../../browser/browserApi';
import { Utils } from 'jslib/misc/utils';
interface ExcludedDomain {
@ -104,7 +108,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
async loadCurrentUris() {
const tabs = await BrowserApi.tabsQuery({ windowType: 'normal' });
if (tabs) {
const uriSet = new Set(tabs.map((tab) => Utils.getHostname(tab.url)));
const uriSet = new Set(tabs.map(tab => Utils.getHostname(tab.url)));
uriSet.delete(null);
this.currentUris = Array.from(uriSet);
}

View File

@ -24,7 +24,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
}
async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (params.folderId) {
this.folderId = params.folderId;
}

View File

@ -214,8 +214,8 @@ export class SettingsComponent implements OnInit {
// Request permission to use the optional permission for nativeMessaging
if (!this.platformUtilsService.isFirefox()) {
const hasPermission = await new Promise((resolve) => {
chrome.permissions.contains({permissions: ['nativeMessaging']}, resolve);
const hasPermission = await new Promise(resolve => {
chrome.permissions.contains({ permissions: ['nativeMessaging'] }, resolve);
});
if (!hasPermission) {
@ -224,7 +224,7 @@ export class SettingsComponent implements OnInit {
this.i18nService.t('ok'), null);
const granted = await new Promise((resolve, reject) => {
chrome.permissions.request({permissions: ['nativeMessaging']}, resolve);
chrome.permissions.request({ permissions: ['nativeMessaging'] }, resolve);
});
if (!granted) {
@ -254,23 +254,23 @@ export class SettingsComponent implements OnInit {
await this.cryptoService.toggleKey();
await Promise.race([
submitted.then((result) => {
submitted.then(result => {
if (result.dismiss === Swal.DismissReason.cancel) {
this.biometric = false;
this.storageService.remove(ConstantsService.biometricAwaitingAcceptance);
}
}),
this.platformUtilsService.authenticateBiometric().then((result) => {
this.platformUtilsService.authenticateBiometric().then(result => {
this.biometric = result;
Swal.close();
if (this.biometric === false) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorEnableBiometricTitle'), this.i18nService.t('errorEnableBiometricDesc'));
}
}).catch((e) => {
}).catch(e => {
// Handle connection errors
this.biometric = false;
})
}),
]);
} else {
await this.storageService.remove(ConstantsService.biometricUnlockKey);

View File

@ -49,7 +49,7 @@ export class AddEditComponent extends BaseAddEditComponent {
async ngOnInit() {
await super.ngOnInit();
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (params.cipherId) {
this.cipherId = params.cipherId;
}
@ -57,7 +57,7 @@ export class AddEditComponent extends BaseAddEditComponent {
this.folderId = params.folderId;
}
if (params.collectionId) {
const collection = this.writeableCollections.find((c) => c.id === params.collectionId);
const collection = this.writeableCollections.find(c => c.id === params.collectionId);
if (collection != null) {
this.collectionIds = [collection.id];
this.organizationId = collection.organizationId;
@ -92,7 +92,7 @@ export class AddEditComponent extends BaseAddEditComponent {
if (!this.editMode) {
const tabs = await BrowserApi.tabsQuery({ windowType: 'normal' });
this.currentUris = tabs == null ? null :
tabs.filter((tab) => tab.url != null && tab.url !== '').map((tab) => tab.url);
tabs.filter(tab => tab.url != null && tab.url !== '').map(tab => tab.url);
}
window.setTimeout(() => {
@ -150,7 +150,7 @@ export class AddEditComponent extends BaseAddEditComponent {
this.stateService.save('addEditCipherInfo', {
cipher: this.cipher,
collectionIds: this.collections == null ? [] :
this.collections.filter((c) => (c as any).checked).map((c) => c.id),
this.collections.filter(c => (c as any).checked).map(c => c.id),
});
this.router.navigate(['generator']);
}

View File

@ -25,7 +25,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
}
async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
this.cipherId = params.cipherId;
await this.init();
if (queryParamsSub != null) {

View File

@ -73,7 +73,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
async ngOnInit() {
this.searchTypeSearch = !this.platformUtilsService.isSafari();
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (this.applySavedState) {
this.state = (await this.stateService.get<any>(ComponentId)) || {};
if (this.state.searchText) {
@ -104,7 +104,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
default:
break;
}
await this.load((c) => c.type === this.type);
await this.load(c => c.type === this.type);
} else if (params.folderId) {
this.folderId = params.folderId === 'none' ? null : params.folderId;
this.searchPlaceholder = this.i18nService.t('searchFolder');
@ -118,7 +118,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
} else {
this.groupingTitle = this.i18nService.t('noneFolder');
}
await this.load((c) => c.folderId === this.folderId);
await this.load(c => c.folderId === this.folderId);
} else if (params.collectionId) {
this.collectionId = params.collectionId;
this.searchPlaceholder = this.i18nService.t('searchCollection');
@ -128,7 +128,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
this.nestedCollections = collectionNode.children != null && collectionNode.children.length > 0 ?
collectionNode.children : null;
}
await this.load((c) => c.collectionIds != null && c.collectionIds.indexOf(this.collectionId) > -1);
await this.load(c => c.collectionIds != null && c.collectionIds.indexOf(this.collectionId) > -1);
} else {
this.groupingTitle = this.i18nService.t('allItems');
await this.load();

View File

@ -24,7 +24,7 @@ export class CollectionsComponent extends BaseCollectionsComponent {
this.onSavedCollections.subscribe(() => {
this.back();
});
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
this.cipherId = params.cipherId;
await this.load();
if (queryParamsSub != null) {

View File

@ -212,7 +212,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
this.cardCiphers = [];
this.identityCiphers = [];
ciphers.forEach((c) => {
ciphers.forEach(c => {
switch (c.type) {
case CipherType.Login:
this.loginCiphers.push(c);

View File

@ -112,7 +112,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
});
const restoredScopeState = await this.restoreState();
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
this.state = (await this.stateService.get<any>(ComponentId)) || {};
if (this.state.searchText) {
this.searchText = this.state.searchText;
@ -167,7 +167,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
if (!this.hasLoadedAllCiphers) {
this.hasLoadedAllCiphers = !this.searchService.isSearchable(this.searchText);
}
this.deletedCount = this.allCiphers.filter((c) => c.isDeleted).length;
this.deletedCount = this.allCiphers.filter(c => c.isDeleted).length;
await this.search(null);
let favoriteCiphers: CipherView[] = null;
let noFolderCiphers: CipherView[] = null;
@ -175,7 +175,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
const collectionCounts = new Map<string, number>();
const typeCounts = new Map<CipherType, number>();
this.ciphers.forEach((c) => {
this.ciphers.forEach(c => {
if (c.isDeleted) {
return;
}
@ -206,7 +206,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
}
if (c.collectionIds != null) {
c.collectionIds.forEach((colId) => {
c.collectionIds.forEach(colId => {
if (collectionCounts.has(colId)) {
collectionCounts.set(colId, collectionCounts.get(colId) + 1);
} else {

View File

@ -22,7 +22,7 @@ export class PasswordHistoryComponent extends BasePasswordHistoryComponent {
}
async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (params.cipherId) {
this.cipherId = params.cipherId;
} else {

View File

@ -29,7 +29,7 @@ export class ShareComponent extends BaseShareComponent {
this.onSharedCipher.subscribe(() => {
this.router.navigate(['view-cipher', { cipherId: this.cipherId }]);
});
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
this.cipherId = params.cipherId;
await this.load();
if (queryParamsSub != null) {

View File

@ -57,7 +57,7 @@ export class ViewComponent extends BaseViewComponent {
ngOnInit() {
this.inPopout = this.popupUtilsService.inPopout(window);
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
const queryParamsSub = this.route.queryParams.subscribe(async params => {
if (params.cipherId) {
this.cipherId = params.cipherId;
} else {
@ -155,7 +155,7 @@ export class ViewComponent extends BaseViewComponent {
if (this.cipher.login.uris == null) {
this.cipher.login.uris = [];
} else {
if (this.cipher.login.uris.some((uri) => uri.uri === this.tab.url)) {
if (this.cipher.login.uris.some(uri => uri.uri === this.tab.url)) {
this.platformUtilsService.showToast('success', null,
this.i18nService.t('autoFillSuccessAndSavedUri'));
return;

View File

@ -16,12 +16,13 @@ export default class VaultTimeoutService extends BaseVaultTimeoutService {
// setIntervals. It works by calling the native extension which sleeps for 10s,
// efficiently replicating setInterval.
async checkSafari() {
while(true) {
while (true) {
try {
await SafariApp.sendMessageToApp('sleep');
this.checkVaultTimeout();
} catch(e) {
console.log("Exception Safari VaultTimeout", e);
} catch (e) {
// tslint:disable-next-line
console.log('Exception Safari VaultTimeout', e);
}
}
}