Feature/Set prefer-const to error in eslint configuration (#3888)
* Set prefer-const to error in eslint configuration * Update changelog --------- Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
parent
7e339972ad
commit
fc5ed887ff
@ -139,7 +139,6 @@
|
|||||||
"@typescript-eslint/require-await": "warn",
|
"@typescript-eslint/require-await": "warn",
|
||||||
"@typescript-eslint/restrict-template-expressions": "warn",
|
"@typescript-eslint/restrict-template-expressions": "warn",
|
||||||
"@typescript-eslint/unbound-method": "warn",
|
"@typescript-eslint/unbound-method": "warn",
|
||||||
"prefer-const": "warn",
|
|
||||||
|
|
||||||
// The following rules are part of @typescript-eslint/stylistic-type-checked
|
// The following rules are part of @typescript-eslint/stylistic-type-checked
|
||||||
// and can be remove once solved
|
// and can be remove once solved
|
||||||
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Extended the _Public API_ with the health check endpoint (experimental)
|
- Extended the _Public API_ with the health check endpoint (experimental)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Switched the `prefer-const` rule from `warn` to `error` in the `eslint` configuration
|
||||||
|
|
||||||
## 2.113.0 - 2024-10-06
|
## 2.113.0 - 2024-10-06
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -233,7 +233,7 @@ export class AdminService {
|
|||||||
const extendedPrismaClient = this.getExtendedPrismaClient();
|
const extendedPrismaClient = this.getExtendedPrismaClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let [assetProfiles, count] = await Promise.all([
|
const symbolProfileResult = await Promise.all([
|
||||||
extendedPrismaClient.symbolProfile.findMany({
|
extendedPrismaClient.symbolProfile.findMany({
|
||||||
orderBy,
|
orderBy,
|
||||||
skip,
|
skip,
|
||||||
@ -264,6 +264,8 @@ export class AdminService {
|
|||||||
}),
|
}),
|
||||||
this.prismaService.symbolProfile.count({ where })
|
this.prismaService.symbolProfile.count({ where })
|
||||||
]);
|
]);
|
||||||
|
const assetProfiles = symbolProfileResult[0];
|
||||||
|
let count = symbolProfileResult[1];
|
||||||
|
|
||||||
const lastMarketPrices = await this.prismaService.marketData.findMany({
|
const lastMarketPrices = await this.prismaService.marketData.findMany({
|
||||||
distinct: ['dataSource', 'symbol'],
|
distinct: ['dataSource', 'symbol'],
|
||||||
|
@ -234,7 +234,7 @@ export class BenchmarkService {
|
|||||||
return { marketData };
|
return { marketData };
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let marketDataItem of marketDataItems) {
|
for (const marketDataItem of marketDataItems) {
|
||||||
const exchangeRate =
|
const exchangeRate =
|
||||||
exchangeRates[`${currentSymbolItem.currency}${userCurrency}`]?.[
|
exchangeRates[`${currentSymbolItem.currency}${userCurrency}`]?.[
|
||||||
format(marketDataItem.date, DATE_FORMAT)
|
format(marketDataItem.date, DATE_FORMAT)
|
||||||
|
@ -266,21 +266,18 @@ export class ImportService {
|
|||||||
|
|
||||||
const activities: Activity[] = [];
|
const activities: Activity[] = [];
|
||||||
|
|
||||||
for (let [
|
for (const [index, activity] of activitiesExtendedWithErrors.entries()) {
|
||||||
index,
|
const accountId = activity.accountId;
|
||||||
{
|
const comment = activity.comment;
|
||||||
accountId,
|
const currency = activity.currency;
|
||||||
comment,
|
const date = activity.date;
|
||||||
currency,
|
const error = activity.error;
|
||||||
date,
|
let fee = activity.fee;
|
||||||
error,
|
const quantity = activity.quantity;
|
||||||
fee,
|
const SymbolProfile = activity.SymbolProfile;
|
||||||
quantity,
|
const type = activity.type;
|
||||||
SymbolProfile,
|
let unitPrice = activity.unitPrice;
|
||||||
type,
|
|
||||||
unitPrice
|
|
||||||
}
|
|
||||||
] of activitiesExtendedWithErrors.entries()) {
|
|
||||||
const assetProfile = assetProfiles[
|
const assetProfile = assetProfiles[
|
||||||
getAssetProfileIdentifier({
|
getAssetProfileIdentifier({
|
||||||
dataSource: SymbolProfile.dataSource,
|
dataSource: SymbolProfile.dataSource,
|
||||||
@ -491,12 +488,13 @@ export class ImportService {
|
|||||||
userCurrency: string;
|
userCurrency: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
}): Promise<Partial<Activity>[]> {
|
}): Promise<Partial<Activity>[]> {
|
||||||
let { activities: existingActivities } = await this.orderService.getOrders({
|
const { activities: existingActivities } =
|
||||||
userCurrency,
|
await this.orderService.getOrders({
|
||||||
userId,
|
userCurrency,
|
||||||
includeDrafts: true,
|
userId,
|
||||||
withExcludedAccounts: true
|
includeDrafts: true,
|
||||||
});
|
withExcludedAccounts: true
|
||||||
|
});
|
||||||
|
|
||||||
return activitiesDto.map(
|
return activitiesDto.map(
|
||||||
({
|
({
|
||||||
|
@ -217,7 +217,7 @@ export abstract class PortfolioCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let exchangeRatesByCurrency =
|
const exchangeRatesByCurrency =
|
||||||
await this.exchangeRateDataService.getExchangeRatesByCurrency({
|
await this.exchangeRateDataService.getExchangeRatesByCurrency({
|
||||||
currencies: uniq(Object.values(currencies)),
|
currencies: uniq(Object.values(currencies)),
|
||||||
endDate: endOfDay(this.endDate),
|
endDate: endOfDay(this.endDate),
|
||||||
@ -261,7 +261,7 @@ export abstract class PortfolioCalculator {
|
|||||||
|
|
||||||
const daysInMarket = differenceInDays(this.endDate, this.startDate);
|
const daysInMarket = differenceInDays(this.endDate, this.startDate);
|
||||||
|
|
||||||
let chartDateMap = this.getChartDateMap({
|
const chartDateMap = this.getChartDateMap({
|
||||||
endDate: this.endDate,
|
endDate: this.endDate,
|
||||||
startDate: this.startDate,
|
startDate: this.startDate,
|
||||||
step: Math.round(
|
step: Math.round(
|
||||||
@ -701,9 +701,9 @@ export abstract class PortfolioCalculator {
|
|||||||
|
|
||||||
let netPerformanceAtStartDate: number;
|
let netPerformanceAtStartDate: number;
|
||||||
let netPerformanceWithCurrencyEffectAtStartDate: number;
|
let netPerformanceWithCurrencyEffectAtStartDate: number;
|
||||||
let totalInvestmentValuesWithCurrencyEffect: number[] = [];
|
const totalInvestmentValuesWithCurrencyEffect: number[] = [];
|
||||||
|
|
||||||
for (let historicalDataItem of historicalData) {
|
for (const historicalDataItem of historicalData) {
|
||||||
const date = resetHours(parseDate(historicalDataItem.date));
|
const date = resetHours(parseDate(historicalDataItem.date));
|
||||||
|
|
||||||
if (!isBefore(date, start) && !isAfter(date, end)) {
|
if (!isBefore(date, start) && !isAfter(date, end)) {
|
||||||
@ -832,13 +832,13 @@ export abstract class PortfolioCalculator {
|
|||||||
}): { [date: string]: true } {
|
}): { [date: string]: true } {
|
||||||
// Create a map of all relevant chart dates:
|
// Create a map of all relevant chart dates:
|
||||||
// 1. Add transaction point dates
|
// 1. Add transaction point dates
|
||||||
let chartDateMap = this.transactionPoints.reduce((result, { date }) => {
|
const chartDateMap = this.transactionPoints.reduce((result, { date }) => {
|
||||||
result[date] = true;
|
result[date] = true;
|
||||||
return result;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// 2. Add dates between transactions respecting the specified step size
|
// 2. Add dates between transactions respecting the specified step size
|
||||||
for (let date of eachDayOfInterval(
|
for (const date of eachDayOfInterval(
|
||||||
{ end: endDate, start: startDate },
|
{ end: endDate, start: startDate },
|
||||||
{ step }
|
{ step }
|
||||||
)) {
|
)) {
|
||||||
@ -847,7 +847,7 @@ export abstract class PortfolioCalculator {
|
|||||||
|
|
||||||
if (step > 1) {
|
if (step > 1) {
|
||||||
// Reduce the step size of last 90 days
|
// Reduce the step size of last 90 days
|
||||||
for (let date of eachDayOfInterval(
|
for (const date of eachDayOfInterval(
|
||||||
{ end: endDate, start: subDays(endDate, 90) },
|
{ end: endDate, start: subDays(endDate, 90) },
|
||||||
{ step: 3 }
|
{ step: 3 }
|
||||||
)) {
|
)) {
|
||||||
@ -855,7 +855,7 @@ export abstract class PortfolioCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reduce the step size of last 30 days
|
// Reduce the step size of last 30 days
|
||||||
for (let date of eachDayOfInterval(
|
for (const date of eachDayOfInterval(
|
||||||
{ end: endDate, start: subDays(endDate, 30) },
|
{ end: endDate, start: subDays(endDate, 30) },
|
||||||
{ step: 1 }
|
{ step: 1 }
|
||||||
)) {
|
)) {
|
||||||
@ -867,7 +867,7 @@ export abstract class PortfolioCalculator {
|
|||||||
chartDateMap[format(endDate, DATE_FORMAT)] = true;
|
chartDateMap[format(endDate, DATE_FORMAT)] = true;
|
||||||
|
|
||||||
// Make sure some key dates are present
|
// Make sure some key dates are present
|
||||||
for (let dateRange of ['1d', '1y', '5y', 'max', 'mtd', 'wtd', 'ytd']) {
|
for (const dateRange of ['1d', '1y', '5y', 'max', 'mtd', 'wtd', 'ytd']) {
|
||||||
const { endDate: dateRangeEnd, startDate: dateRangeStart } =
|
const { endDate: dateRangeEnd, startDate: dateRangeStart } =
|
||||||
getIntervalFromDateRange(dateRange);
|
getIntervalFromDateRange(dateRange);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
let hasErrors = false;
|
let hasErrors = false;
|
||||||
let netPerformance = new Big(0);
|
let netPerformance = new Big(0);
|
||||||
let totalFeesWithCurrencyEffect = new Big(0);
|
let totalFeesWithCurrencyEffect = new Big(0);
|
||||||
let totalInterestWithCurrencyEffect = new Big(0);
|
const totalInterestWithCurrencyEffect = new Big(0);
|
||||||
let totalInvestment = new Big(0);
|
let totalInvestment = new Big(0);
|
||||||
let totalInvestmentWithCurrencyEffect = new Big(0);
|
let totalInvestmentWithCurrencyEffect = new Big(0);
|
||||||
let totalTimeWeightedInvestment = new Big(0);
|
let totalTimeWeightedInvestment = new Big(0);
|
||||||
@ -156,7 +156,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
[date: string]: Big;
|
[date: string]: Big;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
let totalAccountBalanceInBaseCurrency = new Big(0);
|
const totalAccountBalanceInBaseCurrency = new Big(0);
|
||||||
let totalDividend = new Big(0);
|
let totalDividend = new Big(0);
|
||||||
let totalDividendInBaseCurrency = new Big(0);
|
let totalDividendInBaseCurrency = new Big(0);
|
||||||
let totalInterest = new Big(0);
|
let totalInterest = new Big(0);
|
||||||
@ -320,7 +320,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ordersByDate[dateString]?.length > 0) {
|
if (ordersByDate[dateString]?.length > 0) {
|
||||||
for (let order of ordersByDate[dateString]) {
|
for (const order of ordersByDate[dateString]) {
|
||||||
order.unitPriceFromMarketData =
|
order.unitPriceFromMarketData =
|
||||||
marketSymbolMap[dateString]?.[symbol] ?? lastUnitPrice;
|
marketSymbolMap[dateString]?.[symbol] ?? lastUnitPrice;
|
||||||
}
|
}
|
||||||
@ -813,8 +813,9 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
// return format(date, 'yyyy');
|
// return format(date, 'yyyy');
|
||||||
// })
|
// })
|
||||||
]) {
|
]) {
|
||||||
// TODO: getIntervalFromDateRange(dateRange, start)
|
const dateInterval = getIntervalFromDateRange(dateRange);
|
||||||
let { endDate, startDate } = getIntervalFromDateRange(dateRange);
|
const endDate = dateInterval.endDate;
|
||||||
|
let startDate = dateInterval.startDate;
|
||||||
|
|
||||||
if (isBefore(startDate, start)) {
|
if (isBefore(startDate, start)) {
|
||||||
startDate = start;
|
startDate = start;
|
||||||
|
@ -943,7 +943,9 @@ export class PortfolioService {
|
|||||||
currency: this.request.user.Settings.settings.baseCurrency
|
currency: this.request.user.Settings.settings.baseCurrency
|
||||||
});
|
});
|
||||||
|
|
||||||
let { hasErrors, positions } = await portfolioCalculator.getSnapshot();
|
const portfolioSnapshot = await portfolioCalculator.getSnapshot();
|
||||||
|
const hasErrors = portfolioSnapshot.hasErrors;
|
||||||
|
let positions = portfolioSnapshot.positions;
|
||||||
|
|
||||||
positions = positions.filter(({ quantity }) => {
|
positions = positions.filter(({ quantity }) => {
|
||||||
return !quantity.eq(0);
|
return !quantity.eq(0);
|
||||||
@ -1984,7 +1986,7 @@ export class PortfolioService {
|
|||||||
SymbolProfile,
|
SymbolProfile,
|
||||||
type
|
type
|
||||||
} of ordersByAccount) {
|
} of ordersByAccount) {
|
||||||
let currentValueOfSymbolInBaseCurrency =
|
const currentValueOfSymbolInBaseCurrency =
|
||||||
getFactor(type) *
|
getFactor(type) *
|
||||||
quantity *
|
quantity *
|
||||||
(portfolioItemsNow[SymbolProfile.symbol]?.marketPriceInBaseCurrency ??
|
(portfolioItemsNow[SymbolProfile.symbol]?.marketPriceInBaseCurrency ??
|
||||||
|
@ -56,7 +56,7 @@ export class UserService {
|
|||||||
{ Account, id, permissions, Settings, subscription }: UserWithSettings,
|
{ Account, id, permissions, Settings, subscription }: UserWithSettings,
|
||||||
aLocale = locale
|
aLocale = locale
|
||||||
): Promise<IUser> {
|
): Promise<IUser> {
|
||||||
let [access, firstActivity, tags] = await Promise.all([
|
const accessesResult = await Promise.all([
|
||||||
this.prismaService.access.findMany({
|
this.prismaService.access.findMany({
|
||||||
include: {
|
include: {
|
||||||
User: true
|
User: true
|
||||||
@ -72,6 +72,9 @@ export class UserService {
|
|||||||
}),
|
}),
|
||||||
this.tagService.getInUseByUser(id)
|
this.tagService.getInUseByUser(id)
|
||||||
]);
|
]);
|
||||||
|
const access = accessesResult[0];
|
||||||
|
const firstActivity = accessesResult[1];
|
||||||
|
let tags = accessesResult[2];
|
||||||
|
|
||||||
let systemMessage: SystemMessage;
|
let systemMessage: SystemMessage;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export class OpenFigiDataEnhancerService implements DataEnhancerInterface {
|
|||||||
this.configurationService.get('API_KEY_OPEN_FIGI');
|
this.configurationService.get('API_KEY_OPEN_FIGI');
|
||||||
}
|
}
|
||||||
|
|
||||||
let abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
|
@ -458,7 +458,9 @@ export class DataProviderService {
|
|||||||
|
|
||||||
promises.push(
|
promises.push(
|
||||||
promise.then(async (result) => {
|
promise.then(async (result) => {
|
||||||
for (let [symbol, dataProviderResponse] of Object.entries(result)) {
|
for (const [symbol, dataProviderResponse] of Object.entries(
|
||||||
|
result
|
||||||
|
)) {
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
...DERIVED_CURRENCIES.map(({ currency }) => {
|
...DERIVED_CURRENCIES.map(({ currency }) => {
|
||||||
@ -577,7 +579,7 @@ export class DataProviderService {
|
|||||||
return { items: lookupItems };
|
return { items: lookupItems };
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataProviderServices = this.configurationService
|
const dataProviderServices = this.configurationService
|
||||||
.get('DATA_SOURCES')
|
.get('DATA_SOURCES')
|
||||||
.map((dataSource) => {
|
.map((dataSource) => {
|
||||||
return this.getDataProvider(DataSource[dataSource]);
|
return this.getDataProvider(DataSource[dataSource]);
|
||||||
|
@ -203,7 +203,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT'),
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT'),
|
||||||
symbols
|
symbols
|
||||||
}: GetQuotesParams): Promise<{ [symbol: string]: IDataProviderResponse }> {
|
}: GetQuotesParams): Promise<{ [symbol: string]: IDataProviderResponse }> {
|
||||||
let response: { [symbol: string]: IDataProviderResponse } = {};
|
const response: { [symbol: string]: IDataProviderResponse } = {};
|
||||||
|
|
||||||
if (symbols.length <= 0) {
|
if (symbols.length <= 0) {
|
||||||
return response;
|
return response;
|
||||||
|
@ -63,11 +63,11 @@ export class ExchangeRateDataService {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
let exchangeRatesByCurrency: {
|
const exchangeRatesByCurrency: {
|
||||||
[currency: string]: { [dateString: string]: number };
|
[currency: string]: { [dateString: string]: number };
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
for (let currency of currencies) {
|
for (const currency of currencies) {
|
||||||
exchangeRatesByCurrency[`${currency}${targetCurrency}`] =
|
exchangeRatesByCurrency[`${currency}${targetCurrency}`] =
|
||||||
await this.getExchangeRates({
|
await this.getExchangeRates({
|
||||||
startDate,
|
startDate,
|
||||||
@ -94,7 +94,7 @@ export class ExchangeRateDataService {
|
|||||||
!isBefore(date, startDate);
|
!isBefore(date, startDate);
|
||||||
date = subDays(resetHours(date), 1)
|
date = subDays(resetHours(date), 1)
|
||||||
) {
|
) {
|
||||||
let dateString = format(date, DATE_FORMAT);
|
const dateString = format(date, DATE_FORMAT);
|
||||||
|
|
||||||
// Check if the exchange rate for the current date is missing
|
// Check if the exchange rate for the current date is missing
|
||||||
if (
|
if (
|
||||||
@ -351,7 +351,7 @@ export class ExchangeRateDataService {
|
|||||||
startDate: Date;
|
startDate: Date;
|
||||||
}) {
|
}) {
|
||||||
const dates = eachDayOfInterval({ end: endDate, start: startDate });
|
const dates = eachDayOfInterval({ end: endDate, start: startDate });
|
||||||
let factors: { [dateString: string]: number } = {};
|
const factors: { [dateString: string]: number } = {};
|
||||||
|
|
||||||
if (currencyFrom === currencyTo) {
|
if (currencyFrom === currencyTo) {
|
||||||
for (const date of dates) {
|
for (const date of dates) {
|
||||||
@ -379,10 +379,10 @@ export class ExchangeRateDataService {
|
|||||||
} else {
|
} else {
|
||||||
// Calculate indirectly via base currency
|
// Calculate indirectly via base currency
|
||||||
|
|
||||||
let marketPriceBaseCurrencyFromCurrency: {
|
const marketPriceBaseCurrencyFromCurrency: {
|
||||||
[dateString: string]: number;
|
[dateString: string]: number;
|
||||||
} = {};
|
} = {};
|
||||||
let marketPriceBaseCurrencyToCurrency: {
|
const marketPriceBaseCurrencyToCurrency: {
|
||||||
[dateString: string]: number;
|
[dateString: string]: number;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onExport() {
|
public onExport() {
|
||||||
let activityIds = this.dataSource.data.map(({ id }) => {
|
const activityIds = this.dataSource.data.map(({ id }) => {
|
||||||
return id;
|
return id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onExport() {
|
public onExport() {
|
||||||
let activityIds = this.dataSource.data.map(({ id }) => {
|
const activityIds = this.dataSource.data.map(({ id }) => {
|
||||||
return id;
|
return id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ export class DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public deleteActivities({ filters }) {
|
public deleteActivities({ filters }) {
|
||||||
let params = this.buildFiltersAsQueryParams({ filters });
|
const params = this.buildFiltersAsQueryParams({ filters });
|
||||||
|
|
||||||
return this.http.delete<any>(`/api/v1/order`, { params });
|
return this.http.delete<any>(`/api/v1/order`, { params });
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ export function extractNumberFromString({
|
|||||||
// Remove non-numeric characters (excluding international formatting characters)
|
// Remove non-numeric characters (excluding international formatting characters)
|
||||||
const numericValue = value.replace(/[^\d.,'’\s]/g, '');
|
const numericValue = value.replace(/[^\d.,'’\s]/g, '');
|
||||||
|
|
||||||
let parser = new NumberParser(locale);
|
const parser = new NumberParser(locale);
|
||||||
|
|
||||||
return parser.parse(numericValue);
|
return parser.parse(numericValue);
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user