style: align multiline ternary operators

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent b78c215ff1
commit 183b7f1efd
54 changed files with 986 additions and 982 deletions
+43 -43
View File
@@ -84,16 +84,16 @@ export function planInvestmentScreen(
const unavailable: { reason: string; resourceKey: string }[] = [];
const operations = (from: Date, to: Date, instrumentUid?: string) => {
const targets = accounts.flatMap((account) =>
from < to ?
[
from < to
? [
{
accountId: account.accountId,
from,
to,
...(instrumentUid ? { instrumentUid } : {}),
},
] :
[],
]
: [],
);
sources.push(
...operationIntervals(targets).map((range) => ({
@@ -112,12 +112,12 @@ export function planInvestmentScreen(
})),
);
const knownOpening =
accounts.length && accounts.every((account) => account.openedOn) ?
new Date(
accounts.length && accounts.every((account) => account.openedOn)
? new Date(
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- Code-unit ordering is intentional for canonical keys and ISO dates; locale collation would change persisted bindings.
`${accounts.map((account) => account.openedOn ?? '').sort()[0]}T00:00:00+03:00`,
) :
undefined;
)
: undefined;
if (!context.membershipKnown) return { sources, unavailable, now };
if (
['account', 'accounts', 'bond', 'events', 'stock'].includes(screen.screen)
@@ -146,9 +146,9 @@ export function planInvestmentScreen(
);
for (const range of [
period.selected,
...(screen.screen === 'income' ?
[period.previous, ...(period.yearAgo ? [period.yearAgo] : [])] :
[]),
...(screen.screen === 'income'
? [period.previous, ...(period.yearAgo ? [period.yearAgo] : [])]
: []),
]) {
const bounds = dateOnlyBounds(range, now);
operations(bounds.from, bounds.to);
@@ -216,11 +216,11 @@ export function planInvestmentScreen(
}
const range =
screen.candleRange ??
(period === 'all' ?
instrument.historyFrom ?
{ from: instrument.historyFrom, to: now } :
null :
{ from, to: now });
(period === 'all'
? instrument.historyFrom
? { from: instrument.historyFrom, to: now }
: null
: { from, to: now });
if (range) {
sources.push({
...identity,
@@ -237,17 +237,17 @@ export function planInvestmentScreen(
}
if (['account', 'bond', 'events', 'stock'].includes(screen.screen)) {
const day =
screen.screen === 'stock' || screen.screen === 'bond' ?
moscowDate(now) :
now.toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH);
screen.screen === 'stock' || screen.screen === 'bond'
? moscowDate(now)
: now.toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH);
const from =
screen.screen === 'events' && screen.from ?
new Date(`${screen.from}T00:00:00Z`) :
new Date(`${day}T00:00:00Z`);
screen.screen === 'events' && screen.from
? new Date(`${screen.from}T00:00:00Z`)
: new Date(`${day}T00:00:00Z`);
const to =
screen.screen === 'events' && screen.to ?
new Date(`${screen.to}T00:00:00Z`) :
new Date(from);
screen.screen === 'events' && screen.to
? new Date(`${screen.to}T00:00:00Z`)
: new Date(from);
if (
!(screen.screen === 'events' && screen.to) &&
screen.screen !== 'stock' &&
@@ -309,9 +309,9 @@ export function accountHistory(
): OperationInterval[] {
return accounts.flatMap((account) => {
const from = new Date(
account.openedOn ?
`${account.openedOn}T00:00:00Z` :
'1970-01-01T00:00:00Z',
account.openedOn
? `${account.openedOn}T00:00:00Z`
: '1970-01-01T00:00:00Z',
);
return from < now ? [{ accountId: account.accountId, from, to: now }] : [];
});
@@ -324,22 +324,22 @@ export function ledgerRange(
accounts: Account[],
now: Date,
) {
const opening = accounts.every((account) => account.openedOn) ?
const opening = accounts.every((account) => account.openedOn)
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- Code-unit ordering is intentional for canonical keys and ISO dates; locale collation would change persisted bindings.
accounts.map((account) => account.openedOn ?? '').sort()[0] :
undefined;
const from = fromValue ?
new Date(fromValue) :
instrumentUid ?
new Date(opening ? `${opening}T00:00:00Z` : '1970-01-01T00:00:00Z') :
new Date(Date.UTC(now.getUTCFullYear(), JANUARY_INDEX, FIRST_DAY_OF_MONTH));
const end = toValue ?
new Date(
/^\d{4}-\d{2}-\d{2}$/.test(toValue) ?
`${toValue}T23:59:59.999Z` :
toValue,
) :
now;
? accounts.map((account) => account.openedOn ?? '').sort()[0]
: undefined;
const from = fromValue
? new Date(fromValue)
: instrumentUid
? new Date(opening ? `${opening}T00:00:00Z` : '1970-01-01T00:00:00Z')
: new Date(Date.UTC(now.getUTCFullYear(), JANUARY_INDEX, FIRST_DAY_OF_MONTH));
const end = toValue
? new Date(
/^\d{4}-\d{2}-\d{2}$/.test(toValue)
? `${toValue}T23:59:59.999Z`
: toValue,
)
: now;
return {
from,
to: new Date(Math.min(end.valueOf() + (toValue ? EXCLUSIVE_END_OFFSET_MS : NO_END_OFFSET_MS), now.valueOf())),