diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..b41a1ab --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +src/test.ts diff --git a/.eslintrc.json b/.eslintrc.json index a25e093..f72a528 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,6 +19,8 @@ "createDefaultProgram": true }, "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:@angular-eslint/all", "plugin:@angular-eslint/recommended--extra", "plugin:@angular-eslint/template/process-inline-templates" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3021b72..da14ba8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,15 +24,10 @@ build: paths: - dist/angular -lint: - stage: test - script: - - pnpm run lint - test: stage: test script: - - pnpm run test + - pnpm run lint pages: stage: deploy diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 16cfd97..c557849 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -4,7 +4,7 @@ import { AppComponent } from './app.component' describe('AppComponent', (): void => { beforeEach(waitForAsync((): void => { - TestBed.configureTestingModule({ + void TestBed.configureTestingModule({ imports: [ RouterTestingModule, ], @@ -19,7 +19,7 @@ describe('AppComponent', (): void => { if (!(fixture.debugElement.componentInstance instanceof AppComponent)) throw new Error("Expected AppComponent") const app: AppComponent = fixture.debugElement.componentInstance - expect(app).toBeTruthy() + void expect(app).toBeTruthy() }) it(`should have a themeService`, (): void => { @@ -27,7 +27,7 @@ describe('AppComponent', (): void => { if (!(fixture.debugElement.componentInstance instanceof AppComponent)) throw new Error("Expected AppComponent") const app: AppComponent = fixture.debugElement.componentInstance - expect(app.themeService).toBeTruthy() + void expect(app.themeService).toBeTruthy() }) it('should render title', (): void => { @@ -36,10 +36,10 @@ describe('AppComponent', (): void => { if (!isHTMLElement(fixture.debugElement.nativeElement)) throw new Error("Expected HTMLElement") const compiled: HTMLElement = fixture.debugElement.nativeElement - expect(compiled.querySelector('h1')?.textContent).toContain('Public Gateway Cacher') + void expect(compiled.querySelector('h1')?.textContent).toContain('Public Gateway Cacher') }) }) -function isHTMLElement(element: any): element is HTMLElement { - return element.__proto__ instanceof HTMLElement +function isHTMLElement(element: unknown): element is HTMLElement { + return Object.getPrototypeOf(element) instanceof HTMLElement } diff --git a/src/app/pages/pages.component.spec.ts b/src/app/pages/pages.component.spec.ts index 8a48c70..ea3e8fb 100644 --- a/src/app/pages/pages.component.spec.ts +++ b/src/app/pages/pages.component.spec.ts @@ -8,7 +8,7 @@ describe('PagesComponent', (): void => { let fixture: ComponentFixture beforeEach(waitForAsync((): void => { - TestBed.configureTestingModule({ + void TestBed.configureTestingModule({ imports: [HttpClientTestingModule], declarations: [PagesComponent] }) @@ -22,6 +22,6 @@ describe('PagesComponent', (): void => { }) it('should create', (): void => { - expect(component).toBeTruthy() + void expect(component).toBeTruthy() }) }) diff --git a/src/app/services/gateway.service.spec.ts b/src/app/services/gateway.service.spec.ts index 6d720d1..ad98090 100644 --- a/src/app/services/gateway.service.spec.ts +++ b/src/app/services/gateway.service.spec.ts @@ -10,6 +10,6 @@ describe('GatewayService', (): void => { it('should be created', (): void => { const service: GatewayService = TestBed.inject(GatewayService) - expect(service).toBeTruthy() + void expect(service).toBeTruthy() }) }) diff --git a/src/app/services/gateway.service.ts b/src/app/services/gateway.service.ts index 6e7e55f..8e13f52 100644 --- a/src/app/services/gateway.service.ts +++ b/src/app/services/gateway.service.ts @@ -18,7 +18,7 @@ export class GatewayService { return this.http.get( environment.base_href && environment.base_href !== '/' ? `${environment.base_href}/assets/json/gateways.json` - : `${document.querySelector('base')?.href}assets/json/gateways.json` + : `${document.querySelector('base')?.href ?? ''}assets/json/gateways.json` ) } diff --git a/src/app/services/theme.service.spec.ts b/src/app/services/theme.service.spec.ts index 4e18c54..cd45cfa 100644 --- a/src/app/services/theme.service.spec.ts +++ b/src/app/services/theme.service.spec.ts @@ -10,6 +10,6 @@ describe('ThemeService', (): void => { }) it('should be created', (): void => { - expect(service).toBeTruthy() + void expect(service).toBeTruthy() }) }) diff --git a/src/polyfills.ts b/src/polyfills.ts index 13e0ea4..efb1a13 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -45,8 +45,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js'; // Included with Angular CLI. - +import 'zone.js' // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS diff --git a/src/test.ts b/src/test.ts index 0caaca2..76682db 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,8 +1,8 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ // This file is required by karma.conf.js and loads recursively all the .spec and framework files +import 'zone.js/testing' + import { getTestBed } from '@angular/core/testing' import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing' -import 'zone.js/testing' declare const require: any