From 9df52d660feb722404be00a50f3c8a612bec1c15 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Aug 2021 14:42:53 +0200 Subject: Migrate client to eslint --- client/src/app/shared/shared-forms/form-reactive.ts | 6 +++--- client/src/app/shared/shared-forms/form-validator.service.ts | 8 ++++---- client/src/app/shared/shared-forms/reactive-file.component.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'client/src/app/shared/shared-forms') diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts index adf6cb894..f2ce82360 100644 --- a/client/src/app/shared/shared-forms/form-reactive.ts +++ b/client/src/app/shared/shared-forms/form-reactive.ts @@ -51,7 +51,7 @@ export abstract class FormReactive { } // clear previous error message (if any) - formErrors[ field ] = '' + formErrors[field] = '' const control = form.get(field) if (control.dirty) this.formChanged = true @@ -59,9 +59,9 @@ export abstract class FormReactive { // Don't care if dirty on force check const isDirty = control.dirty || forceCheck === true if (control && isDirty && control.enabled && !control.valid) { - const messages = validationMessages[ field ] + const messages = validationMessages[field] for (const key of Object.keys(control.errors)) { - formErrors[ field ] += messages[ key ] + ' ' + formErrors[field] += messages[key] + ' ' } } } diff --git a/client/src/app/shared/shared-forms/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts index 41c8b76bd..c0664de5f 100644 --- a/client/src/app/shared/shared-forms/form-validator.service.ts +++ b/client/src/app/shared/shared-forms/form-validator.service.ts @@ -28,11 +28,11 @@ export class FormValidatorService { continue } - if (field && field.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } + if (field?.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } const defaultValue = defaultValues[name] || '' - if (field && field.VALIDATORS) group[name] = [ defaultValue, field.VALIDATORS ] + if (field?.VALIDATORS) group[name] = [ defaultValue, field.VALIDATORS ] else group[name] = [ defaultValue ] } @@ -62,11 +62,11 @@ export class FormValidatorService { continue } - if (field && field.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } + if (field?.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } const defaultValue = defaultValues[name] || '' - if (field && field.VALIDATORS) form.addControl(name, new FormControl(defaultValue, field.VALIDATORS as ValidatorFn[])) + if (field?.VALIDATORS) form.addControl(name, new FormControl(defaultValue, field.VALIDATORS as ValidatorFn[])) else form.addControl(name, new FormControl(defaultValue)) } } diff --git a/client/src/app/shared/shared-forms/reactive-file.component.ts b/client/src/app/shared/shared-forms/reactive-file.component.ts index fac3dfb3a..9d27ad07a 100644 --- a/client/src/app/shared/shared-forms/reactive-file.component.ts +++ b/client/src/app/shared/shared-forms/reactive-file.component.ts @@ -43,7 +43,7 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { } fileChange (event: any) { - if (event.target.files && event.target.files.length) { + if (event.target.files?.length) { const [ file ] = event.target.files if (file.size > this.maxFileSize) { -- cgit v1.2.3