Skip to content

Commit 0b22740

Browse files
committed
chore: Enforce eslint and fix warnings
1 parent 0769e2e commit 0b22740

11 files changed

+38
-46
lines changed

.eslintrc.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,33 @@
1616
"createDefaultProgram": true
1717
},
1818
"extends": [
19+
"eslint:recommended",
20+
"plugin:@typescript-eslint/recommended",
1921
"plugin:@angular-eslint/recommended",
2022
"plugin:@angular-eslint/template/process-inline-templates",
2123
"plugin:rxjs/recommended"
2224
],
2325
"rules": {
26+
"@typescript-eslint/explicit-function-return-type": [
27+
"error"
28+
],
29+
"no-extra-boolean-cast": [
30+
"off"
31+
],
2432
"@angular-eslint/component-selector": [
2533
"error",
2634
{
35+
"type": "element",
2736
"prefix": "",
28-
"style": "kebab-case",
29-
"type": "element"
37+
"style": "kebab-case"
3038
}
3139
],
3240
"@angular-eslint/directive-selector": [
3341
"error",
3442
{
43+
"type": "attribute",
3544
"prefix": "",
36-
"style": "camelCase",
37-
"type": "attribute"
45+
"style": "camelCase"
3846
}
3947
],
4048
"comma-dangle": [
@@ -75,7 +83,8 @@
7583
"*.html"
7684
],
7785
"extends": [
78-
"plugin:@angular-eslint/template/recommended"
86+
"plugin:@angular-eslint/template/recommended",
87+
"plugin:@angular-eslint/template/accessibility"
7988
],
8089
"rules": {}
8190
}

src/lib/components/ng-http-loader.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { Component, Input, OnInit } from '@angular/core';
10+
import { Component, Input, OnInit, Type } from '@angular/core';
1111
import { merge, Observable, partition, timer } from 'rxjs';
1212
import { debounce, distinctUntilChanged, switchMap, tap } from 'rxjs/operators';
1313
import { PendingRequestsInterceptor } from '../services/pending-requests-interceptor.service';
@@ -28,7 +28,7 @@ export class NgHttpLoaderComponent implements OnInit {
2828
@Input() backdrop = true;
2929
@Input() backgroundColor!: string;
3030
@Input() debounceDelay = 0;
31-
@Input() entryComponent: any = null;
31+
@Input() entryComponent!: Type<unknown> | null;
3232
@Input() extraDuration = 0;
3333
@Input() filteredHeaders: string[] = [];
3434
@Input() filteredMethods: string[] = [];

src/lib/services/pending-requests-interceptor.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ export class PendingRequestsInterceptor implements HttpInterceptor {
5454
});
5555
}
5656

