Configure ESLint with deprecation checking and fix all lint violations

This commit is contained in:
nessar committed 2026-08-17 14:18:14 +02:00
1 parent bdc2e1bc57
commit fd2019e3cd
8 files changed
+331 -48

No files matched your search

+17 -22
View File
@@ -1,4 +1,4 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners, APP_INITIALIZER } from '@angular/core';
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideAppInitializer, inject } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient } from '@angular/common/http';
import { provideOAuthClient, OAuthService } from 'angular-oauth2-oidc';
@@ -6,32 +6,27 @@ import { provideOAuthClient, OAuthService } from 'angular-oauth2-oidc';
import { routes } from './app.routes';
import { ConfigService } from './config.service';
export function initializeApp(configService: ConfigService, oauthService: OAuthService) {
return () => configService.loadConfig().then(() => {
oauthService.configure({
issuer: configService.oidcIssuer,
redirectUri: window.location.origin + '/',
clientId: configService.clientId,
responseType: 'code',
scope: 'openid profile email',
showDebugInformation: true,
requireHttps: false
});
return oauthService.loadDiscoveryDocumentAndTryLogin();
});
}
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes),
provideHttpClient(),
provideOAuthClient(),
{
provide: APP_INITIALIZER,
useFactory: initializeApp,
deps: [ConfigService, OAuthService],
multi: true
}
provideAppInitializer(() => {
const configService = inject(ConfigService);
const oauthService = inject(OAuthService);
return configService.loadConfig().then(() => {
oauthService.configure({
issuer: configService.oidcIssuer,
redirectUri: window.location.origin + '/',
clientId: configService.clientId,
responseType: 'code',
scope: 'openid profile email',
showDebugInformation: true,
requireHttps: false
});
return oauthService.loadDiscoveryDocumentAndTryLogin();
});
})
]
};
+3 -4
View File
@@ -14,8 +14,8 @@ describe('App', () => {
hasValidAccessToken: () => false,
getIdentityClaims: () => null,
getAccessToken: () => 'mock-token',
initCodeFlow: () => {},
logOut: () => {}
initCodeFlow: vi.fn(),
revokeTokenAndLogout: vi.fn()
};
mockHttpClient = {
@@ -77,7 +77,7 @@ describe('App', () => {
const app = fixture.componentInstance;
const loginSpy = vi.spyOn(mockOAuthService, 'initCodeFlow');
const logoutSpy = vi.spyOn(mockOAuthService, 'logOut');
const logoutSpy = vi.spyOn(mockOAuthService, 'revokeTokenAndLogout');
app.login();
expect(loginSpy).toHaveBeenCalled();
@@ -106,7 +106,6 @@ describe('App', () => {
it('should render logged in state when user is authenticated', async () => {
const fixture = TestBed.createComponent(App);
const app = fixture.componentInstance;
// Log in
mockOAuthService.hasValidAccessToken = () => true;
+8 -7
View File
@@ -1,4 +1,4 @@
import { Component, signal } from '@angular/core';
import { Component, signal, inject } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@@ -12,21 +12,22 @@ export class App {
protected readonly title = signal('LMNP Organizer');
readonly helloMessage = signal<string>('');
constructor(private oauthService: OAuthService, private http: HttpClient) {}
private readonly oauthService = inject(OAuthService);
private readonly http = inject(HttpClient);
get isLoggedIn(): boolean {
return this.oauthService.hasValidAccessToken();
}
get username(): string {
const claims: any = this.oauthService.getIdentityClaims();
const claims = this.oauthService.getIdentityClaims() as Record<string, string> | null;
if (!claims) return '';
return claims.preferred_username || claims.given_name || claims.name || 'User';
return claims['preferred_username'] || claims['given_name'] || claims['name'] || 'User';
}
get email(): string {
const claims: any = this.oauthService.getIdentityClaims();
return claims?.email || '';
const claims = this.oauthService.getIdentityClaims() as Record<string, string> | null;
return claims ? claims['email'] : '';
}
login() {
@@ -34,7 +35,7 @@ export class App {
}
logout() {
this.oauthService.logOut();
this.oauthService.revokeTokenAndLogout();
}
callHelloApi() {
+6 -7
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { lastValueFrom } from 'rxjs';
@@ -6,13 +6,12 @@ import { lastValueFrom } from 'rxjs';
providedIn: 'root'
})
export class ConfigService {
private config: any = null;
constructor(private http: HttpClient) {}
private config: Record<string, string> | null = null;
private readonly http = inject(HttpClient);
async loadConfig(): Promise<void> {
try {
this.config = await lastValueFrom(this.http.get('/config.json'));
this.config = await lastValueFrom(this.http.get('/config.json')) as Record<string, string>;
} catch (e) {
console.warn('Could not load /config.json, using default dev values', e);
this.config = {
@@ -23,10 +22,10 @@ export class ConfigService {
}
get oidcIssuer(): string {
return this.config?.oidcIssuer || 'http://localhost:8090/realms/voidAuth';
return this.config ? this.config['oidcIssuer'] : 'http://localhost:8090/realms/voidAuth';
}
get clientId(): string {
return this.config?.clientId || 'lmnp-client';
return this.config ? this.config['clientId'] : 'lmnp-client';
}
}