Upgrade linter and formatter to Ultracite (#1224)

This commit is contained in:
Hayden Bleasel 2025-09-20 12:47:10 -07:00 committed by GitHub
parent b1d254283b
commit 0e320b391d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 6951 additions and 8342 deletions

View file

@ -1,5 +1,5 @@
import useSWR from 'swr';
import { useRef, useEffect, useCallback, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from "react";
import useSWR from "swr";
type ScrollFlag = ScrollBehavior | false;
@ -9,21 +9,25 @@ export function useScrollToBottom() {
const [isAtBottom, setIsAtBottom] = useState(true);
const { data: scrollBehavior = false, mutate: setScrollBehavior } =
useSWR<ScrollFlag>('messages:should-scroll', null, { fallbackData: false });
useSWR<ScrollFlag>("messages:should-scroll", null, { fallbackData: false });
const handleScroll = useCallback(() => {
if (!containerRef.current) return;
if (!containerRef.current) {
return;
}
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
// Check if we are within 100px of the bottom (like v0 does)
setIsAtBottom(scrollTop + clientHeight >= scrollHeight - 100);
}, []);
}, []);
useEffect(() => {
if (!containerRef.current) return;
if (!containerRef.current) {
return;
}
const container = containerRef.current;
const resizeObserver = new ResizeObserver(() => {
requestAnimationFrame(() => {
handleScroll();
@ -43,7 +47,7 @@ export function useScrollToBottom() {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['style', 'class', 'data-state']
attributeFilter: ["style", "class", "data-state"],
});
handleScroll();
@ -56,13 +60,15 @@ export function useScrollToBottom() {
useEffect(() => {
const container = containerRef.current;
if (!container) return;
if (!container) {
return;
}
container.addEventListener('scroll', handleScroll);
container.addEventListener("scroll", handleScroll);
handleScroll(); // Check initial state
return () => {
container.removeEventListener('scroll', handleScroll);
container.removeEventListener("scroll", handleScroll);
};
}, [handleScroll]);
@ -79,10 +85,10 @@ export function useScrollToBottom() {
}, [scrollBehavior, setScrollBehavior]);
const scrollToBottom = useCallback(
(scrollBehavior: ScrollBehavior = 'smooth') => {
setScrollBehavior(scrollBehavior);
(currentScrollBehavior: ScrollBehavior = "smooth") => {
setScrollBehavior(currentScrollBehavior);
},
[setScrollBehavior],
[setScrollBehavior]
);
function onViewportEnter() {