ESLint: fix prefer-const violations

This commit is contained in:
Yury Bondarenko
2023-05-08 16:37:23 +02:00
parent 702246be38
commit 95d3ff6569
27 changed files with 46 additions and 62 deletions

View File

@@ -76,7 +76,7 @@ export class SupervisionOrderGroupSelectorComponent {
save() {
this.isSubmitted = true;
if (this.selectedOrderType && this.selectedGroup) {
let supervisionDataObject = new SupervisionOrder();
const supervisionDataObject = new SupervisionOrder();
supervisionDataObject.ordertype = this.selectedOrderType;
this.supervisionOrderDataService.create(supervisionDataObject, this.itemUUID, this.selectedGroup.uuid, this.selectedOrderType).pipe(
getFirstCompletedRemoteData(),

View File

@@ -90,7 +90,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
this.subs.push(
observableCombineLatest([firstItemRD, lastItemRD]).subscribe(([firstItem, lastItem]) => {
let lowerLimit = this.getLimit(firstItem, metadataKeys, this.appConfig.browseBy.defaultLowerLimit);
let upperLimit = this.getLimit(lastItem, metadataKeys, new Date().getUTCFullYear());
const upperLimit = this.getLimit(lastItem, metadataKeys, new Date().getUTCFullYear());
const options = [];
const oneYearBreak = Math.floor((upperLimit - this.appConfig.browseBy.oneYearLimit) / 5) * 5;
const fiveYearBreak = Math.floor((upperLimit - this.appConfig.browseBy.fiveYearLimit) / 10) * 10;

View File

@@ -280,9 +280,7 @@ export class CommunityListService {
* @param community Community being checked whether it is expandable (if it has subcommunities or collections)
*/
public getIsExpandable(community: Community): Observable<boolean> {
let hasSubcoms$: Observable<boolean>;
let hasColls$: Observable<boolean>;
hasSubcoms$ = this.communityDataService.findByParent(community.uuid, this.configOnePage)
const hasSubcoms$ = this.communityDataService.findByParent(community.uuid, this.configOnePage)
.pipe(
map((rd: RemoteData<PaginatedList<Community>>) => {
if (hasValue(rd) && hasValue(rd.payload)) {
@@ -293,7 +291,7 @@ export class CommunityListService {
}),
);
hasColls$ = this.collectionDataService.findByParent(community.uuid, this.configOnePage)
const hasColls$ = this.collectionDataService.findByParent(community.uuid, this.configOnePage)
.pipe(
map((rd: RemoteData<PaginatedList<Collection>>) => {
if (hasValue(rd) && hasValue(rd.payload)) {
@@ -304,12 +302,9 @@ export class CommunityListService {
}),
);
let hasChildren$: Observable<boolean>;
hasChildren$ = observableCombineLatest(hasSubcoms$, hasColls$).pipe(
return observableCombineLatest(hasSubcoms$, hasColls$).pipe(
map(([hasSubcoms, hasColls]: [boolean, boolean]) => hasSubcoms || hasColls)
);
return hasChildren$;
}
}

View File

@@ -260,9 +260,8 @@ export class AuthService {
select(getAuthenticationToken),
take(1),
map((authTokenInfo: AuthTokenInfo) => {
let token: AuthTokenInfo;
// Retrieve authentication token info and check if is valid
token = isNotEmpty(authTokenInfo) ? authTokenInfo : this.storage.get(TOKENITEM);
const token = isNotEmpty(authTokenInfo) ? authTokenInfo : this.storage.get(TOKENITEM);
if (isNotEmpty(token) && token.hasOwnProperty('accessToken') && isNotEmpty(token.accessToken) && !this.isTokenExpired(token)) {
return token;
} else {

View File

@@ -87,10 +87,9 @@ export class FindAllDataImpl<T extends CacheableObject> extends BaseDataService<
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/
getFindAllHref(options: FindListOptions = {}, linkPath?: string, ...linksToFollow: FollowLinkConfig<T>[]): Observable<string> {
let endpoint$: Observable<string>;
const args = [];
endpoint$ = this.getBrowseEndpoint(options).pipe(
const endpoint$ = this.getBrowseEndpoint(options).pipe(
filter((href: string) => isNotEmpty(href)),
map((href: string) => isNotEmpty(linkPath) ? `${href}/${linkPath}` : href),
distinctUntilChanged(),

View File

@@ -112,10 +112,9 @@ export class SearchDataImpl<T extends CacheableObject> extends BaseDataService<T
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/
getSearchByHref(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<T>[]): Observable<string> {
let result$: Observable<string>;
const args = [];
result$ = this.getSearchEndpoint(searchMethod);
const result$ = this.getSearchEndpoint(searchMethod);
return result$.pipe(map((result: string) => this.buildHrefFromFindOptions(result, options, args, ...linksToFollow)));
}

View File

@@ -95,7 +95,7 @@ export class DsoRedirectService {
if (response.hasSucceeded) {
const dso = response.payload;
if (hasValue(dso.uuid)) {
let newRoute = getDSORoute(dso);
const newRoute = getDSORoute(dso);
if (hasValue(newRoute)) {
// Use a "301 Moved Permanently" redirect for SEO purposes
this.hardRedirectService.redirect(newRoute, 301);

View File

@@ -264,7 +264,7 @@ export class RelationshipDataService extends IdentifiableDataService<Relationshi
* @param options
*/
getRelatedItemsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Item>>> {
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(options.fetchThumbnail);
const linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(options.fetchThumbnail);
linksToFollow.push(followLink('relationshipType'));
return this.getItemRelationshipsByLabel(item, label, options, true, true, ...linksToFollow).pipe(this.paginatedRelationsToItems(item.uuid));

View File

@@ -184,7 +184,7 @@ export class ItemAuthorizationsComponent implements OnInit, OnDestroy {
mergeMap((list: PaginatedList<Bundle>) => list.page),
map((bundle: Bundle) => ({ id: bundle.id, bitstreams: this.getBundleBitstreams(bundle) }))
).subscribe((entry: BundleBitstreamsMapEntry) => {
let bitstreamMapValues: BitstreamMapValue = {
const bitstreamMapValues: BitstreamMapValue = {
isCollapsed: true,
allBitstreamsLoaded: false,
bitstreams: null
@@ -239,14 +239,14 @@ export class ItemAuthorizationsComponent implements OnInit, OnDestroy {
*/
onBitstreamsLoad(bundle: Bundle) {
return this.getBundleBitstreams(bundle).subscribe((res: PaginatedList<Bitstream>) => {
let nextBitstreams = res?.page.slice(this.bitstreamPageSize, this.bitstreamPageSize + this.bitstreamSize);
let bitstreamsToShow = this.bundleBitstreamsMap.get(bundle.id).bitstreams.pipe(
const nextBitstreams = res?.page.slice(this.bitstreamPageSize, this.bitstreamPageSize + this.bitstreamSize);
const bitstreamsToShow = this.bundleBitstreamsMap.get(bundle.id).bitstreams.pipe(
map((existingBits: Bitstream[])=> {
return [... existingBits, ...nextBitstreams];
})
);
this.bitstreamPageSize = this.bitstreamPageSize + this.bitstreamSize;
let bitstreamMapValues: BitstreamMapValue = {
const bitstreamMapValues: BitstreamMapValue = {
bitstreams: bitstreamsToShow ,
isCollapsed: this.bundleBitstreamsMap.get(bundle.id).isCollapsed,
allBitstreamsLoaded: res?.page.length <= this.bitstreamPageSize

View File

@@ -493,7 +493,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
);
// this adds thumbnail images when required by configuration
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(this.fetchThumbnail);
const linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(this.fetchThumbnail);
this.subs.push(
observableCombineLatest([

View File

@@ -103,7 +103,7 @@ export class ItemStatusComponent implements OnInit {
);
// Observable for configuration determining whether the Register DOI feature is enabled
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
const registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<ConfigurationProperty>) => {
// If the config property is exposed via rest and has a value set, return it
@@ -147,7 +147,7 @@ export class ItemStatusComponent implements OnInit {
getFirstSucceededRemoteData(),
getRemoteDataPayload(),
mergeMap((data: IdentifierData) => {
let identifiers = data.identifiers;
const identifiers = data.identifiers;
let no_doi = true;
let pending = false;
if (identifiers !== undefined && identifiers !== null) {
@@ -174,7 +174,7 @@ export class ItemStatusComponent implements OnInit {
}),
// Switch map pushes the register DOI operation onto a copy of the base array then returns to the pipe
switchMap((showDoi: boolean) => {
let ops = [...operations];
const ops = [...operations];
if (showDoi) {
ops.push(new ItemOperation('register-doi', this.getCurrentUrl(item) + '/register-doi', FeatureID.CanRegisterDOI, true));
}

View File

@@ -84,7 +84,7 @@ export class MetadataValuesComponent implements OnChanges {
* @param value the specific metadata value being linked
*/
getQueryParams(value) {
let queryParams = {startsWith: value};
const queryParams = {startsWith: value};
if (this.browseDefinition.getRenderType() === VALUE_LIST_BROWSE_DEFINITION.value) {
return {value: value};
}

View File

@@ -48,7 +48,7 @@ export class MediaViewerVideoComponent {
.filter((media: Bitstream) => media.name.substring(0, (media.name.length - 7)).toLowerCase() === name.toLowerCase());
for (const media of filteredCapMedias) {
let srclang: string = media.name.slice(-6, -4).toLowerCase();
const srclang: string = media.name.slice(-6, -4).toLowerCase();
capInfos.push(new CaptionInfo(
media._links.content.href,
srclang,

View File

@@ -183,7 +183,7 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
* Registration of an email address
*/
registration(captchaToken = null) {
let registerEmail$ = captchaToken ?
const registerEmail$ = captchaToken ?
this.epersonRegistrationService.registerEmail(this.email.value, captchaToken, this.typeRequest) :
this.epersonRegistrationService.registerEmail(this.email.value, null, this.typeRequest);
this.subscriptions.push(registerEmail$.subscribe((response: RemoteData<Registration>) => {

View File

@@ -96,7 +96,7 @@ export class BulkAccessControlService {
* @param payload
*/
export const convertToBulkAccessControlFileModel = (payload: { state: AccessControlFormState, bitstreamAccess: AccessCondition[], itemAccess: AccessCondition[] }): BulkAccessControlFileModel => {
let finalPayload: BulkAccessControlFileModel = {};
const finalPayload: BulkAccessControlFileModel = {};
const itemEnabled = payload.state.item.toggleStatus;
const bitstreamEnabled = payload.state.bitstream.toggleStatus;

View File

@@ -108,7 +108,7 @@ export class BrowserKlaroService extends KlaroService {
const servicesToHide$: Observable<string[]> = observableCombineLatest([hideGoogleAnalytics$, hideRegistrationVerification$]).pipe(
map(([hideGoogleAnalytics, hideRegistrationVerification]) => {
let servicesToHideArray: string[] = [];
const servicesToHideArray: string[] = [];
if (hideGoogleAnalytics) {
servicesToHideArray.push(this.GOOGLE_ANALYTICS_SERVICE_NAME);
}

View File

@@ -228,7 +228,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy {
*/
search(query: string, page: number, useCache: boolean = true): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
// default sort is only used when there is not query
let efectiveSort = query ? null : this.sort;
const efectiveSort = query ? null : this.sort;
return this.searchService.search(
new PaginatedSearchOptions({
query: query,

View File

@@ -86,7 +86,6 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
}
set value(value: string | FormFieldMetadataValueObject) {
let values;
let tempValue: string;
if (typeof value === 'string') {
@@ -97,15 +96,19 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
if (hasNoValue(tempValue)) {
tempValue = '';
}
values = [...tempValue.split(this.separator), null].map((v) =>
// todo: this used to be valid, but results in a type error now -- REMEMBER TO INVESTIGATE!
const values = [...tempValue.split(this.separator), null].map((v) =>
Object.assign(new FormFieldMetadataValueObject(), value, { display: v, value: v }));
if (values[0].value) {
// @ts-ignore
(this.get(0) as DsDynamicInputModel).value = values[0];
} else {
(this.get(0) as DsDynamicInputModel).value = undefined;
}
if (values[1].value) {
// @ts-ignore
(this.get(1) as DsDynamicInputModel).value = values[1];
} else {
(this.get(1) as DsDynamicInputModel).value = undefined;

View File

@@ -1,7 +1,6 @@
import {Inject} from '@angular/core';
import { FormFieldModel } from '../models/form-field.model';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { DynamicFormControlLayout, } from '@ng-dynamic-forms/core';
import {
CONCAT_FIRST_INPUT_SUFFIX,
CONCAT_GROUP_SUFFIX,
@@ -38,12 +37,9 @@ export class ConcatFieldParser extends FieldParser {
}
public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: boolean): any {
let clsGroup: DynamicFormControlLayout;
let clsInput: DynamicFormControlLayout;
const id: string = this.configData.selectableMetadata[0].metadata;
clsInput = {
const clsInput = {
grid: {
host: 'col-sm-6'
}
@@ -105,7 +101,7 @@ export class ConcatFieldParser extends FieldParser {
concatGroup.group.push(model1);
concatGroup.group.push(model2);
clsGroup = {
const clsGroup = {
element: {
control: 'form-row',
}

View File

@@ -1,5 +1,4 @@
import { FieldParser } from './field-parser';
import { DynamicFormControlLayout } from '@ng-dynamic-forms/core';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import {
DsDynamicTextAreaModel,
@@ -12,9 +11,7 @@ export class TextareaFieldParser extends FieldParser {
public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: boolean): any {
const textAreaModelConfig: DsDynamicTextAreaModelConfig = this.initModel(null, label);
let layout: DynamicFormControlLayout;
layout = {
const layout = {
element: {
label: 'col-form-label'
}

View File

@@ -2,7 +2,7 @@ import findIndex from 'lodash/findIndex';
import isEqual from 'lodash/isEqual';
import isObject from 'lodash/isObject';
import { BehaviorSubject } from 'rxjs';
import { ChipsItem, ChipsItemIcon } from './chips-item.model';
import { ChipsItem } from './chips-item.model';
import { hasValue, isNotEmpty } from '../../../empty.util';
import { MetadataIconConfig } from '../../../../../config/submission-config.interface';
import { FormFieldMetadataValueObject } from '../../builder/models/form-field-metadata-value.model';
@@ -123,12 +123,10 @@ export class Chips {
config = (configIndex !== -1) ? this.iconsConfig[configIndex] : defaultConfig;
if (hasValue(value) && isNotEmpty(config) && !this.hasPlaceholder(value)) {
let icon: ChipsItemIcon;
const visibleWhenAuthorityEmpty = this.displayObj !== metadata;
// Set icon
icon = {
const icon = {
metadata,
visibleWhenAuthorityEmpty,
style: config.style

View File

@@ -21,8 +21,7 @@ export class NotificationsService {
}
private add(notification: Notification) {
let notificationAction;
notificationAction = new NewNotificationAction(notification);
const notificationAction = new NewNotificationAction(notification);
this.store.dispatch(notificationAction);
}

View File

@@ -21,7 +21,7 @@ export class BrowseLinkMetadataListElementComponent extends MetadataRepresentati
* expects 'startsWith' (eg browse by date) or 'value' (eg browse by title)
*/
getQueryParams() {
let queryParams = {startsWith: this.mdRepresentation.getValue()};
const queryParams = {startsWith: this.mdRepresentation.getValue()};
if (this.mdRepresentation.browseDefinition.getRenderType() === VALUE_LIST_BROWSE_DEFINITION.value) {
return {value: this.mdRepresentation.getValue()};
}

View File

@@ -21,7 +21,7 @@ export class PlainTextMetadataListElementComponent extends MetadataRepresentatio
* expects 'startsWith' (eg browse by date) or 'value' (eg browse by title)
*/
getQueryParams() {
let queryParams = {startsWith: this.mdRepresentation.getValue()};
const queryParams = {startsWith: this.mdRepresentation.getValue()};
if (this.mdRepresentation.browseDefinition.getRenderType() === VALUE_LIST_BROWSE_DEFINITION.value) {
return {value: this.mdRepresentation.getValue()};
}

View File

@@ -333,11 +333,10 @@ export class PaginationComponent implements OnDestroy, OnInit {
if (collectionSize) {
showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(
map((currentPaginationOptions) => {
let firstItem;
let lastItem;
const pageMax = currentPaginationOptions.pageSize * currentPaginationOptions.currentPage;
firstItem = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1;
const firstItem = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1;
if (collectionSize > pageMax) {
lastItem = pageMax;
} else {

View File

@@ -432,7 +432,7 @@ export class SearchComponent implements OnInit {
private retrieveSearchResults(searchOptions: PaginatedSearchOptions) {
this.resultsRD$.next(null);
this.lastSearchOptions = searchOptions;
let followLinks = [
const followLinks = [
followLink<Item>('thumbnail', { isOptional: true }),
followLink<SubmissionObject>('item', { isOptional: true }, followLink<Item>('thumbnail', { isOptional: true })) as any,
followLink<Item>('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }),

View File

@@ -115,7 +115,7 @@ export class SubscriptionModalComponent implements OnInit {
this.subscriptionForm.valueChanges.subscribe((newValue) => {
let anyFrequencySelected = false;
for (let f of this.frequencyDefaultValues) {
for (const f of this.frequencyDefaultValues) {
anyFrequencySelected = anyFrequencySelected || newValue.content.frequencies[f];
}
this.isValid = anyFrequencySelected;
@@ -124,11 +124,11 @@ export class SubscriptionModalComponent implements OnInit {
initFormByAllSubscriptions(): void {
this.subscriptionForm = new UntypedFormGroup({});
for (let t of this.subscriptionDefaultTypes) {
for (const t of this.subscriptionDefaultTypes) {
const formGroup = new UntypedFormGroup({});
formGroup.addControl('subscriptionId', this.formBuilder.control(''));
formGroup.addControl('frequencies', this.formBuilder.group({}));
for (let f of this.frequencyDefaultValues) {
for (const f of this.frequencyDefaultValues) {
(formGroup.controls.frequencies as UntypedFormGroup).addControl(f, this.formBuilder.control(false));
}
this.subscriptionForm.addControl(t, formGroup);
@@ -145,7 +145,7 @@ export class SubscriptionModalComponent implements OnInit {
formGroup.addControl('subscriptionId', this.formBuilder.control(this.subscription.id));
formGroup.addControl('frequencies', this.formBuilder.group({}));
(formGroup.get('frequencies') as UntypedFormGroup).addValidators(Validators.required);
for (let f of this.frequencyDefaultValues) {
for (const f of this.frequencyDefaultValues) {
const value = findIndex(this.subscription.subscriptionParameterList, ['value', f]) !== -1;
(formGroup.controls.frequencies as UntypedFormGroup).addControl(f, this.formBuilder.control(value));
}
@@ -167,12 +167,12 @@ export class SubscriptionModalComponent implements OnInit {
next: (res: PaginatedList<Subscription>) => {
if (res.pageInfo.totalElements > 0) {
this.showDeleteInfo$.next(true);
for (let subscription of res.page) {
for (const subscription of res.page) {
const type = subscription.subscriptionType;
const subscriptionGroup: UntypedFormGroup = this.subscriptionForm.get(type) as UntypedFormGroup;
if (isNotEmpty(subscriptionGroup)) {
subscriptionGroup.controls.subscriptionId.setValue(subscription.id);
for (let parameter of subscription.subscriptionParameterList.filter((p) => p.name === 'frequency')) {
for (const parameter of subscription.subscriptionParameterList.filter((p) => p.name === 'frequency')) {
(subscriptionGroup.controls.frequencies as UntypedFormGroup).controls[parameter.value]?.setValue(true);
}
}
@@ -266,7 +266,7 @@ export class SubscriptionModalComponent implements OnInit {
subscriptionParameterList: []
};
for (let frequency of this.frequencyDefaultValues) {
for (const frequency of this.frequencyDefaultValues) {
if (frequencies.value[frequency]) {
body.subscriptionParameterList.push(
{