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,7 +1,10 @@
import { EntryCard } from "@wealthledger/ui";
import type { FC } from "react";
import { EntryCard } from "@wealthledger/ui";
import { useTranslation } from "react-i18next";
import { formatDate, formatMoney, instrumentLogoUrl } from "@/shared/lib";
import type { BrokerageEvent } from "../api/useBrokerageEvents";
type BrokerageEventCardProps = { event: BrokerageEvent };
@@ -14,7 +17,7 @@ const BrokerageEventCard: FC<BrokerageEventCardProps> = (props) => {
const metadata = [
date,
event.dateKind === "registry" ? t("events.dateKind.registry") : null,
event.dateKind === "registry" ? t("events.dateKind.registry") : /* eslint-disable-line unicorn/no-null -- Preserve the nullable domain value consumed by this view model. */ null,
event.isin,
event.account?.name,
]
@@ -23,19 +26,19 @@ const BrokerageEventCard: FC<BrokerageEventCardProps> = (props) => {
return (
<EntryCard
title={`${t(`events.type.${event.type}`)} · ${event.displayName}`}
metadata={metadata}
imageSrc={instrumentLogoUrl(event.logoName)}
initial={(
(event.ticker ?? event.displayName).trim()[0] ?? "?"
).toUpperCase()}
imageSrc={instrumentLogoUrl(event.logoName)}
metadata={metadata}
title={[t(`events.type.${event.type}`), event.displayName].join(" · ")}
tone="neutral"
value={
event.projectedAmount
? formatMoney(event.projectedAmount)
: t("events.noAmount")
}
valueLabel={t("events.projectedAmount")}
tone="neutral"
/>
);
};
@@ -1,32 +1,53 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { MemoryRouter } from "react-router";
import type { BrokerageEvent } from "../../api/useBrokerageEvents";
import { BrokerageEventsPreview } from "./BrokerageEventsPreview";
const syntheticEvent = {
type: "coupon",
const syntheticEvent = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
date: "2026-10-15",
dateKind: "event",
displayName: "Учебные облигации",
figi: null,
instrumentUid: null,
ticker: "DEMO",
displayName: "Учебные облигации",
logoName: null,
isin: "RU000A0JX0J2",
logoName: null,
projectedAmount: { currency: "RUB", value: "850.50" },
} satisfies BrokerageEvent;
ticker: "DEMO",
type: "coupon",
}
/* eslint-enable unicorn/no-null */) satisfies BrokerageEvent;
const eventsPath = "/accounts/storybook-account/events";
const meta = {
title: "Product/RecentEvents",
component: BrokerageEventsPreview,
tags: ["autodocs"],
args: {
events: {
items: [
syntheticEvent,
{
...syntheticEvent,
date: "2026-11-01",
dateKind: "registry",
displayName: "Учебные технологии",
projectedAmount: { currency: "RUB", value: "1200" },
ticker: "EXAMPLE",
type: "dividend",
},
],
state: "loaded",
to: eventsPath,
},
},
argTypes: {
events: { control: false },
},
component: BrokerageEventsPreview,
decorators: [
(Story) => (
Story => (
<MemoryRouter initialEntries={["/accounts/storybook-account"]}>
<Story />
</MemoryRouter>
@@ -40,24 +61,8 @@ const meta = {
},
},
},
args: {
events: {
state: "loaded",
to: eventsPath,
items: [
syntheticEvent,
{
...syntheticEvent,
type: "dividend",
date: "2026-11-01",
dateKind: "registry",
ticker: "EXAMPLE",
displayName: "Учебные технологии",
projectedAmount: { currency: "RUB", value: "1200" },
},
],
},
},
tags: ["autodocs"],
title: "Product/RecentEvents",
} satisfies Meta<typeof BrokerageEventsPreview>;
export default meta;
@@ -77,8 +82,8 @@ export const Loaded: Story = {
};
export const Loading: Story = {
name: "Загрузка раздела",
args: { events: { state: "loading", to: eventsPath } },
name: "Загрузка раздела",
parameters: {
docs: {
description: {
@@ -90,8 +95,8 @@ export const Loading: Story = {
};
export const Failed: Story = {
name: "Ошибка получения событий",
args: { events: { state: "error", to: eventsPath } },
name: "Ошибка получения событий",
parameters: {
docs: {
description: {
@@ -103,8 +108,8 @@ export const Failed: Story = {
};
export const Empty: Story = {
name: "Нет ближайших событий",
args: { events: { state: "empty", to: eventsPath } },
name: "Нет ближайших событий",
parameters: {
docs: {
description: {
@@ -115,40 +120,44 @@ export const Empty: Story = {
},
};
export const MissingAmount: Story = {
name: "Событие без ожидаемой суммы",
args: {
events: {
state: "loaded",
to: eventsPath,
items: [{ ...syntheticEvent, projectedAmount: null }],
},
},
parameters: {
docs: {
description: {
story:
"Событие остаётся видимым при неизвестной ожидаемой сумме. Отсутствие оценки не подменяется нулевой выплатой.",
export const MissingAmount: Story = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
args: {
events: {
items: [{ ...syntheticEvent, projectedAmount: null }],
state: "loaded",
to: eventsPath,
},
},
},
};
export const LongEvent: Story = {
name: "Длинное название на узком экране",
args: {
events: {
state: "loaded",
to: eventsPath,
items: [
{
...syntheticEvent,
type: "offer",
displayName:
"Учебные облигации компании с очень длинным названием инструмента",
projectedAmount: null,
name: "Событие без ожидаемой суммы",
parameters: {
docs: {
description: {
story:
"Событие остаётся видимым при неизвестной ожидаемой сумме. Отсутствие оценки не подменяется нулевой выплатой.",
},
],
},
},
},
};
}
/* eslint-enable unicorn/no-null */);
export const LongEvent: Story = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
args: {
events: {
items: [
{
...syntheticEvent,
displayName:
"Учебные облигации компании с очень длинным названием инструмента",
projectedAmount: null,
type: "offer",
},
],
state: "loaded",
to: eventsPath,
},
},
name: "Длинное название на узком экране",
}
/* eslint-enable unicorn/no-null */);
@@ -1,26 +1,30 @@
import type { FC } from "react";
import { Alert, Button, Skeleton, Stack, Text } from "@mantine/core";
import { LoadingSkeleton } from "@wealthledger/ui";
import type { FC } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { formatSnapshotTime } from "@/shared/lib";
import type { BrokerageEvent } from "../../api/useBrokerageEvents";
import { BrokerageEventCard } from "../BrokerageEventCard";
type BrokerageEventsPreviewProps = {
events: BrokerageEventsPreviewState;
};
type BrokerageEventsPreviewState =
| { state: "loading" | "error" | "empty"; to: string }
| {
state: "loaded" | "partial";
to: string;
lastSuccessfulAt?: string | null;
stale?: boolean;
refreshError?: boolean;
items: BrokerageEvent[];
};
type BrokerageEventsPreviewState
= | {
items: BrokerageEvent[];
lastSuccessfulAt?: null | string;
refreshError?: boolean;
stale?: boolean;
state: "loaded" | "partial";
to: string;
}
| { state: "empty" | "error" | "loading"; to: string };
const BrokerageEventsPreview: FC<BrokerageEventsPreviewProps> = (props) => {
const { events } = props;
@@ -28,53 +32,51 @@ const BrokerageEventsPreview: FC<BrokerageEventsPreviewProps> = (props) => {
return (
<Stack gap="sm">
{events.state === "loaded" ? (
{(events.state === "loaded") && ((
<>
{events.lastSuccessfulAt ? (
<Text size="xs" c="dimmed">
{!!(events.lastSuccessfulAt) && ((
<Text c="dimmed" size="xs">
{t("investment.sourceTime", {
date: formatSnapshotTime(events.lastSuccessfulAt),
})}
</Text>
) : null}
{events.stale ? <Text size="xs">{t("investment.stale")}</Text> : null}
{events.refreshError ? (
))}
{!!(events.stale) && (<Text size="xs">{t("investment.stale")}</Text>)}
{!!(events.refreshError) && ((
<Text role="status">{t("accounts.refreshError")}</Text>
) : null}
))}
</>
) : null}
{events.state === "loading" ? (
))}
{(events.state === "loading") && ((
<LoadingSkeleton label={t("events.recentLoading")}>
{[0, 1, 2].map((index) => (
<Skeleton key={index} height={48} radius="sm" />
{["first", "second", "third"].map(placeholder => (
<Skeleton height={48} key={placeholder} radius="sm" />
))}
</LoadingSkeleton>
) : null}
{events.state === "error" ? (
))}
{(events.state === "error") && ((
<Alert color="red">{t("events.recentError")}</Alert>
) : null}
{events.state === "empty" ? (
))}
{(events.state === "empty") && ((
<Text c="dimmed">{t("events.recentEmpty")}</Text>
) : null}
{events.state === "partial" ? (
))}
{(events.state === "partial") && ((
<Text role="status">{t("investment.partial")}</Text>
) : null}
{events.state === "loaded" || events.state === "partial"
? events.items.map((event) => (
<BrokerageEventCard
key={JSON.stringify([
event.account?.id,
event.type,
event.date,
event.instrumentUid,
event.figi,
event.ticker,
event.logoName,
])}
event={event}
/>
))
: null}
))}
{(events.state === "loaded" || events.state === "partial") && (events.items.map(event => (
<BrokerageEventCard
event={event}
key={JSON.stringify([
event.account?.id,
event.type,
event.date,
event.instrumentUid,
event.figi,
event.ticker,
event.logoName,
])}
/>
)))}
<Button component={Link} to={events.to} variant="subtle">
{t("events.open")}
</Button>