diff --git a/src/Turnierplan.App/Client/src/app/core/directives/e2e.directive.ts b/src/Turnierplan.App/Client/src/app/core/directives/e2e.directive.ts index 02bc0c36..77cfcbe0 100644 --- a/src/Turnierplan.App/Client/src/app/core/directives/e2e.directive.ts +++ b/src/Turnierplan.App/Client/src/app/core/directives/e2e.directive.ts @@ -13,7 +13,7 @@ export class E2eDirective { return; } - this.elementRef.nativeElement.setAttribute('data-cy', E2eDirective.transformValue(value)); + this.elementRef.nativeElement.dataset.cy = E2eDirective.transformValue(value); } private static transformValue(value: string | (string | number)[]): string { diff --git a/src/Turnierplan.App/Client/src/app/core/services/authentication.service.ts b/src/Turnierplan.App/Client/src/app/core/services/authentication.service.ts index c11affbc..44ddd1be 100644 --- a/src/Turnierplan.App/Client/src/app/core/services/authentication.service.ts +++ b/src/Turnierplan.App/Client/src/app/core/services/authentication.service.ts @@ -247,14 +247,14 @@ export class AuthenticationService implements OnDestroy { const expiry = this.readAccessTokenExpiryFromLocalStorage(); // Add some clock skew to prevent race condition - return expiry === undefined || expiry * 1000 < new Date().getTime() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000; + return expiry === undefined || expiry * 1000 < Date.now() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000; } private isRefreshTokenExpired(): boolean { const expiry = this.readRefreshTokenExpiryFromLocalStorage(); // Add some clock skew to prevent race condition - return expiry === undefined || expiry * 1000 < new Date().getTime() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000; + return expiry === undefined || expiry * 1000 < Date.now() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000; } private decodeAccessToken(token: string): TurnierplanAccessToken { @@ -323,7 +323,11 @@ export class AuthenticationService implements OnDestroy { private logoutAndClearData(navigateTo?: () => void): Observable { const logout$ = this.turnierplanApi.invoke(logout).pipe( catchError(() => of(undefined)), - tap(() => AuthenticationService.allLocalStorageKeys.forEach((key) => localStorage.removeItem(key))), + tap(() => { + for (const key of AuthenticationService.allLocalStorageKeys) { + localStorage.removeItem(key); + } + }), map(() => void 0) ); diff --git a/src/Turnierplan.App/Client/src/app/portal/components/document-config-receipts/document-config-receipts.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/document-config-receipts/document-config-receipts.component.ts index 4d86d78f..7faa96fa 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/document-config-receipts/document-config-receipts.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/document-config-receipts/document-config-receipts.component.ts @@ -108,7 +108,7 @@ export class DocumentConfigReceiptsComponent extends DocumentConfigComponent +x); let newEntry = 2; - while (existingEntries.some((x) => x === newEntry)) { + while (existingEntries.includes(newEntry)) { newEntry++; } diff --git a/src/Turnierplan.App/Client/src/app/portal/components/folder-tree/folder-tree.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/folder-tree/folder-tree.component.ts index 644b4f43..df60d025 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/folder-tree/folder-tree.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/folder-tree/folder-tree.component.ts @@ -42,14 +42,18 @@ export class FolderTreeComponent { treeData.push(root); // Add all tournaments w/o folder to the root node - tournaments.filter((x) => x.folderId === undefined).forEach((tournament) => root.tournaments.push(tournament)); + for (const tournament of tournaments) { + if (tournament.folderId === undefined) { + root.tournaments.push(tournament); + } + } // Get all distinct folders const allFolders = FolderTreeComponent.detectFolders(tournaments); allFolders.sort((a, b) => a.name.localeCompare(b.name)); // Add all tournaments with folder to the corresponding folder node - allFolders.forEach((folder) => { + for (const folder of allFolders) { const folderTournaments = tournaments.filter((tournament) => tournament.folderId === folder.id); folderTournaments.sort((a, b) => a.name.localeCompare(b.name)); @@ -64,7 +68,7 @@ export class FolderTreeComponent { }; treeData.push(folderEntry); - }); + } return treeData; } diff --git a/src/Turnierplan.App/Client/src/app/portal/components/labels-select/labels-select.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/labels-select/labels-select.component.ts index 41d981db..b6057b85 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/labels-select/labels-select.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/labels-select/labels-select.component.ts @@ -26,7 +26,7 @@ export class LabelsSelectComponent { this.labelsSelected = {}; for (const label of this.availableLabels) { - this.labelsSelected[label.id] = selectedLabelIds.some((x) => x === label.id); + this.labelsSelected[label.id] = selectedLabelIds.includes(label.id); } this.isInitialized = true; diff --git a/src/Turnierplan.App/Client/src/app/portal/components/manage-applications/manage-applications.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/manage-applications/manage-applications.component.ts index 30932a5f..08fe922a 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/manage-applications/manage-applications.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/manage-applications/manage-applications.component.ts @@ -150,7 +150,7 @@ export class ManageApplicationsComponent implements OnDestroy { } protected isTeamVisible(team: ApplicationTeamDto): boolean { - return this.tournamentClassFilter.length === 0 || this.tournamentClassFilter.some((x) => x === team.tournamentClassId); + return this.tournamentClassFilter.length === 0 || this.tournamentClassFilter.includes(team.tournamentClassId); } protected getNumberOfVisibleTeams(application: ApplicationDto): number { diff --git a/src/Turnierplan.App/Client/src/app/portal/components/match-plan/match-plan.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/match-plan/match-plan.component.ts index 0f6915c7..c79e963c 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/match-plan/match-plan.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/match-plan/match-plan.component.ts @@ -97,7 +97,7 @@ export class MatchPlanComponent implements OnChanges { matches: [] }; - this.matches.forEach((match) => { + for (const match of this.matches) { this.matchCount++; const isCorrectGroup = currentGroup.title.displayName === match.type.displayName; @@ -114,7 +114,7 @@ export class MatchPlanComponent implements OnChanges { if (match.kickoff !== undefined && new Date(match.kickoff).getSeconds() !== 0) { this.showKickoffWithSeconds = true; } - }); + } this.showCourtColumn = new Set(this.matches.map((x) => x.court)).size > 1; diff --git a/src/Turnierplan.App/Client/src/app/portal/components/match-tree/match-tree.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/match-tree/match-tree.component.ts index d550a9c6..20a174bf 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/match-tree/match-tree.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/match-tree/match-tree.component.ts @@ -131,7 +131,9 @@ export class MatchTreeComponent implements OnChanges, AfterViewInit { this.columns.at(-1)!.dependencyIds.push(...dependentMatchIds); this.columns.push({ index: this.columns.length, matches: [...dependantMatches], dependencyIds: [] }); - dependantMatches.forEach((match) => includedMatchIds.push(match.id)); + for (const match of dependantMatches) { + includedMatchIds.push(match.id); + } dependantMatches = []; dependentMatchIds = []; diff --git a/src/Turnierplan.App/Client/src/app/portal/components/multi-select-filter/multi-select-filter.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/multi-select-filter/multi-select-filter.component.ts index ec99f0df..cd59b276 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/multi-select-filter/multi-select-filter.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/multi-select-filter/multi-select-filter.component.ts @@ -54,14 +54,14 @@ export class MultiSelectFilterComponent { } protected isValueSelected(value: unknown): boolean { - return this._selected.some((x) => x === value); + return this._selected.includes(value); } protected setValueSelected(value: unknown, isSelected: boolean): void { let updated = false; if (isSelected) { - if (!this._selected.some((x) => x === value)) { + if (!this._selected.includes(value)) { this._selected.push(value); updated = true; } diff --git a/src/Turnierplan.App/Client/src/app/portal/components/select-application-team/select-application-team.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/select-application-team/select-application-team.component.ts index 5a6ca369..9fd0c8d7 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/select-application-team/select-application-team.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/select-application-team/select-application-team.component.ts @@ -204,7 +204,7 @@ export class SelectApplicationTeamComponent implements OnInit, OnDestroy { } protected isTeamDisabled(id: number): boolean { - return this.usedApplicationTeamIds.some((x) => x === id); + return this.usedApplicationTeamIds.includes(id); } private emitSelectedTeams(): void { @@ -212,9 +212,6 @@ export class SelectApplicationTeamComponent implements OnInit, OnDestroy { } private isTeamVisible(team: ApplicationTeamDto): boolean { - return ( - this.applicationsFilter.tournamentClass.length === 0 || - this.applicationsFilter.tournamentClass.some((x) => x === team.tournamentClassId) - ); + return this.applicationsFilter.tournamentClass.length === 0 || this.applicationsFilter.tournamentClass.includes(team.tournamentClassId); } } diff --git a/src/Turnierplan.App/Client/src/app/portal/components/updates-check/updates-check.component.ts b/src/Turnierplan.App/Client/src/app/portal/components/updates-check/updates-check.component.ts index 633cf005..f2630731 100644 --- a/src/Turnierplan.App/Client/src/app/portal/components/updates-check/updates-check.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/components/updates-check/updates-check.component.ts @@ -48,7 +48,7 @@ export class UpdatesCheckComponent implements OnInit { try { const parsed = JSON.parse(localStorageValue) as VersionCache; const cacheExpiry = parsed.timestamp + cacheMaxAgeMilliseconds; - if (new Date().getTime() < cacheExpiry) { + if (Date.now() < cacheExpiry) { return of(parsed.version); } } catch (e) { @@ -64,7 +64,7 @@ export class UpdatesCheckComponent implements OnInit { localStorageKey, JSON.stringify({ version: version, - timestamp: new Date().getTime() + timestamp: Date.now() } as VersionCache) ); }) diff --git a/src/Turnierplan.App/Client/src/app/portal/pages/configure-tournament/configure-tournament.component.ts b/src/Turnierplan.App/Client/src/app/portal/pages/configure-tournament/configure-tournament.component.ts index 2841ee25..1cd44c71 100644 --- a/src/Turnierplan.App/Client/src/app/portal/pages/configure-tournament/configure-tournament.component.ts +++ b/src/Turnierplan.App/Client/src/app/portal/pages/configure-tournament/configure-tournament.component.ts @@ -152,9 +152,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC } protected get totalTeamCount(): number { - let count = 0; - this.groups.forEach((x) => (count += x.teams.length)); - return count; + return this.groups.reduce((sum, group) => sum + group.teams.length, 0); } protected get isGroupPhaseCourtsInvalid(): boolean { @@ -387,7 +385,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC } protected moveTeam(team: TemporaryTeam, from: TemporaryGroup, to: TemporaryGroup): void { - const index = from.teams.findIndex((x) => x === team); + const index = from.teams.indexOf(team); from.teams.splice(index, 1); to.teams.push(team); @@ -634,7 +632,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC return; } - if (!this.currentFinalRound || this.availableFinalRounds.findIndex((x) => x === this.currentFinalRound) === -1) { + if (!this.currentFinalRound || this.availableFinalRounds.indexOf(this.currentFinalRound) === -1) { this.currentFinalRound = this.availableFinalRounds[0]; } diff --git a/src/Turnierplan.App/Client/src/main.ts b/src/Turnierplan.App/Client/src/main.ts index d55a9d8e..ba645b14 100644 --- a/src/Turnierplan.App/Client/src/main.ts +++ b/src/Turnierplan.App/Client/src/main.ts @@ -23,7 +23,7 @@ const routes: Routes = [ children: [ { matcher: (url: UrlSegment[]) => - url.length > 0 && ['change-password', 'login', 'user-info'].some((x) => x === url[0].path) ? { consumed: [] } : null, + url.length > 0 && ['change-password', 'login', 'user-info'].includes(url[0].path) ? { consumed: [] } : null, title: environment.defaultTitle, loadChildren: () => import('./app/identity/identity.routes').then((m) => m.identityRoutes) },