1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +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 { Component } from '@angular/core';
import { ConstantsService } from 'jslib/services/constants.service'; import { ConstantsService } from 'jslib/services/constants.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service'; import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service'; import { StorageService } from 'jslib/abstractions/storage.service';
import { Utils } from 'jslib/misc/utils'; 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 { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib/angular/components/two-factor.component';
import { PopupUtilsService } from '../services/popup-utils.service'; import { PopupUtilsService } from '../services/popup-utils.service';
import { BrowserApi } from '../../browser/browserApi'; import { BrowserApi } from '../../browser/browserApi';
const BroadcasterSubscriptionId = 'TwoFactorComponent'; 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') { if (qParams.sso === 'true') {
super.onSuccessfulLogin = () => { super.onSuccessfulLogin = () => {
BrowserApi.reloadOpenWindows(); BrowserApi.reloadOpenWindows();

View File

@ -73,7 +73,7 @@ export class SendAddEditComponent extends BaseAddEditComponent {
this.inPopout = this.popupUtilsService.inPopout(window); this.inPopout = this.popupUtilsService.inPopout(window);
this.inSidebar = this.popupUtilsService.inSidebar(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) { if (params.sendId) {
this.sendId = 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 { AuthService as AuthServiceAbstraction } from 'jslib/abstractions/auth.service';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service'; import { CollectionService } from 'jslib/abstractions/collection.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { EventService } from 'jslib/abstractions/event.service'; import { EventService } from 'jslib/abstractions/event.service';
import { ExportService } from 'jslib/abstractions/export.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 BrowserMessagingService from '../../services/browserMessaging.service';
import { AuthService } from 'jslib/services/auth.service'; import { AuthService } from 'jslib/services/auth.service';
import { ConsoleLogService } from 'jslib/services/consoleLog.service';
import { ConstantsService } from 'jslib/services/constants.service'; import { ConstantsService } from 'jslib/services/constants.service';
import { SearchService } from 'jslib/services/search.service'; import { SearchService } from 'jslib/services/search.service';
import { StateService } from 'jslib/services/state.service'; import { StateService } from 'jslib/services/state.service';
import { ConsoleLogService } from 'jslib/services/consoleLog.service';
import { Analytics } from 'jslib/misc/analytics'; import { Analytics } from 'jslib/misc/analytics';
@ -93,9 +93,9 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
if (theme == null) { if (theme == null) {
theme = platformUtilsService.getDefaultSystemTheme(); theme = platformUtilsService.getDefaultSystemTheme();
platformUtilsService.onDefaultSystemThemeChange((theme) => { platformUtilsService.onDefaultSystemThemeChange(sysTheme => {
window.document.documentElement.classList.remove('theme_light', 'theme_dark'); 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); window.document.documentElement.classList.add('locale_' + i18nService.translationLocale);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ export class ViewComponent extends BaseViewComponent {
ngOnInit() { ngOnInit() {
this.inPopout = this.popupUtilsService.inPopout(window); 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) { if (params.cipherId) {
this.cipherId = params.cipherId; this.cipherId = params.cipherId;
} else { } else {
@ -155,7 +155,7 @@ export class ViewComponent extends BaseViewComponent {
if (this.cipher.login.uris == null) { if (this.cipher.login.uris == null) {
this.cipher.login.uris = []; this.cipher.login.uris = [];
} else { } 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.platformUtilsService.showToast('success', null,
this.i18nService.t('autoFillSuccessAndSavedUri')); this.i18nService.t('autoFillSuccessAndSavedUri'));
return; 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, // setIntervals. It works by calling the native extension which sleeps for 10s,
// efficiently replicating setInterval. // efficiently replicating setInterval.
async checkSafari() { async checkSafari() {
while(true) { while (true) {
try { try {
await SafariApp.sendMessageToApp('sleep'); await SafariApp.sendMessageToApp('sleep');
this.checkVaultTimeout(); this.checkVaultTimeout();
} catch(e) { } catch (e) {
console.log("Exception Safari VaultTimeout", e); // tslint:disable-next-line
console.log('Exception Safari VaultTimeout', e);
} }
} }
} }