57-
private shouldBypassMethod(req: HttpRequest<any>): boolean {
57+
private shouldBypassMethod(req: HttpRequest<unknown>): boolean {
5858
return this._filteredMethods.some(e => {
5959
return e.toUpperCase() === req.method.toUpperCase();
6060
});
6161
}
6262

63-
private shouldBypassHeader(req: HttpRequest<any>): boolean {
63+
private shouldBypassHeader(req: HttpRequest<unknown>): boolean {
6464
return this._filteredHeaders.some(e => {
6565
return req.headers.has(e);
6666
});
6767
}
6868

69-
private shouldBypass(req: HttpRequest<any>): boolean {
69+
private shouldBypass(req: HttpRequest<unknown>): boolean {
7070
return this._forceByPass
7171
|| this.shouldBypassUrl(req.urlWithParams)
7272
|| this.shouldBypassMethod(req)
7373
|| this.shouldBypassHeader(req);
7474
}
7575

76-
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
76+
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
7777
const shouldBypass = this.shouldBypass(req);
7878

7979
if (!shouldBypass) {

src/test/components/ng-http-loader.component.on-push.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { HttpClient } from '@angular/common/http';
1111
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
1212
import { ChangeDetectionStrategy, Component } from '@angular/core';
13-
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
13+
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
1414
import { By } from '@angular/platform-browser';
1515
import { NgHttpLoaderModule } from '../../lib/ng-http-loader.module';
1616

@@ -22,7 +22,6 @@ export class HostComponent {
2222
}
2323

2424
describe('NgHttpLoaderComponent OnPush', () => {
25-
let component: HostComponent;
2625
let fixture: ComponentFixture<HostComponent>;
2726
let http: HttpClient;
2827
let httpMock: HttpTestingController;
@@ -37,7 +36,6 @@ describe('NgHttpLoaderComponent OnPush', () => {
3736

3837
beforeEach(() => {
3938
fixture = TestBed.createComponent(HostComponent);
40-
component = fixture.componentInstance;
4139
http = TestBed.inject(HttpClient);
4240
httpMock = TestBed.inject(HttpTestingController);
4341
fixture.detectChanges();

src/test/components/ng-http-loader.component.outlet.spec.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
10+
import { ComponentFixture, TestBed } from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
1212
import { of } from 'rxjs';
1313
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component';
@@ -52,15 +52,6 @@ describe('NgHttpLoaderComponentOutlet', () => {
5252
expect(component.spinner).toBeNull();
5353
});
5454

55-
it('should correctly check [entryComponent] with empty string', () => {
56-
const spinnerName = 'spinner-name';
57-
component.spinner = spinnerName;
58-
component.entryComponent = '';
59-
component.ngOnInit();
60-
61-
expect(component.spinner).toBe(spinnerName);
62-
});
63-
6455
it('should correctly check [entryComponent] with null', () => {
6556
const spinnerName = 'spinner-name';
6657
component.spinner = spinnerName;
@@ -69,13 +60,4 @@ describe('NgHttpLoaderComponentOutlet', () => {
6960

7061
expect(component.spinner).toBe(spinnerName);
7162
});
72-
73-
it('should correctly check [entryComponent] with undefined', () => {
74-
const spinnerName = 'spinner-name';
75-
component.spinner = spinnerName;
76-
component.entryComponent = undefined;
77-
component.ngOnInit();
78-
79-
expect(component.spinner).toBe(spinnerName);
80-
});
8163
});

src/test/components/ng-http-loader.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('NgHttpLoaderComponent', () => {
114114
});
115115

116116
it('should show and hide the spinner according to the pending HTTP requests', fakeAsync(() => {
117-
const runQuery$ = (url: string): Observable<any> => http.get(url);
117+
const runQuery$ = (url: string): Observable<unknown> => http.get(url);
118118
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
119119
const firstRequest = httpMock.expectOne('/fake');
120120
const secondRequest = httpMock.expectOne('/fake2');
@@ -367,7 +367,7 @@ describe('NgHttpLoaderComponent', () => {
367367

368368
it('should correctly handle the debounce delay for multiple HTTP requests', fakeAsync(() => {
369369
component.debounceDelay = 2000;
370-
const runQuery$ = (url: string): Observable<any> => http.get(url);
370+
const runQuery$ = (url: string): Observable<unknown> => http.get(url);
371371
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
372372
const firstRequest = httpMock.expectOne('/fake');
373373
const secondRequest = httpMock.expectOne('/fake2');
@@ -510,7 +510,7 @@ describe('NgHttpLoaderComponent', () => {
510510

511511
it('should correctly handle the minimum spinner duration for multiple HTTP requests', fakeAsync(() => {
512512
component.minDuration = 5000;
513-
const runQuery$ = (url: string): Observable<any> => http.get(url);
513+
const runQuery$ = (url: string): Observable<unknown> => http.get(url);
514514
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
515515
const firstRequest = httpMock.expectOne('/fake');
516516
const secondRequest = httpMock.expectOne('/fake2');
@@ -548,7 +548,7 @@ describe('NgHttpLoaderComponent', () => {
548548

549549
it('should correctly handle the extra spinner duration for multiple HTTP requests', fakeAsync(() => {
550550
component.extraDuration = 5000;
551-
const runQuery$ = (url: string): Observable<any> => http.get(url);
551+
const runQuery$ = (url: string): Observable<unknown> => http.get(url);
552552
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
553553
const firstRequest = httpMock.expectOne('/fake');
554554
const secondRequest = httpMock.expectOne('/fake2');
@@ -622,7 +622,7 @@ describe('NgHttpLoaderComponent', () => {
622622

623623
it('should handle the extra spinner duration for multiple HTTP requests ran one after the others', fakeAsync(() => {
624624
component.extraDuration = 10;
625-
const runQuery$ = (url: string): Observable<any> => http.get(url);
625+
const runQuery$ = (url: string): Observable<unknown> => http.get(url);
626626
runQuery$('/fake').subscribe();
627627
const firstRequest = httpMock.expectOne('/fake');
628628

src/test/components/sk-chasing-dots/sk-chasing-dots.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
10+
import { ComponentFixture, TestBed } from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
1212
import { SkChasingDotsComponent } from '../../../lib/components/sk-chasing-dots/sk-chasing-dots.component';
1313

src/test/components/sk-cube-grid/sk-cube-grid.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
10+
import { ComponentFixture, TestBed } from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
1212
import { SkCubeGridComponent } from '../../../lib/components/sk-cube-grid/sk-cube-grid.component';
1313

src/test/components/sk-wandering-cubes/sk-wandering-cubes.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
10+
import { ComponentFixture, TestBed } from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
1212
import { SkWanderingCubesComponent } from '../../../lib/components/sk-wandering-cubes/sk-wandering-cubes.component';
1313

src/test/ng-http-loader.module.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('NgHttpLoaderModule', () => {
2323

2424
it('should create an instance with providers via forRoot()', () => {
2525
const ngHttpLoaderModuleWithProviders = NgHttpLoaderModule.forRoot();
26-
// @ts-ignore
26+
// @ts-expect-error This is error free
2727
expect(ngHttpLoaderModuleWithProviders.providers[0][0].useExisting.name).toEqual(PendingRequestsInterceptor.name);
2828
});
2929
});

0 commit comments

Comments
 (0)