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,8 +1,9 @@
import type { FC } from "react";
import { MantineProvider } from "@mantine/core";
import { QueryClientProvider } from "@tanstack/react-query";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { HttpResponse, http } from "msw";
import type { FC } from "react";
import { http, HttpResponse } from "msw";
import {
MemoryRouter,
Route,
@@ -11,6 +12,7 @@ import {
useNavigate,
} from "react-router";
import { describe, expect, it, vi } from "vitest";
import {
type BrokerageOperation,
LedgerEntryRow,
@@ -19,25 +21,28 @@ import { configureAuthClient } from "@/shared/api";
import { createTestQueryClient } from "@/test/query";
import { resource } from "@/test/resource";
import { server } from "@/test/server";
import { AccountOperationsPage } from "./AccountOperationsPage";
const operation: BrokerageOperation = {
id: "operation-1",
occurredAt: "2026-08-14T10:00:00Z",
type: "OPERATION_TYPE_BUY",
category: "trade",
description: "Покупка акций",
figi: null,
instrumentUid: null,
ticker: "SBER",
instrumentType: "share",
logoName: null,
payment: null,
quantity: "2",
price: { currency: "RUB", value: "100" },
accruedInterest: null,
commission: { currency: "RUB", value: "1" },
};
const operation: BrokerageOperation = (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
accruedInterest: null,
category: "trade",
commission: { currency: "RUB", value: "1" },
description: "Покупка акций",
figi: null,
id: "operation-1",
instrumentType: "share",
instrumentUid: null,
logoName: null,
occurredAt: "2026-08-14T10:00:00Z",
payment: null,
price: { currency: "RUB", value: "100" },
quantity: "2",
ticker: "SBER",
type: "OPERATION_TYPE_BUY",
}
/* eslint-enable unicorn/no-null */);
const Navigation: FC = () => {
const location = useLocation();
@@ -45,10 +50,10 @@ const Navigation: FC = () => {
return (
<>
<output aria-label="URL">{location.search}</output>
<button type="button" onClick={() => navigate(-1)}>
<button onClick={() => navigate(-1)} type="button">
History back
</button>
<button type="button" onClick={() => navigate(1)}>
<button onClick={() => navigate(1)} type="button">
History forward
</button>
</>
@@ -58,8 +63,8 @@ const Navigation: FC = () => {
function configureTestAuth() {
configureAuthClient({
accessToken: () => "token",
refresh: async () => true,
clear: vi.fn(),
refresh: () => Promise.resolve(true),
});
}
@@ -72,8 +77,8 @@ function renderPage(search = "") {
>
<Routes>
<Route
path="/accounts/:accountId/operations"
element={<AccountOperationsPage />}
path="/accounts/:accountId/operations"
/>
</Routes>
</MemoryRouter>
@@ -95,9 +100,9 @@ describe("LedgerEntryRow", () => {
expect(screen.getByText("Без движения денег")).toBeInTheDocument();
expect(
screen.queryByRole("button", { name: "Показать детали" }),
).toBeNull();
expect(screen.queryByText("Цена: 100 ₽")).toBeNull();
expect(screen.queryByText("Количество: 2")).toBeNull();
).not.toBeInTheDocument();
expect(screen.queryByText("Цена: 100 ₽")).not.toBeInTheDocument();
expect(screen.queryByText("Количество: 2")).not.toBeInTheDocument();
});
it("labels a positive payment with its category type", () => {
@@ -125,9 +130,9 @@ describe("LedgerEntryRow", () => {
<LedgerEntryRow
operation={{
...operation,
type: "OPERATION_TYPE_COUPON",
category: "income",
payment: { currency: "RUB", value: "8" },
type: "OPERATION_TYPE_COUPON",
}}
/>
</MemoryRouter>
@@ -145,9 +150,9 @@ describe("LedgerEntryRow", () => {
<LedgerEntryRow
operation={{
...operation,
type: "OPERATION_TYPE_DIVIDEND",
category: "income",
payment: { currency: "RUB", value: "20" },
type: "OPERATION_TYPE_DIVIDEND",
}}
/>
</MemoryRouter>
@@ -165,9 +170,9 @@ describe("LedgerEntryRow", () => {
<LedgerEntryRow
operation={{
...operation,
type: "OPERATION_TYPE_SERVICE_FEE",
category: "fee",
payment: { currency: "RUB", value: "-3" },
type: "OPERATION_TYPE_SERVICE_FEE",
}}
/>
</MemoryRouter>
@@ -193,7 +198,7 @@ describe("LedgerEntryRow", () => {
);
expect(screen.getByText("Без движения денег")).toBeInTheDocument();
expect(screen.queryByText("Сделка")).toBeNull();
expect(screen.queryByText("Сделка")).not.toBeInTheDocument();
});
it("uses an instrument initial when the ledger entry has no logo", () => {
@@ -222,9 +227,9 @@ describe("AccountOperationsPage", () => {
searches.push(new URL(request.url).searchParams);
return HttpResponse.json(
resource({
hasNext: true,
items: [operation],
nextCursor: "next",
hasNext: true,
}),
);
},
@@ -234,20 +239,20 @@ describe("AccountOperationsPage", () => {
<QueryClientProvider client={createTestQueryClient()}>
<MantineProvider env="test">
<MemoryRouter
initialIndex={0}
initialEntries={[
"?from=bad&to=2026-02-28&categories=trade",
"?from=2026-02-30&categories=trade",
"?from=2026-03-01&to=2026-02-28&categories=trade",
"?from=2026-02-01&categories=trade",
"?to=2026-02-28&categories=trade",
].map((search) => `/accounts/${accountId}/operations${search}`)}
].map(search => `/accounts/${accountId}/operations${search}`)}
initialIndex={0}
>
<Navigation />
<Routes>
<Route
path="/accounts/:accountId/operations"
element={<AccountOperationsPage />}
path="/accounts/:accountId/operations"
/>
</Routes>
</MemoryRouter>
@@ -266,6 +271,7 @@ describe("AccountOperationsPage", () => {
screen.getByRole("button", { name: "History forward" }),
);
await waitFor(() =>
// eslint-disable-next-line jest-dom/prefer-to-have-text-content -- URL history requires exact equality, including empty search.
expect(screen.getByLabelText("URL").textContent).toBe(expected),
);
await screen.findByLabelText("Период");
@@ -287,11 +293,11 @@ describe("AccountOperationsPage", () => {
expect(screen.getByLabelText("Период")).toHaveTextContent("01.02.2026"),
);
expect(screen.getByRole("button", { name: "Назад" })).toBeDisabled();
expect(searches.map((query) => query.get("from"))).not.toContain(
expect(searches.map(query => query.get("from"))).not.toContain(
"badT00:00:00.000Z",
);
expect(
searches.every((query) => query.get("categories") === "trade"),
searches.every(query => query.get("categories") === "trade"),
).toBe(true);
},
);
@@ -307,7 +313,9 @@ describe("AccountOperationsPage", () => {
new URL(request.url).searchParams.has("from")
? HttpResponse.json({ code: "VALIDATION_ERROR" }, { status: 400 })
: HttpResponse.json(
resource({ items: [], hasNext: false, nextCursor: null }),
resource((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{ hasNext: false, items: [], nextCursor: null }
/* eslint-enable unicorn/no-null */)),
),
),
);
@@ -322,8 +330,8 @@ describe("AccountOperationsPage", () => {
<Navigation />
<Routes>
<Route
path="/accounts/:accountId/operations"
element={<AccountOperationsPage />}
path="/accounts/:accountId/operations"
/>
</Routes>
</MemoryRouter>
@@ -333,7 +341,7 @@ describe("AccountOperationsPage", () => {
await screen.findByRole("button", { name: "Повторить" });
fireEvent.click(screen.getByRole("button", { name: "Сбросить" }));
await screen.findByLabelText("Период");
expect(screen.getByLabelText("URL").textContent).toBe("");
expect(screen.getByLabelText("URL")).toBeEmptyDOMElement();
},
);
@@ -347,13 +355,15 @@ describe("AccountOperationsPage", () => {
const url = new URL(request.url);
searches.push(url.search);
return HttpResponse.json(
resource({
accountId: "account-1",
items: [operation],
nextCursor: url.searchParams.get("cursor") ? null : "next-1",
hasNext: !url.searchParams.get("cursor"),
observedAt: "2026-08-14T00:00:00Z",
}),
resource((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
accountId: "account-1",
hasNext: !url.searchParams.get("cursor"),
items: [operation],
nextCursor: url.searchParams.get("cursor") ? null : "next-1",
observedAt: "2026-08-14T00:00:00Z",
}
/* eslint-enable unicorn/no-null */)),
);
},
),
@@ -385,13 +395,15 @@ describe("AccountOperationsPage", () => {
const url = new URL(request.url);
searches.push(url.search);
return HttpResponse.json(
resource({
accountId: "account-1",
items: [operation],
nextCursor: null,
hasNext: false,
observedAt: "2026-08-14T00:00:00Z",
}),
resource((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
accountId: "account-1",
hasNext: false,
items: [operation],
nextCursor: null,
observedAt: "2026-08-14T00:00:00Z",
}
/* eslint-enable unicorn/no-null */)),
);
},
),
@@ -405,9 +417,9 @@ describe("AccountOperationsPage", () => {
const countBefore = searches.length;
fireEvent.click(screen.getByRole("combobox", { name: "Категории" }));
fireEvent.click(await screen.findByText("Налог"));
await new Promise((resolve) => setTimeout(resolve, 100));
expect(searches.length).toBe(countBefore);
expect(searches.some((s) => s.includes("categories=tax"))).toBe(false);
await new Promise(resolve => setTimeout(resolve, 100));
expect(searches).toHaveLength(countBefore);
expect(searches.some(s => s.includes("categories=tax"))).toBe(false);
});
it("reset clears filters and refetches unfiltered", async () => {
@@ -420,13 +432,15 @@ describe("AccountOperationsPage", () => {
const url = new URL(request.url);
searches.push(url.search);
return HttpResponse.json(
resource({
accountId: "account-1",
items: [operation],
nextCursor: null,
hasNext: false,
observedAt: "2026-08-14T00:00:00Z",
}),
resource((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
accountId: "account-1",
hasNext: false,
items: [operation],
nextCursor: null,
observedAt: "2026-08-14T00:00:00Z",
}
/* eslint-enable unicorn/no-null */)),
);
},
),
@@ -440,7 +454,7 @@ describe("AccountOperationsPage", () => {
fireEvent.click(await screen.findByText("Налог"));
fireEvent.click(screen.getByRole("button", { name: "Применить" }));
await waitFor(() =>
expect(searches.some((s) => s.includes("categories=tax"))).toBe(true),
expect(searches.some(s => s.includes("categories=tax"))).toBe(true),
);
fireEvent.click(screen.getByRole("button", { name: "Сбросить" }));
await waitFor(() => expect(searches.at(-1)).not.toContain("categories="));
@@ -471,9 +485,11 @@ it("keeps UTC operation boundaries in GET and source sync requests", async () =>
({ request }) => {
requested.push(Object.fromEntries(new URL(request.url).searchParams));
return HttpResponse.json(
resource(null, {
sync: { id: null, state: "failed", errorCode: "TBANK_UNAVAILABLE" },
}),
resource(null, (/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
sync: { errorCode: "TBANK_UNAVAILABLE", id: null, state: "failed" },
}
/* eslint-enable unicorn/no-null */)),
);
},
),
@@ -486,10 +502,10 @@ it("keeps UTC operation boundaries in GET and source sync requests", async () =>
const retry = await screen.findByRole("button", { name: "Повторить" });
expect(requested).toEqual([
{
from: "2024-02-29T00:00:00.000Z",
to: "2024-03-01T23:59:59.999Z",
categories: "trade",
from: "2024-02-29T00:00:00.000Z",
limit: "100",
to: "2024-03-01T23:59:59.999Z",
},
]);
expect(syncRequests).toEqual([]);
@@ -497,12 +513,12 @@ it("keeps UTC operation boundaries in GET and source sync requests", async () =>
await waitFor(() =>
expect(syncRequests).toEqual([
{
screen: "operations",
accountId: "account-1",
from: "2024-02-29T00:00:00.000Z",
to: "2024-03-01T23:59:59.999Z",
categories: ["trade"],
from: "2024-02-29T00:00:00.000Z",
limit: 100,
screen: "operations",
to: "2024-03-01T23:59:59.999Z",
},
]),
);
@@ -514,12 +530,14 @@ it("does not label incomplete empty operations as a confirmed empty period", asy
http.get("*/api/v1/brokerage-accounts/:accountId/operations", () =>
HttpResponse.json(
resource(
{
accountId: "account-1",
items: [],
hasNext: false,
nextCursor: null,
},
(/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{
accountId: "account-1",
hasNext: false,
items: [],
nextCursor: null,
}
/* eslint-enable unicorn/no-null */),
{ availability: "partial" },
),
),
@@ -537,17 +555,17 @@ it("recovers an invalid cursor at the first page without clearing applied filter
http.get(
"*/api/v1/brokerage-accounts/:accountId/operations",
({ request }) => {
const params = new URL(request.url).searchParams;
searches.push(params);
if (params.has("cursor"))
const parameters = new URL(request.url).searchParams;
searches.push(parameters);
if (parameters.has("cursor"))
return HttpResponse.json(
{ code: "INVALID_OPERATIONS_CURSOR" },
{ status: 400 },
);
return HttpResponse.json(
resource({
items: [operation],
hasNext: true,
items: [operation],
nextCursor: "old-cursor",
}),
);
@@ -557,7 +575,7 @@ it("recovers an invalid cursor at the first page without clearing applied filter
renderPage("?from=2026-08-01&to=2026-08-14&categories=trade");
fireEvent.click(await screen.findByRole("button", { name: "Далее" }));
fireEvent.click(await screen.findByRole("button", { name: "Повторить" }));
await waitFor(() => expect(searches.length).toBe(3));
await waitFor(() => expect(searches).toHaveLength(3));
expect(searches[2].get("cursor")).toBeNull();
for (const key of ["from", "to", "categories"])
expect(searches[2].get(key)).toBe(searches[0].get(key));