chore: finish frontend ESLint migration #18

Enable every plugin recommended preset and replace Biome with ESLint formatting.

Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
This commit is contained in:
2026-09-28 16:36:40 +03:00
committed by ksv741
parent 57630102e4
commit 72d7835227
253 changed files with 10059 additions and 8864 deletions
@@ -1,34 +1,36 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { MemoryRouter } from "react-router";
import type { BrokerageAccount } from "../../api/useBrokerageAccounts";
import { brokerageAccountCards } from "../../model/display";
import { BrokerageAccountList } from "./BrokerageAccountList";
const syntheticAccount = {
id: "storybook-account",
name: "Учебный брокерский счёт",
type: "BROKERAGE",
openedOn: "2025-03-15",
portfolioSummary: {
stockPositionCount: 5,
bondPositionCount: 12,
stockPositionCount: 5,
totalsByCurrency: [
{ currency: "RUB", value: "125000.50" },
{ currency: "USD", value: "320" },
{ currency: "EUR", value: "210" },
],
},
type: "BROKERAGE",
} satisfies BrokerageAccount;
const meta = {
title: "Product/BrokerageAccountList",
component: BrokerageAccountList,
tags: ["autodocs"],
args: { accounts: brokerageAccountCards([syntheticAccount]) },
argTypes: {
accounts: { control: false },
},
component: BrokerageAccountList,
decorators: [
(Story) => (
Story => (
<MemoryRouter initialEntries={["/accounts"]}>
<Story />
</MemoryRouter>
@@ -42,7 +44,8 @@ const meta = {
},
},
},
args: { accounts: brokerageAccountCards([syntheticAccount]) },
tags: ["autodocs"],
title: "Product/BrokerageAccountList",
} satisfies Meta<typeof BrokerageAccountList>;
export default meta;
@@ -61,37 +64,39 @@ export const Available: Story = {
},
};
export const Unavailable: Story = {
name: "Сводка недоступна",
args: {
accounts: brokerageAccountCards([
{ ...syntheticAccount, portfolioSummary: null, openedOn: null },
]),
},
parameters: {
docs: {
description: {
story:
export const Unavailable: Story = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
args: {
accounts: brokerageAccountCards([
{ ...syntheticAccount, openedOn: null, portfolioSummary: null },
]),
},
name: "Сводка недоступна",
parameters: {
docs: {
description: {
story:
"Счёт остаётся доступен для открытия, даже если сводка временно недоступна. Неизвестные суммы не заменяются нулём; отсутствующая дата открытия не отображается.",
},
},
},
},
};
}
/* eslint-enable unicorn/no-null */);
export const Empty: Story = {
name: "Нет текущих сумм",
args: {
accounts: brokerageAccountCards([
{
...syntheticAccount,
portfolioSummary: {
totalsByCurrency: [],
stockPositionCount: 0,
bondPositionCount: 0,
stockPositionCount: 0,
totalsByCurrency: [],
},
},
]),
},
name: "Нет текущих сумм",
parameters: {
docs: {
description: {
@@ -103,7 +108,6 @@ export const Empty: Story = {
};
export const LongName: Story = {
name: "Длинное название счёта",
args: {
accounts: brokerageAccountCards([
{
@@ -113,6 +117,7 @@ export const LongName: Story = {
},
]),
},
name: "Длинное название счёта",
parameters: {
docs: {
description: {
@@ -124,105 +129,107 @@ export const LongName: Story = {
};
export const AccountGrid: Story = {
name: "Несколько счетов",
args: {
accounts: brokerageAccountCards([
{
...syntheticAccount,
name: "Основной",
portfolioSummary: {
totalsByCurrency: [{ currency: "RUB", value: "1256430.50" }],
stockPositionCount: 8,
bondPositionCount: 14,
stockPositionCount: 8,
totalsByCurrency: [{ currency: "RUB", value: "1256430.50" }],
},
},
{
...syntheticAccount,
id: "storybook-iis",
name: "Долгосрочные инвестиции",
type: "INDIVIDUAL_INVESTMENT",
portfolioSummary: {
totalsByCurrency: [{ currency: "RUB", value: "480250" }],
stockPositionCount: 0,
bondPositionCount: 6,
stockPositionCount: 0,
totalsByCurrency: [{ currency: "RUB", value: "480250" }],
},
type: "INDIVIDUAL_INVESTMENT",
},
]),
},
name: "Несколько счетов",
};
export const UnvaluedPositions: Story = {
name: "Бумаги без текущей оценки",
args: {
accounts: brokerageAccountCards([
{
...syntheticAccount,
portfolioSummary: {
totalsByCurrency: [],
stockPositionCount: 2,
bondPositionCount: 1,
stockPositionCount: 2,
totalsByCurrency: [],
},
},
]),
},
name: "Бумаги без текущей оценки",
};
export const LargeValues: Story = {
name: "Длинные суммы",
args: {
accounts: brokerageAccountCards([
{
...syntheticAccount,
portfolioSummary: {
bondPositionCount: 105,
stockPositionCount: 21,
totalsByCurrency: [
{ currency: "RUB", value: "1234567890123456789.50" },
{ currency: "USD", value: "-9876543210987654321.50" },
],
stockPositionCount: 21,
bondPositionCount: 105,
},
},
]),
},
name: "Длинные суммы",
};
export const IndependentFreshness: Story = {
name: "Независимая свежесть и ошибка сводок",
args: {
accounts: brokerageAccountCards(
[
syntheticAccount,
{
...syntheticAccount,
id: "waiting",
name: "Новый счёт",
portfolioSummary: null,
},
],
[
{
resourceKey: "portfolio/storybook-account",
dataRevision: "1",
stateVersion: "failed",
availability: "complete",
freshness: "stale",
lastSuccessfulAt: "2026-09-24T10:30:00Z",
sync: {
id: "failed",
state: "failed",
errorCode: "TBANK_UNAVAILABLE",
export const IndependentFreshness: Story = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
args: {
accounts: brokerageAccountCards(
[
syntheticAccount,
{
...syntheticAccount,
id: "waiting",
name: "Новый счёт",
portfolioSummary: null,
},
},
{
resourceKey: "portfolio/waiting",
dataRevision: "0",
stateVersion: "waiting",
availability: "missing",
freshness: "unknown",
lastSuccessfulAt: null,
sync: { id: "waiting", state: "running", errorCode: null },
},
],
),
},
};
],
[
{
availability: "complete",
dataRevision: "1",
freshness: "stale",
lastSuccessfulAt: "2026-09-24T10:30:00Z",
resourceKey: "portfolio/storybook-account",
stateVersion: "failed",
sync: {
errorCode: "TBANK_UNAVAILABLE",
id: "failed",
state: "failed",
},
},
{
availability: "missing",
dataRevision: "0",
freshness: "unknown",
lastSuccessfulAt: null,
resourceKey: "portfolio/waiting",
stateVersion: "waiting",
sync: { errorCode: null, id: "waiting", state: "running" },
},
],
),
},
name: "Независимая свежесть и ошибка сводок",
}
/* eslint-enable unicorn/no-null */);
@@ -2,7 +2,9 @@ import { MantineProvider } from "@mantine/core";
import { render, screen, within } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it } from "vitest";
import { resource } from "@/test/resource";
import { brokerageAccountCards } from "../../model/display";
import { BrokerageAccountList } from "./BrokerageAccountList";
@@ -16,36 +18,40 @@ describe("BrokerageAccountList", () => {
{
id: "account-1",
name: "Основной",
type: "BROKERAGE",
openedOn: "2024-08-13",
portfolioSummary: {
stockPositionCount: 5,
bondPositionCount: 12,
stockPositionCount: 5,
totalsByCurrency: [
{ currency: "RUB", value: "1500" },
{ currency: "USD", value: "20" },
{ currency: "EUR", value: "5" },
],
},
},
{
id: "account-2",
name: "Недоступный",
type: "BROKERAGE",
openedOn: null,
portfolioSummary: null,
},
{
id: "account-3",
name: "Пустой",
type: "BROKERAGE",
openedOn: null,
portfolioSummary: {
totalsByCurrency: [],
stockPositionCount: 2,
bondPositionCount: 0,
},
},
(/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
id: "account-2",
name: "Недоступный",
openedOn: null,
portfolioSummary: null,
type: "BROKERAGE",
}
/* eslint-enable unicorn/no-null */),
(/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
id: "account-3",
name: "Пустой",
openedOn: null,
portfolioSummary: {
bondPositionCount: 0,
stockPositionCount: 2,
totalsByCurrency: [],
},
type: "BROKERAGE",
}
/* eslint-enable unicorn/no-null */),
])}
/>
</MemoryRouter>
@@ -65,18 +71,18 @@ describe("BrokerageAccountList", () => {
expect(screen.getByText("Нет текущих сумм")).toBeInTheDocument();
expect(screen.getAllByText("Открыть счет")).toHaveLength(3);
const available = within(screen.getByRole("link", { name: /Основной/ }));
expect(available.getByText("Акции").nextElementSibling).toHaveTextContent(
expect(available.getAllByRole("definition")[0]).toHaveTextContent(
"5",
);
expect(
available.getByText("Облигации").nextElementSibling,
available.getAllByRole("definition")[1],
).toHaveTextContent("12");
const unvalued = within(screen.getByRole("link", { name: /Пустой/ }));
expect(unvalued.getByText("Акции").nextElementSibling).toHaveTextContent(
expect(unvalued.getAllByRole("definition")[0]).toHaveTextContent(
"2",
);
expect(
unvalued.getByText("Облигации").nextElementSibling,
unvalued.getAllByRole("definition")[1],
).toHaveTextContent("0");
expect(
within(screen.getByRole("link", { name: /Недоступный/ })).queryByText(
@@ -88,21 +94,23 @@ describe("BrokerageAccountList", () => {
it("shows portfolio summary freshness independently for each account", () => {
const accounts = brokerageAccountCards(
["fresh", "stale"].map((id) => ({
id,
name: id,
type: "BROKERAGE" as const,
openedOn: null,
portfolioSummary: {
stockPositionCount: 1,
bondPositionCount: 0,
totalsByCurrency: [{ currency: "RUB", value: "10" }],
},
})),
["fresh", "stale"].map(id => ((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
id,
name: id,
openedOn: null,
portfolioSummary: {
bondPositionCount: 0,
stockPositionCount: 1,
totalsByCurrency: [{ currency: "RUB", value: "10" }],
},
type: "BROKERAGE" as const,
}
/* eslint-enable unicorn/no-null */))),
[
resource(null, { resourceKey: "portfolio/fresh", freshness: "fresh" })
resource(null, { freshness: "fresh", resourceKey: "portfolio/fresh" })
.meta,
resource(null, { resourceKey: "portfolio/stale", freshness: "stale" })
resource(null, { freshness: "stale", resourceKey: "portfolio/stale" })
.meta,
],
);
@@ -1,9 +1,13 @@
import { Card, Group, SimpleGrid, Stack, Text } from "@mantine/core";
import type { FC } from "react";
import { Card, Group, SimpleGrid, Stack, Text } from "@mantine/core";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { formatDate, formatMoney, formatSnapshotTime } from "@/shared/lib";
import type { BrokerageAccountCard } from "../../model/display";
import { accountTypeKey } from "../../model/display";
import classes from "./BrokerageAccountList.module.css";
@@ -31,18 +35,18 @@ const BrokerageAccountSummary: FC<BrokerageAccountSummaryProps> = (props) => {
return (
<Stack className={classes.summary} gap={4}>
{summary.totals.map((total) => (
{summary.totals.map(total => (
<Text className={classes.total} fw={700} key={total.currency}>
{formatMoney(total)}
</Text>
))}
{summary.remainingCurrencyCount ? (
{!!(summary.remainingCurrencyCount) && ((
<Text c="dimmed" size="sm">
{t("accounts.remainingCurrencies", {
count: summary.remainingCurrencyCount,
})}
</Text>
) : null}
))}
</Stack>
);
};
@@ -53,37 +57,37 @@ const BrokerageAccountList: FC<BrokerageAccountListProps> = (props) => {
return (
<SimpleGrid className={classes.list} cols={1} spacing="lg">
{accounts.map(({ account, summary, positionCounts, source }) => (
{accounts.map(({ account, positionCounts, source, summary }) => (
<Card
component={Link}
to={`/accounts/${account.id}`}
key={account.id}
className={classes.card}
component={Link}
key={account.id}
padding="xl"
radius="lg"
to={`/accounts/${account.id}`}
withBorder
>
<Stack className={classes.identity} gap="sm">
<Group justify="space-between" wrap="nowrap" gap="sm">
<Text className={classes.kicker} size="xs" fw={700}>
<Group gap="sm" justify="space-between" wrap="nowrap">
<Text className={classes.kicker} fw={700} size="xs">
{t(accountTypeKey(account.type))}
</Text>
<svg
aria-hidden="true"
className={classes.accountIcon}
viewBox="0 0 24 24"
fill="none"
focusable="false"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
focusable="false"
strokeWidth="1.5"
viewBox="0 0 24 24"
>
<rect x="3" y="5" width="18" height="15" rx="3" />
<rect height="15" rx="3" width="18" x="3" y="5" />
<path d="M3 9h18M7 15h3M14 5V3H7a4 4 0 0 0-4 4" />
</svg>
</Group>
<Text component="h2" className={classes.name} fw={700}>
<Text className={classes.name} component="h2" fw={700}>
{account.name}
</Text>
</Stack>
@@ -92,27 +96,27 @@ const BrokerageAccountList: FC<BrokerageAccountListProps> = (props) => {
{t("accounts.currentValue")}
</Text>
<BrokerageAccountSummary summary={summary} />
{source?.lastSuccessfulAt ? (
<Text size="xs" c="dimmed">
{!!(source?.lastSuccessfulAt) && ((
<Text c="dimmed" size="xs">
{t("investment.sourceTime", {
date: formatSnapshotTime(source.lastSuccessfulAt),
})}
</Text>
) : null}
{source?.sync.state === "running" ||
source?.sync.state === "queued" ? (
<Text size="xs" role="status">
))}
{(source?.sync.state === "running"
|| source?.sync.state === "queued") && ((
<Text role="status" size="xs">
{t("accounts.refreshing")}
</Text>
) : null}
{source?.sync.state === "failed" ? (
))}
{(source?.sync.state === "failed") && ((
<Text size="xs">{t("accounts.refreshError")}</Text>
) : null}
{source?.freshness === "stale" ? (
))}
{(source?.freshness === "stale") && ((
<Text size="xs">{t("investment.stale")}</Text>
) : null}
))}
</Stack>
{positionCounts ? (
{!!(positionCounts) && ((
<dl className={classes.positions}>
<div className={classes.stocks}>
<dt>{t("accounts.stocks")}</dt>
@@ -127,18 +131,18 @@ const BrokerageAccountList: FC<BrokerageAccountListProps> = (props) => {
</dd>
</div>
</dl>
) : null}
<Group className={classes.footer} justify="space-between" gap="sm">
{account.openedOn ? (
))}
<Group className={classes.footer} gap="sm" justify="space-between">
{!!(account.openedOn) && ((
<Text c="dimmed" size="xs">
{t("accounts.openedOn", {
date: formatDate(account.openedOn),
})}
</Text>
) : null}
<Text component="span" className={classes.open} size="sm" fw={600}>
))}
<Text className={classes.open} component="span" fw={600} size="sm">
{t("accounts.openAccount")}
<span className={classes.arrow} aria-hidden="true">
<span aria-hidden="true" className={classes.arrow}>
→
</span>
</Text>