ESLint: fix ban-types violations

This commit is contained in:
Yury Bondarenko
2023-05-08 17:24:11 +02:00
parent 80c9dae417
commit 74e9e5fa14
13 changed files with 39 additions and 37 deletions

View File

@@ -55,7 +55,7 @@ export class PutDataImpl<T extends CacheableObject> extends BaseDataService<T> i
*/ */
put(object: T): Observable<RemoteData<T>> { put(object: T): Observable<RemoteData<T>> {
const requestId = this.requestService.generateRequestId(); const requestId = this.requestService.generateRequestId();
const serializedObject = new DSpaceSerializer(object.constructor as GenericConstructor<{}>).serialize(object); const serializedObject = new DSpaceSerializer(object.constructor as GenericConstructor<unknown>).serialize(object);
const request = new PutRequest(requestId, object._links.self.href, serializedObject); const request = new PutRequest(requestId, object._links.self.href, serializedObject);
if (hasValue(this.responseMsToLive)) { if (hasValue(this.responseMsToLive)) {

View File

@@ -0,0 +1,15 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
import { SortDirection } from '../cache/models/sort-options.model';
export interface PaginationRouteParams {
page?: number
pageSize?: number
sortField?: string
sortDirection?: SortDirection
}

View File

@@ -9,6 +9,7 @@ import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
import { difference } from '../../shared/object.util'; import { difference } from '../../shared/object.util';
import { FindListOptions } from '../data/find-list-options.model'; import { FindListOptions } from '../data/find-list-options.model';
import { isNumeric } from '../../shared/numeric.util'; import { isNumeric } from '../../shared/numeric.util';
import { PaginationRouteParams } from './pagination-route-params.interface';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@@ -121,13 +122,8 @@ export class PaginationService {
*/ */
updateRoute( updateRoute(
paginationId: string, paginationId: string,
params: { params: PaginationRouteParams,
page?: number extraParams?: Record<string, unknown>,
pageSize?: number
sortField?: string
sortDirection?: SortDirection
},
extraParams?,
retainScrollPosition?: boolean, retainScrollPosition?: boolean,
navigationExtras?: NavigationExtras, navigationExtras?: NavigationExtras,
) { ) {
@@ -147,13 +143,8 @@ export class PaginationService {
updateRouteWithUrl( updateRouteWithUrl(
paginationId: string, paginationId: string,
url: string[], url: string[],
params: { params: PaginationRouteParams,
page?: number extraParams?: Record<string, unknown>,
pageSize?: number
sortField?: string
sortDirection?: SortDirection
},
extraParams?,
retainScrollPosition?: boolean, retainScrollPosition?: boolean,
navigationExtras?: NavigationExtras, navigationExtras?: NavigationExtras,
) { ) {
@@ -219,12 +210,7 @@ export class PaginationService {
); );
} }
private getParametersWithIdName(paginationId: string, params: { private getParametersWithIdName(paginationId: string, params: PaginationRouteParams) {
page?: number
pageSize?: number
sortField?: string
sortDirection?: SortDirection
}) {
const paramsWithIdName = {}; const paramsWithIdName = {};
if (hasValue(params.page)) { if (hasValue(params.page)) {
paramsWithIdName[`${paginationId}.page`] = `${params.page}`; paramsWithIdName[`${paginationId}.page`] = `${params.page}`;

View File

@@ -48,7 +48,7 @@ export class RecentItemListComponent implements OnInit {
public searchConfigurationService: SearchConfigurationService, public searchConfigurationService: SearchConfigurationService,
protected elementRef: ElementRef, protected elementRef: ElementRef,
@Inject(APP_CONFIG) private appConfig: AppConfig, @Inject(APP_CONFIG) private appConfig: AppConfig,
@Inject(PLATFORM_ID) private platformId: Object, @Inject(PLATFORM_ID) private platformId: any,
) { ) {
this.paginationConfig = Object.assign(new PaginationComponentOptions(), { this.paginationConfig = Object.assign(new PaginationComponentOptions(), {

View File

@@ -65,7 +65,7 @@ export class RelatedItemsComponent extends AbstractIncrementalListComponent<Obse
constructor(public relationshipService: RelationshipDataService, constructor(public relationshipService: RelationshipDataService,
protected elementRef: ElementRef, protected elementRef: ElementRef,
@Inject(APP_CONFIG) protected appConfig: AppConfig, @Inject(APP_CONFIG) protected appConfig: AppConfig,
@Inject(PLATFORM_ID) private platformId: Object @Inject(PLATFORM_ID) private platformId: any
) { ) {
super(); super();
this.fetchThumbnail = this.appConfig.browseBy.showThumbnails; this.fetchThumbnail = this.appConfig.browseBy.showThumbnails;

View File

@@ -8,5 +8,5 @@ export class OnClickMenuItemModel implements MenuItemModel {
type = MenuItemType.ONCLICK; type = MenuItemType.ONCLICK;
disabled: boolean; disabled: boolean;
text: string; text: string;
function: () => {}; function: () => void;
} }

View File

@@ -2,5 +2,5 @@ import { Action } from '@ngrx/store';
export class ActionMock implements Action { export class ActionMock implements Action {
type = null; type = null;
payload: {}; payload: any;
} }

View File

@@ -22,7 +22,7 @@ export class MockActivatedRoute {
// Test parameters // Test parameters
get testParams() { return this._testParams; } get testParams() { return this._testParams; }
set testParams(params: {}) { set testParams(params: any) {
this._testParams = params; this._testParams = params;
this.subject.next(params); this.subject.next(params);
} }

View File

@@ -189,7 +189,7 @@ export class ObjectCollectionComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private elementRef: ElementRef, private elementRef: ElementRef,
@Inject(PLATFORM_ID) private platformId: Object) { @Inject(PLATFORM_ID) private platformId: any) {
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -24,6 +24,7 @@ import { RemoteData } from '../../core/data/remote-data';
import { PaginatedList } from '../../core/data/paginated-list.model'; import { PaginatedList } from '../../core/data/paginated-list.model';
import { ListableObject } from '../object-collection/shared/listable-object.model'; import { ListableObject } from '../object-collection/shared/listable-object.model';
import { ViewMode } from '../../core/shared/view-mode.model'; import { ViewMode } from '../../core/shared/view-mode.model';
import { PaginationRouteParams } from '../../core/pagination/pagination-route-params.interface';
/** /**
* The default pagination controls component. * The default pagination controls component.
@@ -273,7 +274,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The page being navigated to. * The page being navigated to.
*/ */
public doPageChange(page: number) { public doPageChange(page: number) {
this.updateParams({page: page.toString()}); this.updateParams({page: page});
this.emitPaginationChange(); this.emitPaginationChange();
} }
@@ -284,7 +285,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The page size being navigated to. * The page size being navigated to.
*/ */
public doPageSizeChange(pageSize: number) { public doPageSizeChange(pageSize: number) {
this.updateParams({ pageId: this.id, page: 1, pageSize: pageSize }); this.updateParams({ page: 1, pageSize: pageSize });
this.emitPaginationChange(); this.emitPaginationChange();
} }
@@ -295,7 +296,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The sort direction being navigated to. * The sort direction being navigated to.
*/ */
public doSortDirectionChange(sortDirection: SortDirection) { public doSortDirectionChange(sortDirection: SortDirection) {
this.updateParams({ pageId: this.id, page: 1, sortDirection: sortDirection }); this.updateParams({ page: 1, sortDirection: sortDirection });
this.emitPaginationChange(); this.emitPaginationChange();
} }
@@ -306,7 +307,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The sort field being navigated to. * The sort field being navigated to.
*/ */
public doSortFieldChange(field: string) { public doSortFieldChange(field: string) {
this.updateParams({ pageId: this.id, page: 1, sortField: field }); this.updateParams({ page: 1, sortField: field });
this.emitPaginationChange(); this.emitPaginationChange();
} }
@@ -321,7 +322,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* Update the current query params and optionally update the route * Update the current query params and optionally update the route
* @param params * @param params
*/ */
private updateParams(params: {}) { private updateParams(params: PaginationRouteParams) {
this.paginationService.updateRoute(this.id, params, {}, this.retainScrollPosition); this.paginationService.updateRoute(this.id, params, {}, this.retainScrollPosition);
} }
@@ -407,7 +408,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/ */
updatePagination(value: number) { updatePagination(value: number) {
this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(take(1)).subscribe((currentPaginationOptions) => { this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(take(1)).subscribe((currentPaginationOptions) => {
this.updateParams({page: (currentPaginationOptions.currentPage + value).toString()}); this.updateParams({ page: (currentPaginationOptions.currentPage + value) });
}); });
} }

View File

@@ -2,5 +2,5 @@ import { Action } from '@ngrx/store';
export class ActionMock implements Action { export class ActionMock implements Action {
type = null; type = null;
payload: {}; payload: unknown;
} }

View File

@@ -35,7 +35,7 @@ export class ActivatedRouteStub {
return this._testParams; return this._testParams;
} }
set testParams(params: {}) { set testParams(params: unknown) {
this._testParams = params; this._testParams = params;
this.subject.next(params); this.subject.next(params);
} }
@@ -45,7 +45,7 @@ export class ActivatedRouteStub {
return this._testParams; return this._testParams;
} }
set testData(data: {}) { set testData(data: unknown) {
this._testData = data; this._testData = data;
this.dataSubject.next(data); this.dataSubject.next(data);
} }

View File

@@ -48,7 +48,7 @@ export class SystemWideAlertBannerComponent implements OnInit, OnDestroy {
subscriptions: Subscription[] = []; subscriptions: Subscription[] = [];
constructor( constructor(
@Inject(PLATFORM_ID) protected platformId: Object, @Inject(PLATFORM_ID) protected platformId: any,
protected systemWideAlertDataService: SystemWideAlertDataService, protected systemWideAlertDataService: SystemWideAlertDataService,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
) { ) {