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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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