refactor: replace TSLint with ESLint

This commit is contained in:
Wieland Schöbl
2021-06-30 13:53:44 +02:00
committed by Jovan Krunić
parent 67fb4a43c9
commit d696215d08
147 changed files with 5471 additions and 2704 deletions

View File

@@ -13,14 +13,11 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {DecimalPipe} from '@angular/common';
import {Injectable, OnDestroy, Pipe, PipeTransform} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {Subscription} from 'rxjs';
// tslint:disable: completed-docs
@Injectable()
@Pipe({
name: 'join',
@@ -29,21 +26,21 @@ import {Subscription} from 'rxjs';
export class ArrayJoinPipe implements PipeTransform {
value = '';
transform(anArray: [], separator: string): unknown {
transform(anArray: unknown[], separator: string | unknown): unknown {
if (typeof separator !== 'string' || separator.length <= 0) {
return this.value;
}
if (!Array.isArray(anArray)){
throw new SyntaxError(`Wrong parameter in ArrayJoinPipe. Expected a valid Array, received: ${anArray}`);
if (!Array.isArray(anArray)) {
throw new SyntaxError(
`Wrong parameter in ArrayJoinPipe. Expected a valid Array, received: ${anArray}`,
);
}
this.value = anArray.join(separator);
return this.value;
}
}
@Injectable()
@@ -52,25 +49,25 @@ export class ArrayJoinPipe implements PipeTransform {
pure: false, // required to update the value when the promise is resolved
})
export class StringSplitPipe implements PipeTransform {
value = Array<unknown>();
value = new Array<unknown>();
transform(aString: string, splitter: string): unknown {
transform<T>(aString: string | T, splitter: string | T): T {
if (typeof splitter !== 'string' || splitter.length <= 0) {
return this.value;
return this.value as never;
}
if (typeof aString !== 'string'){
throw new SyntaxError(`Wrong parameter in StringSplitPipe. Expected a valid String, received: ${aString}`);
if (typeof aString !== 'string') {
throw new SyntaxError(
`Wrong parameter in StringSplitPipe. Expected a valid String, received: ${aString}`,
);
}
this.value = aString.split(splitter);
return this.value;
return this.value as never;
}
}
@Injectable()
@Pipe({
name: 'numberLocalized',
@@ -78,8 +75,11 @@ export class StringSplitPipe implements PipeTransform {
})
export class NumberLocalizedPipe implements PipeTransform, OnDestroy {
decimalPipe: DecimalPipe;
locale: string;
onLangChange: Subscription;
value: unknown;
constructor(private readonly translate: TranslateService) {
@@ -109,21 +109,22 @@ export class NumberLocalizedPipe implements PipeTransform, OnDestroy {
* Default is `3`.
*/
transform(value: unknown, digitsInfo?: string | undefined): unknown {
this.updateValue(value, digitsInfo);
this._dispose();
if (typeof this.onLangChange === 'undefined' || this.onLangChange.closed ) {
this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
if (typeof this.onLangChange === 'undefined' || this.onLangChange.closed) {
this.onLangChange = this.translate.onLangChange.subscribe(
(event: LangChangeEvent) => {
this.locale = event.lang;
this.updateValue(value, digitsInfo);
});
}
},
);
}
return this.value;
}
updateValue(value: unknown, digitsInfo?: string | undefined): void {
// this.value = this.locale;
this.value = this.decimalPipe.transform(value, digitsInfo,this.locale);
this.value = this.decimalPipe.transform(value, digitsInfo, this.locale);
}
}