From 3dca6d07ba376eaaee7c712b9fd29f727a875aee Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Sat, 5 Sep 2020 01:30:02 +0200 Subject: [PATCH] [frontend] Fix linter issues --- kibicara-frontend/angular.json | 2 +- .../src/app/auth/confirm/confirm.component.ts | 2 +- .../src/app/auth/login/login.component.ts | 5 ++--- .../app/auth/register/register.component.ts | 2 +- .../src/app/core/auth/error.interceptor.ts | 8 ++++---- .../src/app/dashboard/board/board.component.ts | 2 +- .../src/app/hoodpage/hoodpage.component.ts | 2 +- .../telegram-settings.component.ts | 2 +- .../twitter-callback.component.ts | 18 +++++++++--------- .../app/shared/toolbar/toolbar.component.ts | 2 +- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/kibicara-frontend/angular.json b/kibicara-frontend/angular.json index 291bd8d..d400f3c 100644 --- a/kibicara-frontend/angular.json +++ b/kibicara-frontend/angular.json @@ -107,7 +107,7 @@ "tsconfig.spec.json", "e2e/tsconfig.json" ], - "exclude": ["**/node_modules/**"] + "exclude": ["**/node_modules/**", "src/app/core/api/**"] } }, "e2e": { diff --git a/kibicara-frontend/src/app/auth/confirm/confirm.component.ts b/kibicara-frontend/src/app/auth/confirm/confirm.component.ts index 73400c6..3c4cf21 100644 --- a/kibicara-frontend/src/app/auth/confirm/confirm.component.ts +++ b/kibicara-frontend/src/app/auth/confirm/confirm.component.ts @@ -16,7 +16,7 @@ export class ConfirmComponent implements OnInit { ) {} ngOnInit(): void { - const token = this.route.snapshot.queryParams['token']; + const token = this.route.snapshot.queryParams.token; if (token) { this.adminService .confirm(token) diff --git a/kibicara-frontend/src/app/auth/login/login.component.ts b/kibicara-frontend/src/app/auth/login/login.component.ts index ce98403..539a751 100644 --- a/kibicara-frontend/src/app/auth/login/login.component.ts +++ b/kibicara-frontend/src/app/auth/login/login.component.ts @@ -34,10 +34,9 @@ export class LoginComponent implements OnInit { email: ['', Validators.required], password: ['', Validators.required], }); - this.returnUrl = - this.route.snapshot.queryParams['returnUrl'] || '/dashboard'; + this.returnUrl = this.route.snapshot.queryParams.returnUrl || '/dashboard'; - if (this.route.snapshot.queryParams['registered'] === true) { + if (this.route.snapshot.queryParams.registered === true) { this.snackBar.open('Registration successful', 'Close', { duration: 2000, }); diff --git a/kibicara-frontend/src/app/auth/register/register.component.ts b/kibicara-frontend/src/app/auth/register/register.component.ts index f9c9aab..8d70d73 100644 --- a/kibicara-frontend/src/app/auth/register/register.component.ts +++ b/kibicara-frontend/src/app/auth/register/register.component.ts @@ -35,7 +35,7 @@ export class RegisterComponent implements OnInit { password: ['', [Validators.required, Validators.minLength(8)]], }); - if (this.route.snapshot.queryParams['error']) { + if (this.route.snapshot.queryParams.error) { this.snackBar.open( 'Invalid confirmation link. Try registering again', 'Close', diff --git a/kibicara-frontend/src/app/core/auth/error.interceptor.ts b/kibicara-frontend/src/app/core/auth/error.interceptor.ts index 555e834..4fa8e08 100644 --- a/kibicara-frontend/src/app/core/auth/error.interceptor.ts +++ b/kibicara-frontend/src/app/core/auth/error.interceptor.ts @@ -18,7 +18,7 @@ export class ErrorInterceptor implements HttpInterceptor { constructor( private loginService: LoginService, private router: Router, - private _snackBar: MatSnackBar + private snackBar: MatSnackBar ) {} intercept( @@ -30,15 +30,15 @@ export class ErrorInterceptor implements HttpInterceptor { if (err.error instanceof ProgressEvent) { // TODO Add spinner/overlay in app to prevent user input console.log('Networkerror'); - this._snackBar.openFromComponent(OverlayComponent, { + this.snackBar.openFromComponent(OverlayComponent, { verticalPosition: 'top', }); - setTimeout(function () { + setTimeout(() => { window.location.reload(); }, 20000); } else if (err.status === 401) { this.loginService.logout(); - location.reload(true); + location.reload(); } else if (err.status === 404) { this.router.navigate(['/404']); } diff --git a/kibicara-frontend/src/app/dashboard/board/board.component.ts b/kibicara-frontend/src/app/dashboard/board/board.component.ts index a746e90..f7ceb0f 100644 --- a/kibicara-frontend/src/app/dashboard/board/board.component.ts +++ b/kibicara-frontend/src/app/dashboard/board/board.component.ts @@ -19,7 +19,7 @@ export class BoardComponent implements OnInit { ) {} ngOnInit(): void { - this.hoodId = this.route.snapshot.params['id']; + this.hoodId = this.route.snapshot.params.id; this.hood$ = this.hoodService.getHood(this.hoodId); } } diff --git a/kibicara-frontend/src/app/hoodpage/hoodpage.component.ts b/kibicara-frontend/src/app/hoodpage/hoodpage.component.ts index c82879a..1fbb3f3 100644 --- a/kibicara-frontend/src/app/hoodpage/hoodpage.component.ts +++ b/kibicara-frontend/src/app/hoodpage/hoodpage.component.ts @@ -19,7 +19,7 @@ export class HoodpageComponent implements OnInit { ) {} ngOnInit(): void { - this.hoodId = this.route.snapshot.params['id']; + this.hoodId = this.route.snapshot.params.id; if (this.hoodId) { this.hoodsService .getHood(this.hoodId) diff --git a/kibicara-frontend/src/app/platforms/telegram/telegram-settings/telegram-settings.component.ts b/kibicara-frontend/src/app/platforms/telegram/telegram-settings/telegram-settings.component.ts index 6d1596c..fe9be0b 100644 --- a/kibicara-frontend/src/app/platforms/telegram/telegram-settings/telegram-settings.component.ts +++ b/kibicara-frontend/src/app/platforms/telegram/telegram-settings/telegram-settings.component.ts @@ -66,7 +66,7 @@ export class TelegramSettingsComponent implements OnInit { onEdit(telegramId) { const dialogRef = this.dialog.open(TelegramDialogComponent, { - data: { hoodId: this.hoodId, telegramId: telegramId }, + data: { hoodId: this.hoodId, telegramId }, }); dialogRef.afterClosed().subscribe(() => { diff --git a/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts index fdfdc16..47f28a0 100644 --- a/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts +++ b/kibicara-frontend/src/app/platforms/twitter/twitter-callback/twitter-callback.component.ts @@ -16,28 +16,28 @@ export class TwitterCallbackComponent implements OnInit { ngOnInit(): void { if ( - this.route.snapshot.queryParams['hood'] && - this.route.snapshot.queryParams['oauth_token'] && - this.route.snapshot.queryParams['oauth_verifier'] + this.route.snapshot.queryParams.hood && + this.route.snapshot.queryParams.oauth_token && + this.route.snapshot.queryParams.oauth_verifier ) { this.twitterService .callbackTwitter( - this.route.snapshot.queryParams['oauth_token'], - this.route.snapshot.queryParams['oauth_verifier'] + this.route.snapshot.queryParams.oauth_token, + this.route.snapshot.queryParams.oauth_verifier ) .subscribe(() => { this.router.navigate([ '/dashboard/hoods', - this.route.snapshot.queryParams['hood'], + this.route.snapshot.queryParams.hood, ]); }); } else if ( - this.route.snapshot.queryParams['hood'] && - this.route.snapshot.queryParams['denied'] + this.route.snapshot.queryParams.hood && + this.route.snapshot.queryParams.denied ) { this.router.navigate([ '/dashboard/hoods', - this.route.snapshot.queryParams['hood'], + this.route.snapshot.queryParams.hood, ]); } else { this.router.navigate(['/404']); diff --git a/kibicara-frontend/src/app/shared/toolbar/toolbar.component.ts b/kibicara-frontend/src/app/shared/toolbar/toolbar.component.ts index 8fa79f1..5640cde 100644 --- a/kibicara-frontend/src/app/shared/toolbar/toolbar.component.ts +++ b/kibicara-frontend/src/app/shared/toolbar/toolbar.component.ts @@ -14,7 +14,7 @@ export class ToolbarComponent implements OnInit { authenticated = false; constructor(private loginService: LoginService, private router: Router) { - this.router.routeReuseStrategy.shouldReuseRoute = function () { + this.router.routeReuseStrategy.shouldReuseRoute = () => { return false; };