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