120243: Fix lint issues after upgrade

This commit is contained in:
Andreas Awouters
2024-11-19 11:24:30 +01:00
committed by Yury Bondarenko
parent ae32581d20
commit d87b375a35
28 changed files with 293 additions and 130 deletions

View File

@@ -1,3 +1,7 @@
import {
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import {
@@ -20,7 +24,6 @@ import { RawRestResponse } from 'src/app/core/dspace-rest/raw-rest-response.mode
import { TranslateLoaderMock } from 'src/app/shared/mocks/translate-loader.mock';
import { FilteredCollectionsComponent } from './filtered-collections.component';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
describe('FiltersComponent', () => {
let component: FilteredCollectionsComponent;
@@ -40,22 +43,22 @@ describe('FiltersComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
imports: [NgbAccordionModule,
schemas: [NO_ERRORS_SCHEMA],
imports: [NgbAccordionModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock,
},
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock,
},
}),
FilteredCollectionsComponent],
providers: [
providers: [
FormBuilder,
DspaceRestService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
}));
beforeEach(waitForAsync(() => {

View File

@@ -1,5 +1,12 @@
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HTTP_INTERCEPTORS,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
@@ -25,21 +32,21 @@ describe(`AuthInterceptor`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
imports: [],
providers: [
DspaceRestService,
{ provide: AuthService, useValue: authServiceStub },
{ provide: Router, useClass: RouterStub },
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
},
{ provide: Store, useValue: store },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
service = TestBed.inject(DspaceRestService);
httpMock = TestBed.inject(HttpTestingController);

View File

@@ -1,4 +1,13 @@
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest, HttpResponse, HttpResponseBase } from '@angular/common/http';
import {
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpHeaders,
HttpInterceptor,
HttpRequest,
HttpResponse,
HttpResponseBase,
} from '@angular/common/http';
import {
Injectable,
Injector,

View File

@@ -1,4 +1,8 @@
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
HttpResponse,
} from '@angular/common/http';
import {
Observable,
of as observableOf,

View File

@@ -1,4 +1,8 @@
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
HttpResponse,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

View File

@@ -1,4 +1,7 @@
import { HttpHeaders, HttpParams } from '@angular/common/http';
import {
HttpHeaders,
HttpParams,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import {

View File

@@ -1,4 +1,8 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
HttpParams,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';

View File

@@ -1,5 +1,13 @@
import { HttpErrorResponse, HttpHeaders, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HttpErrorResponse,
HttpHeaders,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import {
inject,
TestBed,
@@ -27,9 +35,13 @@ describe('DspaceRestService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [DspaceRestService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
});
imports: [],
providers: [
DspaceRestService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
});
dspaceRestService = TestBed.inject(DspaceRestService);
httpMock = TestBed.inject(HttpTestingController);

View File

@@ -1,4 +1,10 @@
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import {
HttpClient,
HttpErrorResponse,
HttpHeaders,
HttpParams,
HttpResponse,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
Observable,

View File

@@ -1,5 +1,12 @@
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HTTP_INTERCEPTORS,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { REQUEST } from '../../../express.tokens';
@@ -18,19 +25,19 @@ describe('ForwardClientIpInterceptor', () => {
clientIp = '1.2.3.4';
TestBed.configureTestingModule({
imports: [],
providers: [
imports: [],
providers: [
DspaceRestService,
{
provide: HTTP_INTERCEPTORS,
useClass: ForwardClientIpInterceptor,
multi: true,
provide: HTTP_INTERCEPTORS,
useClass: ForwardClientIpInterceptor,
multi: true,
},
{ provide: REQUEST, useValue: { get: () => undefined, connection: { remoteAddress: clientIp } } },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
service = TestBed.inject(DspaceRestService);
httpMock = TestBed.inject(HttpTestingController);

View File

@@ -1,4 +1,9 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import {
Inject,
Injectable,

View File

@@ -1,5 +1,12 @@
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HTTP_INTERCEPTORS,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
@@ -22,19 +29,19 @@ describe(`LocaleInterceptor`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
imports: [],
providers: [
DspaceRestService,
{
provide: HTTP_INTERCEPTORS,
useClass: LocaleInterceptor,
multi: true,
provide: HTTP_INTERCEPTORS,
useClass: LocaleInterceptor,
multi: true,
},
{ provide: LocaleService, useValue: mockLocaleService },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
service = TestBed.inject(DspaceRestService);
httpMock = TestBed.inject(HttpTestingController);

View File

@@ -1,4 +1,9 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import {

View File

@@ -1,5 +1,12 @@
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HTTP_INTERCEPTORS,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { StoreModule } from '@ngrx/store';
@@ -36,14 +43,14 @@ describe('LogInterceptor', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [StoreModule.forRoot(appReducers, storeModuleConfig)],
providers: [
imports: [StoreModule.forRoot(appReducers, storeModuleConfig)],
providers: [
DspaceRestService,
// LogInterceptor,
{
provide: HTTP_INTERCEPTORS,
useClass: LogInterceptor,
multi: true,
provide: HTTP_INTERCEPTORS,
useClass: LogInterceptor,
multi: true,
},
{ provide: CookieService, useValue: new CookieServiceMock() },
{ provide: Router, useValue: router },
@@ -51,8 +58,8 @@ describe('LogInterceptor', () => {
{ provide: UUIDService, useClass: UUIDService },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
service = TestBed.inject(DspaceRestService);
httpMock = TestBed.inject(HttpTestingController);

View File

@@ -1,4 +1,9 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';

View File

@@ -1,4 +1,7 @@
import { HttpHeaders, HttpParams } from '@angular/common/http';
import {
HttpHeaders,
HttpParams,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ReplaceOperation } from 'fast-json-patch';
import { Observable } from 'rxjs';

View File

@@ -1,4 +1,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
} from '@angular/common/http';
import { ReplaceOperation } from 'fast-json-patch';
import {
cold,

View File

@@ -1,4 +1,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
} from '@angular/common/http';
import { waitForAsync } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import {

View File

@@ -1,4 +1,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';

View File

@@ -1,5 +1,12 @@
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HttpClient,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { RESTURLCombiner } from '../url-combiner/rest-url-combiner';
@@ -14,9 +21,13 @@ describe(`BrowserXSRFService`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [BrowserXSRFService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
});
imports: [],
providers: [
BrowserXSRFService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
});
httpClient = TestBed.inject(HttpClient);
httpTestingController = TestBed.inject(HttpTestingController);
service = TestBed.inject(BrowserXSRFService);

View File

@@ -1,5 +1,14 @@
import { HTTP_INTERCEPTORS, HttpHeaders, HttpXsrfTokenExtractor, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
HTTP_INTERCEPTORS,
HttpHeaders,
HttpXsrfTokenExtractor,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { CookieServiceMock } from '../../shared/mocks/cookie.service.mock';
@@ -28,20 +37,20 @@ describe(`XsrfInterceptor`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
imports: [],
providers: [
DspaceRestService,
{
provide: HTTP_INTERCEPTORS,
useClass: XsrfInterceptor,
multi: true,
provide: HTTP_INTERCEPTORS,
useClass: XsrfInterceptor,
multi: true,
},
{ provide: HttpXsrfTokenExtractor, useValue: new HttpXsrfTokenExtractorMock(testToken) },
{ provide: CookieService, useValue: new CookieServiceMock() },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});
],
});
service = TestBed.get(DspaceRestService);
httpMock = TestBed.get(HttpTestingController);

View File

@@ -1,4 +1,12 @@
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse, HttpXsrfTokenExtractor } from '@angular/common/http';
import {
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
HttpResponse,
HttpXsrfTokenExtractor,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
Observable,

View File

@@ -1,4 +1,11 @@
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import {
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
HttpTestingController,
provideHttpClientTesting,
} from '@angular/common/http/testing';
import {
DebugElement,
NO_ERRORS_SCHEMA,
@@ -22,7 +29,6 @@ import {
import { LangConfig } from '../../../config/lang-config.interface';
import { LocaleService } from '../../core/locale/locale.service';
import { LangSwitchComponent } from './lang-switch.component';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
// This test is completely independent from any message catalogs or keys in the codebase
// The translation module is instantiated with these bogus messages that we aren't using anyway.
@@ -81,17 +87,17 @@ describe('LangSwitchComponent', () => {
};
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
imports: [TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: CustomLoader },
schemas: [NO_ERRORS_SCHEMA],
imports: [TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: CustomLoader },
}), LangSwitchComponent],
providers: [
TranslateService,
{ provide: LocaleService, useValue: getMockLocaleService() },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
}).compileComponents()
providers: [
TranslateService,
{ provide: LocaleService, useValue: getMockLocaleService() },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents()
.then(() => {
translate = TestBed.inject(TranslateService);
translate.addLangs(mockConfig.languages.filter((langConfig: LangConfig) => langConfig.active === true).map((a) => a.code));
@@ -166,17 +172,17 @@ describe('LangSwitchComponent', () => {
};
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
imports: [TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: CustomLoader },
schemas: [NO_ERRORS_SCHEMA],
imports: [TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: CustomLoader },
}), LangSwitchComponent],
providers: [
TranslateService,
{ provide: LocaleService, useValue: getMockLocaleService() },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
}).compileComponents();
providers: [
TranslateService,
{ provide: LocaleService, useValue: getMockLocaleService() },
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents();
translate = TestBed.inject(TranslateService);
translate.addLangs(mockConfig.languages.filter((MyLangConfig) => MyLangConfig.active === true).map((a) => a.code));
translate.setDefaultLang('en');

View File

@@ -1,4 +1,7 @@
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import {
HttpHeaders,
HttpResponse,
} from '@angular/common/http';
import { of as observableOf } from 'rxjs';
import { RestRequestMethod } from '../../../core/data/rest-request-method';

View File

@@ -1,4 +1,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import {
HttpClient,
HttpHeaders,
} from '@angular/common/http';
import {
Inject,
Injectable,

View File

@@ -1,4 +1,8 @@
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import {
HttpClient,
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import {
APP_ID,
APP_INITIALIZER,

View File

@@ -1,6 +1,9 @@
import { DragDropModule } from '@angular/cdk/drag-drop';
import { CommonModule } from '@angular/common';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import {
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
@@ -203,19 +206,24 @@ const DECLARATIONS = [
SearchResultsSkeletonComponent,
];
@NgModule({ imports: [RootModule,
CommonModule,
DragDropModule,
FormsModule,
NgbModule,
RouterModule,
ScrollToModule,
StoreModule,
StoreRouterConnectingModule,
TranslateModule,
FormsModule,
NgxGalleryModule,
...DECLARATIONS], providers: [provideHttpClient(withInterceptorsFromDi())] })
@NgModule({
imports: [RootModule,
CommonModule,
DragDropModule,
FormsModule,
NgbModule,
RouterModule,
ScrollToModule,
StoreModule,
StoreRouterConnectingModule,
TranslateModule,
FormsModule,
NgxGalleryModule,
...DECLARATIONS],
providers: [
provideHttpClient(withInterceptorsFromDi()),
],
})
/**
* This module serves as an index for all the components in this theme.

View File

@@ -1,6 +1,9 @@
import { DragDropModule } from '@angular/cdk/drag-drop';
import { CommonModule } from '@angular/common';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import {
provideHttpClient,
withInterceptorsFromDi,
} from '@angular/common/http';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
@@ -15,17 +18,25 @@ import { RootModule } from '../../app/root.module';
const DECLARATIONS = [
];
@NgModule({ declarations: DECLARATIONS, imports: [RootModule,
CommonModule,
DragDropModule,
FormsModule,
NgbModule,
RouterModule,
ScrollToModule,
StoreModule,
StoreRouterConnectingModule,
TranslateModule,
FormsModule], providers: [provideHttpClient(withInterceptorsFromDi())] })
@NgModule({
declarations: DECLARATIONS,
imports: [
RootModule,
CommonModule,
DragDropModule,
FormsModule,
NgbModule,
RouterModule,
ScrollToModule,
StoreModule,
StoreRouterConnectingModule,
TranslateModule,
FormsModule,
],
providers: [
provideHttpClient(withInterceptorsFromDi()),
],
})
/**
* This module serves as an index for all the components in this theme.