chore: finish frontend ESLint migration #18
Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 37m50s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Failing after 42m10s
Conventional commits / commits (pull_request) Successful in 29s

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 07:31:28 +03:00
parent 851457e03c
commit 3eafad2657
253 changed files with 10059 additions and 8864 deletions
@@ -3,11 +3,14 @@ import { fireEvent, render, screen } from "@testing-library/react";
import { type FC, lazy, Suspense } from "react";
import { MemoryRouter, useLocation, useNavigate } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { RouteErrorBoundary } from "./RouteErrorBoundary";
let authenticated = false;
const session = { isAuthenticated: false };
vi.mock("@/features/auth", () => ({
useAuth: () => ({ user: authenticated ? {} : null }),
useAuth: () => ((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
{ user: session.isAuthenticated ? {} : null }
/* eslint-enable unicorn/no-null */)),
}));
const ThrowingRoute: FC = () => {
@@ -17,11 +20,13 @@ const ThrowingRoute: FC = () => {
const HealthyRoute: FC = () => {
return (
<div>
{useLocation().pathname === "/healthy" ? (
"healthy route"
) : (
<ThrowingRoute />
)}
{useLocation().pathname === "/healthy"
? (
"healthy route"
)
: (
<ThrowingRoute />
)}
</div>
);
};
@@ -31,7 +36,7 @@ const RouteHarness: FC = () => {
return (
<>
<button type="button" onClick={() => navigate("/healthy")}>
<button onClick={() => navigate("/healthy")} type="button">
go healthy
</button>
<RouteErrorBoundary>
@@ -55,10 +60,10 @@ describe("RouteErrorBoundary", () => {
it.each(["/accounts", "/login"])(
"recovers a transient failure through the fallback on %s itself",
async (path) => {
authenticated = path === "/accounts";
let failing = true;
session.isAuthenticated = path === "/accounts";
let isFailing = true;
const RecoverableRoute: FC = () => {
if (failing) throw new Error("temporary failure");
if (isFailing) throw new Error("temporary failure");
return <div>recovered route</div>;
};
render(
@@ -71,14 +76,14 @@ describe("RouteErrorBoundary", () => {
</MantineProvider>,
);
const action = screen.getByRole("link", { name: "Продолжить" });
failing = false;
isFailing = false;
fireEvent.click(action);
expect(await screen.findByText("recovered route")).toBeInTheDocument();
},
);
it("keeps a persistent failure recoverable without an automatic reset loop", () => {
authenticated = true;
session.isAuthenticated = true;
renderBoundary("/accounts");
fireEvent.click(screen.getByRole("link", { name: "Продолжить" }));
expect(
@@ -91,7 +96,7 @@ describe("RouteErrorBoundary", () => {
});
it("offers document navigation when React.lazy caches a rejected chunk", async () => {
authenticated = false;
session.isAuthenticated = false;
const load = vi.fn(() => Promise.reject(new Error("chunk failed")));
const Chunk = lazy(load);
render(
@@ -110,18 +115,18 @@ describe("RouteErrorBoundary", () => {
const reload = screen.getByRole("link", { name: "Перезагрузить страницу" });
expect(reload).toHaveAttribute("href", "/login");
// Cancel browser navigation in JSDOM only after proving React Router did not intercept it.
let intercepted = true;
let isIntercepted = true;
const preventNavigation = (event: MouseEvent) => {
intercepted = event.defaultPrevented;
isIntercepted = event.defaultPrevented;
event.preventDefault();
};
document.addEventListener("click", preventNavigation, { once: true });
fireEvent.click(reload);
expect(intercepted).toBe(false);
expect(isIntercepted).toBe(false);
});
it("offers login after a public route error without error details", () => {
authenticated = false;
session.isAuthenticated = false;
renderBoundary("/login");
expect(document.title).toBe("Не удалось открыть страницу — WealthLedger");
expect(screen.getByRole("link", { name: "Продолжить" })).toHaveAttribute(
@@ -132,9 +137,9 @@ describe("RouteErrorBoundary", () => {
});
it("offers accounts after a protected route error and resets on navigation", async () => {
authenticated = true;
session.isAuthenticated = true;
renderBoundary("/accounts");
screen.getByRole("button", { name: "go healthy" }).click();
fireEvent.click(screen.getByRole("button", { name: "go healthy" }));
expect(await screen.findByText("healthy route")).toBeInTheDocument();
});
});