chore: strengthen backend eslint profile

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent 53b2794963
commit a970eaaf7a
179 changed files with 4485 additions and 2716 deletions
@@ -1,5 +1,7 @@
import { Injectable } from '@nestjs/common';
import type { TbankFundamentals } from '../../../../../integrations/tbank/tbank.api';
import { CatalogEnrichmentService } from '../../application/catalog-enrichment.service';
import {
StockCompanyResourceDto,
@@ -21,8 +23,8 @@ export class GetStockCompanyUseCase {
observe,
);
return {
data: result.values.instrument
? {
data: result.values.instrument ?
{
description: result.values.description ?? null,
metrics: metrics(
result.values.fundamentals ?? null,
@@ -30,14 +32,14 @@ export class GetStockCompanyUseCase {
),
unavailable: result.unavailable,
observedAt: result.observedAt,
}
: null,
} :
null,
meta: result.meta,
};
}
}
export function metrics(
values: TbankFundamentals | null,
values: null | TbankFundamentals,
sector?: string,
): StockMetricDto[] {
if (!values) return [];
@@ -49,30 +51,31 @@ export function metrics(
][] = [
['marketCapitalization', 'money', null],
['peRatioTtm', 'ratio', 'TTM'],
...(bank
? ([
...(bank ?
([
['priceToBookTtm', 'ratio', 'TTM'],
['roe', 'percent', null],
] as typeof selection)
: ([
] as typeof selection) :
([
['revenueTtm', 'money', 'TTM'],
['ebitdaTtm', 'money', 'TTM'],
] as typeof selection)),
['netIncomeTtm', 'money', 'TTM'],
...(!bank
? ([
...(!bank ?
([
['totalDebtMrq', 'money', 'MRQ'],
['netDebtToEbitda', 'ratio', null],
] as typeof selection)
: []),
] as typeof selection) :
[]),
];
return selection.flatMap(([key, unit, period]) => {
// eslint-disable-next-line security/detect-object-injection -- Keys come from the fixed metric selection declared above.
const value = values[key];
const currency = values.currency?.toUpperCase() || null;
return typeof value === 'number' &&
Number.isFinite(value) &&
(unit !== 'money' || currency)
? [
(unit !== 'money' || currency) ?
[
{
key,
value,
@@ -80,7 +83,7 @@ export function metrics(
period,
currency: unit === 'money' ? currency : null,
},
]
: [];
] :
[];
});
}