mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
refactor: replace TSLint with ESLint
This commit is contained in:
committed by
Jovan Krunić
parent
67fb4a43c9
commit
d696215d08
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
/*
|
||||
* Copyright (C) 2020-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -15,7 +16,7 @@
|
||||
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
// tslint:disable: member-ordering prefer-function-over-method completed-docs
|
||||
/* eslint-disable @typescript-eslint/member-ordering, class-methods-use-this */
|
||||
|
||||
export abstract class ThingTranslateParser {
|
||||
/**
|
||||
@@ -27,22 +28,23 @@ export abstract class ThingTranslateParser {
|
||||
|
||||
@Injectable()
|
||||
export class ThingTranslateDefaultParser extends ThingTranslateParser {
|
||||
|
||||
getValueFromKeyPath(instance: object, keyPath: string): unknown {
|
||||
// keyPath = aproperty[0].anotherproperty["arrayproperty"][42].finalproperty
|
||||
let path = keyPath.replace(/(?:\"|\')'"/gmi, '.');
|
||||
let path = keyPath.replace(/["']'"/gim, '.');
|
||||
// path = aproperty[0].anotherproperty[.arrayproperty.][42].finalproperty
|
||||
path = path.replace(/(?:\[|\])/gmi, '.');
|
||||
path = path.replace(/[\[\]]/gim, '.');
|
||||
// path = aproperty.0..anotherproperty..arrayproperty...42..finalproperty
|
||||
path = path.replace(/\.{2,}/gmi, '.');
|
||||
// TODO
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
path = path.replace(/\.{2,}/gim, '.');
|
||||
// path = aproperty.0.anotherproperty.arrayproperty.42.finalproperty
|
||||
|
||||
const keyPathChain = keyPath.split('.');
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let property = instance as any;
|
||||
|
||||
for(const key of keyPathChain) {
|
||||
for (const key of keyPathChain) {
|
||||
property = property[key] ?? undefined;
|
||||
}
|
||||
|
||||
@@ -50,6 +52,9 @@ export class ThingTranslateDefaultParser extends ThingTranslateParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
export function isDefined<T>(value?: T | null): value is T {
|
||||
return typeof value !== 'undefined' && value !== null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user