move to biome (#297)

* switch to biome

* writer format

* migrate format

* packages format

* hudozka format

* writer fix

* biome config updated

* migrate fix

* packages fix

* hudozka fix

* claude updated
This commit is contained in:
tmshv authored and GitHub committed 2026-04-25 03:25:15 +03:00
1 parent 98dcaaa237
commit 467a218d00
112 files changed
+1472 -5914

No files matched your search

+9 -5
View File
@@ -1,5 +1,5 @@
import { render, screen } from "@testing-library/react"
import { describe, it, expect } from "vitest"
import { describe, expect, it } from "vitest"
import { Box } from "."
describe("Box", () => {
@@ -20,25 +20,29 @@ describe("Box", () => {
it("applies vertical class", () => {
const { container } = render(<Box vertical>v</Box>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/vertical/)
})
it("applies center class", () => {
const { container } = render(<Box center>c</Box>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/center/)
})
it("applies wrap class", () => {
const { container } = render(<Box wrap>w</Box>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/wrap/)
})
it("passes gap to inline style", () => {
const { container } = render(<Box gap={8}>g</Box>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el).toHaveStyle({ gap: "8px" })
})
})
+1 -2
View File
@@ -1,7 +1,6 @@
import s from "./box.module.css"
import classnames from "classnames/bind"
import { createElement } from "react"
import s from "./box.module.css"
const cx = classnames.bind(s)
@@ -1,5 +1,5 @@
import { render, within } from "@testing-library/react"
import { describe, it, expect } from "vitest"
import { describe, expect, it } from "vitest"
import { Breadcrumbs } from "."
describe("Breadcrumbs", () => {
@@ -9,9 +9,21 @@ describe("Breadcrumbs", () => {
{ name: "Team", href: "/about/team" },
]
function getNav(container: HTMLElement) {
const navEl = container.querySelector("nav")
if (!navEl) throw new Error("expected <nav> element to be rendered")
return within(navEl)
}
function getClosestLink(el: HTMLElement) {
const link = el.closest("a")
if (!link) throw new Error("expected ancestor <a> element")
return link
}
it("renders breadcrumb items with separators", () => {
const { container } = render(<Breadcrumbs items={items} path="/about/team" />)
const nav = within(container.querySelector("nav")!)
const nav = getNav(container)
expect(nav.getByText("Home")).toBeInTheDocument()
expect(nav.getByText("About")).toBeInTheDocument()
@@ -23,12 +35,12 @@ describe("Breadcrumbs", () => {
it("disables the button matching the current path", () => {
const { container } = render(<Breadcrumbs items={items} path="/about" />)
const nav = within(container.querySelector("nav")!)
const nav = getNav(container)
const aboutLink = nav.getByText("About").closest("a")!
const aboutLink = getClosestLink(nav.getByText("About"))
expect(aboutLink.className).toMatch(/disabled/)
const homeLink = nav.getByText("Home").closest("a")!
const homeLink = getClosestLink(nav.getByText("Home"))
expect(homeLink.className).not.toMatch(/disabled/)
})
})
+13 -24
View File
@@ -1,7 +1,6 @@
import s from "./styles.module.css"
import { Fragment } from "react"
import { Button } from "../Button"
import { insertBetween } from "@hudozka/utils"
import s from "./styles.module.css"
export type Crumb = {
name: string
@@ -14,33 +13,23 @@ export type BreadcrumbsProps = {
path: string
}
export const Breadcrumbs: React.FC<BreadcrumbsProps> = props => {
const items = insertBetween(props.items, () => "/")
export function Breadcrumbs(props: BreadcrumbsProps) {
return (
<nav className={s.breadcrumbs} style={props.style}>
{items.map((x, i) => {
if (typeof x === "string") {
return (
<li key={i}>
<span style={{ margin: "0 var(--size-xs)" }}>{x}</span>
{props.items.map((x, i) => (
<Fragment key={x.href}>
{i > 0 && (
<li>
<span style={{ margin: "0 var(--size-xs)" }}>/</span>
</li>
)
}
return (
<li key={x.href}>
<Button
href={x.href}
theme={"ghost"}
size={"small"}
disabled={x.href === props.path}
>
)}
<li>
<Button href={x.href} theme={"ghost"} size={"small"} disabled={x.href === props.path}>
{x.name}
</Button>
</li>
)
})}
</Fragment>
))}
</nav>
)
}
+10 -4
View File
@@ -1,5 +1,5 @@
import { render, screen, fireEvent } from "@testing-library/react"
import { describe, it, expect, vi } from "vitest"
import { fireEvent, render, screen } from "@testing-library/react"
import { describe, expect, it, vi } from "vitest"
import { Button } from "."
describe("Button", () => {
@@ -19,7 +19,11 @@ describe("Button", () => {
it("calls onClick with value when clicked", () => {
const onClick = vi.fn()
render(<Button value="test-value" onClick={onClick}>Click</Button>)
render(
<Button value="test-value" onClick={onClick}>
Click
</Button>,
)
fireEvent.click(screen.getByRole("button", { name: "Click" }))
expect(onClick).toHaveBeenCalledOnce()
expect(onClick).toHaveBeenCalledWith("test-value", expect.anything())
@@ -35,6 +39,8 @@ describe("Button", () => {
it("applies disabled class when disabled is true", () => {
const { container } = render(<Button disabled>Disabled</Button>)
expect(container.firstElementChild!.className).toMatch(/disabled/)
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/disabled/)
})
})
+13 -13
View File
@@ -1,9 +1,9 @@
import s from "./button.module.css"
import cx from "classnames"
import Link from "next/link"
import cx from "classnames"
import { useCallback } from "react"
import type { MouseEvent, MouseEventHandler } from "react"
import { useCallback } from "react"
import s from "./button.module.css"
const sizeClass = {
default: s.sizeDefault,
@@ -31,11 +31,15 @@ export const Button: React.FC<ButtonProps> = ({ size = "default", theme = "defau
const className = cx(s.button, sizeClass[size], themeClass[theme], {
[s.disabled]: disabled,
})
const onClick = useCallback<MouseEventHandler<HTMLButtonElement>>(event => {
if (typeof props.onClick === "function") {
props.onClick(props.value, event)
}
}, [props])
const { onClick: onClickProp, value } = props
const onClick = useCallback<MouseEventHandler<HTMLButtonElement>>(
event => {
if (typeof onClickProp === "function") {
onClickProp(value, event)
}
},
[onClickProp, value],
)
if (props.href) {
return (
@@ -46,11 +50,7 @@ export const Button: React.FC<ButtonProps> = ({ size = "default", theme = "defau
}
return (
<button
className={className}
style={props.style}
onClick={onClick}
>
<button type="button" className={className} style={props.style} onClick={onClick}>
{props.children}
</button>
)
+1 -4
View File
@@ -17,10 +17,7 @@ export function Transition(props: TransitionProps) {
setMounted(false)
}
}, [opacity])
const transition = useMemo(
() => `all ${props.duration}ms`,
[props.duration],
)
const transition = useMemo(() => `all ${props.duration}ms`, [props.duration])
if (props.show && !mounted) {
setMounted(true)
+9 -8
View File
@@ -1,7 +1,6 @@
import s from "./styles.module.css"
import { Transition } from "./Transition"
import { useLockBodyScroll, useReducedMotion } from "@hudozka/hooks"
import s from "./styles.module.css"
import { Transition } from "./Transition"
export type OverlayProps = {
children?: React.ReactNode
@@ -18,16 +17,18 @@ export const Overlay: React.FC<OverlayProps> = props => {
useLockBodyScroll(props.show)
return (
<Transition
duration={duration}
show={props.show}
>
<Transition duration={duration} show={props.show}>
<div
onClick={(event) => {
onClick={event => {
if (event.target === event.currentTarget) {
props.onClickOverlay()
}
}}
onKeyDown={event => {
if (event.key === "Escape") {
props.onClickOverlay()
}
}}
className={s.overlay}
style={props.style}
>
+7 -4
View File
@@ -1,5 +1,5 @@
import { render } from "@testing-library/react"
import { describe, it, expect } from "vitest"
import { describe, expect, it } from "vitest"
import { Panel } from "."
describe("Panel", () => {
@@ -10,20 +10,23 @@ describe("Panel", () => {
it("applies the default variant class", () => {
const { container } = render(<Panel>content</Panel>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/default/)
})
it("applies the ghost variant class when ghost is true", () => {
const { container } = render(<Panel ghost>content</Panel>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toMatch(/ghost/)
expect(el.className).not.toMatch(/default/)
})
it("forwards a custom className", () => {
const { container } = render(<Panel className="custom">content</Panel>)
const el = container.firstElementChild!
const el = container.firstElementChild
if (!el) throw new Error("expected rendered element")
expect(el.className).toContain("custom")
})
})
+8 -9
View File
@@ -1,6 +1,5 @@
import s from "./panel.module.css"
import { Box } from "../Box"
import s from "./panel.module.css"
export type PanelProps = {
children?: React.ReactNode
@@ -9,16 +8,16 @@ export type PanelProps = {
ghost?: boolean
}
export function Panel({
style,
className,
children,
ghost = false,
}: PanelProps) {
export function Panel({ style, className, children, ghost = false }: PanelProps) {
const variant = ghost ? s.ghost : s.default
return (
<Box vertical align={false} className={`${s.panel} ${variant}${className ? ` ${className}` : ""}`} style={style}>
<Box
vertical
align={false}
className={`${s.panel} ${variant}${className ? ` ${className}` : ""}`}
style={style}
>
{children}
</Box>
)
+1 -1
View File
@@ -1,6 +1,6 @@
export * from "./Box"
export * from "./Breadcrumbs"
export * from "./Button"
export * from "./Overlay"
export * from "./Panel"
export * from "./Title"
export * from "./Overlay"