Browse Source

Merge 7c39ed2a63 into 82cee20f2d

pull/7925/merge
Suraj2105-1 16 hours ago
committed by GitHub
parent
commit
97dbf8fc46
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 310
      eslint.config.cjs
  3. 3
      package.json

28
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -319,6 +319,10 @@ export abstract class PortfolioCalculator {
[date: string]: { [assetProfileIdentifier: string]: Big };
} = {};
const latestMarketPriceMap: {
[assetProfileIdentifier: string]: { date: string; price: Big };
} = {};
for (const marketSymbol of marketSymbols) {
const date = format(marketSymbol.date, DATE_FORMAT);
@ -327,13 +331,33 @@ export abstract class PortfolioCalculator {
}
if (marketSymbol.marketPrice) {
marketSymbolMap[date][getAssetProfileIdentifier(marketSymbol)] =
new Big(marketSymbol.marketPrice);
const identifier = getAssetProfileIdentifier(marketSymbol);
const price = new Big(marketSymbol.marketPrice);
marketSymbolMap[date][identifier] = price;
if (
!latestMarketPriceMap[identifier] ||
latestMarketPriceMap[identifier].date < date
) {
latestMarketPriceMap[identifier] = { date, price };
}
}
}
const endDateString = format(this.endDate, DATE_FORMAT);
if (!marketSymbolMap[endDateString]) {
marketSymbolMap[endDateString] = {};
}
for (const identifier of Object.keys(latestMarketPriceMap)) {
if (!marketSymbolMap[endDateString][identifier]) {
marketSymbolMap[endDateString][identifier] =
latestMarketPriceMap[identifier].price;
}
}
const daysInMarket = differenceInDays(this.endDate, this.startDate);
const chartDateMap = this.getChartDateMap({

310
eslint.config.cjs

@ -1,19 +1,14 @@
const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const nxEslintPlugin = require('@nx/eslint-plugin');
const nx = require('@nx/eslint-plugin');
const storybook = require('eslint-plugin-storybook');
const tseslint = require('typescript-eslint');
const importPlugin = require('eslint-plugin-import');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
});
module.exports = [
module.exports = tseslint.config(
{
ignores: ['**/dist']
},
...storybook.configs['flat/recommended'],
{ plugins: { '@nx': nxEslintPlugin } },
{ plugins: { '@nx': nx } },
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
@ -35,160 +30,149 @@ module.exports = [
'no-extra-semi': 'off'
}
},
...compat
.config({
extends: ['plugin:@nx/typescript']
})
.map((config) => ({
...config,
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
rules: {
...config.rules
}
})),
...compat
.config({
extends: ['plugin:@nx/javascript']
})
.map((config) => ({
...config,
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
rules: {
...config.rules
...nx.configs['flat/typescript'].map((config) => ({
...config,
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
})),
...nx.configs['flat/javascript'].map((config) => ({
...config,
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
})),
{
files: ['**/*.ts'],
extends: [
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked
],
plugins: {
import: importPlugin
},
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname
}
})),
...compat
.config({
plugins: ['eslint-plugin-import', '@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked'
]
})
.map((config) => ({
...config,
files: ['**/*.ts'],
rules: {
...config.rules,
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'off',
{
accessibility: 'explicit'
}
],
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/naming-convention': [
'off',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: ['variable', 'classProperty', 'typeProperty'],
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: 'objectLiteralProperty',
format: null
},
{
selector: 'enumMember',
format: ['camelCase', 'UPPER_CASE', 'PascalCase']
},
{
selector: 'typeLike',
format: ['PascalCase']
}
],
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-inferrable-types': [
'warn',
{
ignoreParameters: true
}
],
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-shadow': [
'warn',
{
hoist: 'all'
}
],
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-loss-of-precision': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'arrow-body-style': 'off',
'constructor-super': 'error',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'warn',
'id-blacklist': 'off',
'id-match': 'off',
'import/no-deprecated': 'warn',
'no-bitwise': 'error',
'no-caller': 'error',
'no-debugger': 'error',
'no-empty': 'off',
'no-eval': 'error',
'no-fallthrough': 'error',
'no-new-wrappers': 'error',
'no-restricted-imports': ['error', 'rxjs/Rx'],
'no-undef-init': 'error',
'no-underscore-dangle': 'off',
'no-var': 'error',
radix: 'error',
'no-unsafe-optional-chaining': 'warn',
'no-extra-boolean-cast': 'warn',
'no-empty-pattern': 'warn',
'no-useless-catch': 'warn',
'no-unsafe-finally': 'warn',
'no-prototype-builtins': 'warn',
'no-async-promise-executor': 'warn',
'no-constant-condition': 'warn',
},
rules: {
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'off',
{
accessibility: 'explicit'
}
],
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/naming-convention': [
'off',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: ['variable', 'classProperty', 'typeProperty'],
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow'
},
{
selector: 'objectLiteralProperty',
format: null
},
{
selector: 'enumMember',
format: ['camelCase', 'UPPER_CASE', 'PascalCase']
},
{
selector: 'typeLike',
format: ['PascalCase']
}
],
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-inferrable-types': [
'warn',
{
ignoreParameters: true
}
],
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-shadow': [
'warn',
{
hoist: 'all'
}
],
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-loss-of-precision': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'arrow-body-style': 'off',
'constructor-super': 'error',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'warn',
'id-blacklist': 'off',
'id-match': 'off',
'import/no-deprecated': 'warn',
'no-bitwise': 'error',
'no-caller': 'error',
'no-debugger': 'error',
'no-empty': 'off',
'no-eval': 'error',
'no-fallthrough': 'error',
'no-new-wrappers': 'error',
'no-restricted-imports': ['error', 'rxjs/Rx'],
'no-undef-init': 'error',
'no-underscore-dangle': 'off',
'no-var': 'error',
radix: 'error',
'no-unsafe-optional-chaining': 'warn',
'no-extra-boolean-cast': 'warn',
'no-empty-pattern': 'warn',
'no-useless-catch': 'warn',
'no-unsafe-finally': 'warn',
'no-prototype-builtins': 'warn',
'no-async-promise-executor': 'warn',
'no-constant-condition': 'warn',
// The following rules are part of eslint:recommended
// and can be remove once solved
'no-loss-of-precision': 'warn',
// The following rules are part of eslint:recommended
// and can be remove once solved
'no-loss-of-precision': 'warn',
// The following rules are part of @typescript-eslint/recommended-type-checked
// and can be remove once solved
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none'
}
],
'@typescript-eslint/no-wrapper-object-types': 'warn',
'@typescript-eslint/only-throw-error': 'warn',
'@typescript-eslint/prefer-promise-reject-errors': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/unbound-method': 'warn',
// The following rules are part of @typescript-eslint/recommended-type-checked
// and can be remove once solved
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none'
}
],
'@typescript-eslint/no-wrapper-object-types': 'warn',
'@typescript-eslint/only-throw-error': 'warn',
'@typescript-eslint/prefer-promise-reject-errors': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/unbound-method': 'warn',
// The following rules are part of @typescript-eslint/stylistic-type-checked
// and can be remove once solved
'@typescript-eslint/prefer-nullish-coalescing': 'warn' // TODO: Requires strictNullChecks: true
}
}))
];
// The following rules are part of @typescript-eslint/stylistic-type-checked
// and can be remove once solved
'@typescript-eslint/prefer-nullish-coalescing': 'warn' // TODO: Requires strictNullChecks: true
}
}
);

3
package.json

@ -166,8 +166,6 @@
"@angular/language-service": "22.1.2",
"@angular/localize": "22.1.2",
"@angular/pwa": "22.1.4",
"@eslint/eslintrc": "3.3.1",
"@eslint/js": "9.35.0",
"@nestjs/schematics": "11.1.0",
"@nestjs/testing": "11.2.3",
"@nx/angular": "23.1.1",
@ -221,6 +219,7 @@
"ts-node": "10.9.2",
"tslib": "2.8.1",
"typescript": "6.0.3",
"typescript-eslint": "8.67.0",
"webpack-cli": "7.1.0"
},
"engines": {

Loading…
Cancel
Save