Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable strict + remove ESLint exceptions AB#17794 #1456

Merged
merged 11 commits into from
Sep 18, 2023
Merged
12 changes: 6 additions & 6 deletions interfaces/IBF-dashboard/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@angular-eslint/no-empty-lifecycle-method": "off",
"@angular-eslint/component-class-suffix": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-empty-function": "off"
"@angular-eslint/component-class-suffix": [
"error",
{
"suffixes": ["Page", "Component"]
}
]
}
},
{
Expand Down
16 changes: 11 additions & 5 deletions interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CountryService } from '../services/country.service';
providedIn: 'root',
})
export class AnalyticsService {
private log = DEBUG_LOG ? console.log : () => {};
private log = DEBUG_LOG ? console.log : () => undefined;

applicationInsights: ApplicationInsights;
isApplicationInsightsEnabled: boolean;
Expand Down Expand Up @@ -66,11 +66,14 @@ export class AnalyticsService {
}
}

logError(error: any, severityLevel?: SeverityLevel): void {
logError(error: Error, severityLevel?: SeverityLevel): void {
this.displayOnConsole(error, severityLevel);
}

logEvent(name: string, properties?: { [key: string]: any }): void {
logEvent(
name: string,
properties?: { [key: string]: string | number | boolean },
): void {
if (this.isApplicationInsightsEnabled) {
this.applicationInsights.trackEvent({ name }, properties);
} else {
Expand All @@ -89,7 +92,10 @@ export class AnalyticsService {
}
}

logTrace(message: string, properties?: { [key: string]: any }) {
logTrace(
message: string,
properties?: { [key: string]: string | number | boolean },
) {
if (this.isApplicationInsightsEnabled) {
this.applicationInsights.trackTrace({ message }, properties);
} else {
Expand All @@ -98,7 +104,7 @@ export class AnalyticsService {
}

private displayOnConsole(
error: any,
error: Error,
severityLevel: SeverityLevel = SeverityLevel.Error,
) {
switch (severityLevel) {
Expand Down
2 changes: 1 addition & 1 deletion interfaces/IBF-dashboard/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AppComponent implements OnDestroy {
initializeApp() {
this.translateService.setDefaultLang(this.defaultLanguage);
this.translateService.use(this.defaultLanguage);
this.platform.ready().then(() => {});
this.platform.ready();
}

ngOnDestroy() {
Expand Down
1 change: 1 addition & 0 deletions interfaces/IBF-dashboard/src/app/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class AuthGuard implements CanActivate {

checkLogin(url: string, route: ActivatedRouteSnapshot): boolean {
if (this.authService.isLoggedIn()) {
console.log('route: ', route);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion interfaces/IBF-dashboard/src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class AuthService implements OnDestroy {
.subscribe(this.onPasswordChanged, this.onChangePasswordError);
}

private onPasswordChanged = async (res) => {
private onPasswordChanged = async () => {
const toast = await this.toastController.create({
message: `Password changed successfully`,
duration: 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { PlaceCodeService } from 'src/app/services/place-code.service';
import { EventState } from 'src/app/types/event-state';
import { AnalyticsEvent, AnalyticsPage } from '../../analytics/analytics.enum';
import { AnalyticsService } from '../../analytics/analytics.service';
import { AreaOfFocus } from '../../types/area-of-focus';
import { TriggeredArea } from '../../types/triggered-area';
import { LayerControlInfoPopoverComponent } from '../layer-control-info-popover/layer-control-info-popover.component';

@Component({
Expand All @@ -22,8 +24,8 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy {
private initialEventStateSubscription: Subscription;
private manualEventStateSubscription: Subscription;

public areasOfFocus: any[];
public triggeredAreas: any[];
public areasOfFocus: AreaOfFocus[];
public triggeredAreas: TriggeredArea[];
public trigger: boolean;
public eventState: EventState;

Expand Down Expand Up @@ -62,7 +64,7 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy {
this.manualEventStateSubscription.unsubscribe();
}

private onTriggeredAreasChange = (triggeredAreas) => {
private onTriggeredAreasChange = (triggeredAreas: TriggeredArea[]) => {
this.triggeredAreas = triggeredAreas;
this.calculateEAPActionStatus(this.triggeredAreas);
};
Expand Down Expand Up @@ -100,14 +102,14 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy {
};

private calculateEAPActionStatus(triggeredAreas): void {
const onEachAreaOfFocus = (areaOfFocus) => {
const onEachAreaOfFocus = (areaOfFocus: AreaOfFocus) => {
areaOfFocus.count = 0;
areaOfFocus.countChecked = 0;
// Look at each triggered area ..
triggeredAreas.forEach(this.onEachTriggeredArea(areaOfFocus));
};

const onAreasOfFocusChange = (areasOfFocus) => {
const onAreasOfFocusChange = (areasOfFocus: AreaOfFocus[]) => {
this.areasOfFocus = areasOfFocus;

// Start calculation only when last area has eapActions attached to it
Expand All @@ -128,7 +130,7 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy {
this.eventState = eventState;
};

public async moreInfo(areaOfFocus: any): Promise<void> {
public async moreInfo(areaOfFocus: AreaOfFocus): Promise<void> {
const { id, label, description } = areaOfFocus;

const popover = await this.popoverController.create({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { PopoverController } from '@ionic/angular';
import { AuthService } from 'src/app/auth/auth.service';
Expand All @@ -8,7 +8,7 @@ import { AuthService } from 'src/app/auth/auth.service';
templateUrl: './change-password-popover.component.html',
styleUrls: ['./change-password-popover.component.scss'],
})
export class ChangePasswordPopoverComponent implements OnInit {
export class ChangePasswordPopoverComponent {
@ViewChild('changePasswordForm')
public changePasswordForm: NgForm;

Expand All @@ -24,8 +24,6 @@ export class ChangePasswordPopoverComponent implements OnInit {
private popoverController: PopoverController,
) {}

ngOnInit() {}

public onSubmit() {
if (!this.changePasswordForm.form.valid) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
</app-dialogue-turn>
</ng-container>
<app-dialogue-turn
actor="self"
[actor]="actor.self"
*ngFor="let area of filteredActiveAreas; first as isFirst"
[isConnected]="!isFirst"
[isTriggered]="eventState?.event?.thresholdReached"
Expand Down Expand Up @@ -276,7 +276,7 @@
changeAction(
area.placeCode,
action.action,
$event.detail.checked
$event['detail']['checked']
)
"
></ion-checkbox>
Expand Down
13 changes: 10 additions & 3 deletions interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { EventState } from 'src/app/types/event-state';
import { TimelineState } from 'src/app/types/timeline-state';
import { AggregatesService } from '../../services/aggregates.service';
import { TimelineService } from '../../services/timeline.service';
import { Actor } from '../../types/chat';
import { Indicator } from '../../types/indicator-group';
import { LeadTimeTriggerKey, LeadTimeUnit } from '../../types/lead-time';
import { TriggeredArea } from '../../types/triggered-area';
Expand Down Expand Up @@ -78,6 +79,8 @@ export class ChatComponent implements OnInit, OnDestroy {
private lastModelRunDateFormat = 'cccc, dd LLLL HH:mm';
public isWarn = false;

public actor = Actor;

constructor(
private eapActionsService: EapActionsService,
public authService: AuthService,
Expand Down Expand Up @@ -546,9 +549,13 @@ export class ChatComponent implements OnInit, OnDestroy {
const prefixKey = 'prefix';
const prefix = this.disasterTypeSettings.monthlyForecastInfo[prefixKey];

return this.disasterTypeSettings.monthlyForecastInfo[
currentMonth
].map((forecast) =>
const currentMonthforecastInfo = this.disasterTypeSettings
.monthlyForecastInfo[currentMonth];
if (typeof currentMonthforecastInfo === 'string') {
return [];
}

return currentMonthforecastInfo.map((forecast) =>
this.translateService.instant(`${prefix}.${forecast}`),
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { DateTime } from 'luxon';

enum Actor {
system = 'system',
self = 'self',
}
import { Actor } from '../../types/chat';

@Component({
selector: 'app-dialogue-turn',
Expand Down Expand Up @@ -49,8 +45,6 @@ export class DialogueTurnComponent implements OnInit {

animate = false;

constructor() {}

ngOnInit() {
this.isSelf = this.actor === Actor.self;
this.isSystem = this.actor === Actor.system;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ import { environment } from '../../../environments/environment';
})
export class DisclaimerToolbarComponent {
public environmentConfiguration = environment.configuration;

constructor() {}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<app-dialogue-turn
*ngIf="type === 'active'"
isConnected="true"
[isConnected]="true"
[isTriggered]="event.thresholdReached"
[isNotTriggered]="!event.thresholdReached"
[isSelected]="eventBubbleIsSelected(event.eventName)"
isConnected="true"
[isConnected]="true"
>
<ng-container *ngIf="event.activeTrigger && event.thresholdReached">
<span>
Expand Down Expand Up @@ -190,9 +190,9 @@

<app-dialogue-turn
*ngIf="type === 'stopped' && event.eventName === selectedEvent"
isConnected="true"
isStopped="true"
isConnected="true"
[isConnected]="true"
[isStopped]="true"
[isConnected]="true"
>
<ng-container>
<p
Expand Down Expand Up @@ -234,7 +234,7 @@
</ng-container>
</app-dialogue-turn>

<app-dialogue-turn *ngIf="type === 'old'" isConnected="true">
<app-dialogue-turn *ngIf="type === 'old'" [isConnected]="true">
<p
[innerHTML]="
'chat-component.' + disasterTypeName + '.active-event-no-trigger.welcome'
Expand All @@ -254,7 +254,7 @@
></p>
</app-dialogue-turn>

<app-dialogue-turn *ngIf="type === 'no-event'" isConnected="true">
<app-dialogue-turn *ngIf="type === 'no-event'" [isConnected]="true">
<p
[innerHTML]="
'chat-component.' + disasterTypeName + '.no-event-no-trigger.welcome'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { PopoverController } from '@ionic/angular';
import { environment } from 'src/environments/environment';

Expand All @@ -7,13 +7,11 @@ import { environment } from 'src/environments/environment';
templateUrl: './forgot-password-popover.component.html',
styleUrls: ['./forgot-password-popover.component.scss'],
})
export class ForgotPasswordPopoverComponent implements OnInit {
export class ForgotPasswordPopoverComponent {
public emailAddress = environment.supportEmailAddress;

constructor(private popoverController: PopoverController) {}

ngOnInit() {}

public closePopover(): void {
this.popoverController.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export class IbfButtonComponent implements OnInit {

public style = '';

constructor() {}

ngOnInit() {
this.style += `
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import { Component } from '@angular/core';
templateUrl: './map-controls.component.html',
styleUrls: ['./map-controls.component.scss'],
})
export class MapControlsComponent {
constructor() {}
}
export class MapControlsComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class MapComponent implements AfterViewInit, OnDestroy {
let zoomExtraOffset: number;
if (this.placeCode) {
adminRegionsFiltered.features = adminRegionsLayer.data?.features.filter(
(area) => area?.properties?.placeCode === this.placeCode,
(area) => area?.properties?.['placeCode'] === this.placeCode,
);
zoomExtraOffset = 0.1;
} else {
Expand Down Expand Up @@ -750,7 +750,7 @@ export class MapComponent implements AfterViewInit, OnDestroy {
feature,
): string {
feature = activeAggregateLayer.data?.features.find(
(f) => f.properties?.placeCode === feature.properties.placeCode,
(f) => f.properties?.['placeCode'] === feature.properties.placeCode,
);
return (
'<strong>' +
Expand Down Expand Up @@ -857,10 +857,10 @@ export class MapComponent implements AfterViewInit, OnDestroy {
const dates = layer.data?.features
.filter(
(f) =>
DateTime.fromISO(f.properties?.timestampOfTrackpoint) <=
DateTime.fromISO(f.properties?.['timestampOfTrackpoint']) <=
DateTime.fromISO(this.lastModelRunDate),
)
.map((t) => DateTime.fromISO(t.properties?.timestampOfTrackpoint));
.map((t) => DateTime.fromISO(t.properties?.['timestampOfTrackpoint']));

this.closestPointToTyphoon = Math.max.apply(null, dates);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class MatrixComponent implements OnDestroy {
}
};

async presentPopover(event: any, layer: IbfLayer): Promise<void> {
async presentPopover(event: Event, layer: IbfLayer): Promise<void> {
event.stopPropagation();

const popover = await this.popoverController.create({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { PopoverController } from '@ionic/angular';

@Component({
selector: 'app-screen-orientation-popover',
templateUrl: './screen-orientation-popover.component.html',
styleUrls: ['./screen-orientation-popover.component.scss'],
})
export class ScreenOrientationPopoverComponent implements OnInit {
export class ScreenOrientationPopoverComponent {
@Input()
public device: string;

constructor(private popoverController: PopoverController) {}

ngOnInit() {}

public closePopover(): void {
this.popoverController.dismiss();
}
Expand Down
Loading
Loading