diff --git a/apps/app/tsconfig.json b/apps/app/tsconfig.json index 216c382bc..6aa9201ce 100644 --- a/apps/app/tsconfig.json +++ b/apps/app/tsconfig.json @@ -24,14 +24,8 @@ // } { "extends": "tsconfig/nextjs.json", - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"], "compilerOptions": { "baseUrl": ".", "jsx": "preserve" diff --git a/apps/docs/.eslintrc.js b/apps/docs/.eslintrc.js new file mode 100644 index 000000000..132c8c4e5 --- /dev/null +++ b/apps/docs/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('config/.eslintrc') diff --git a/apps/docs/src/components/Button.jsx b/apps/docs/src/components/Button.jsx index 46f14f34c..c311f91e8 100644 --- a/apps/docs/src/components/Button.jsx +++ b/apps/docs/src/components/Button.jsx @@ -33,7 +33,7 @@ export function Button({ arrow, ...props }) { - let Component = props.href ? Link : 'button' + const Component = props.href ? Link : 'button' className = clsx( 'inline-flex gap-0.5 justify-center overflow-hidden text-sm font-medium transition', @@ -41,7 +41,7 @@ export function Button({ className ) - let arrowIcon = ( + const arrowIcon = ( 0 + const [copyCount, setCopyCount] = useState(0) + const copied = copyCount > 0 useEffect(() => { if (copyCount > 0) { - let timeout = setTimeout(() => setCopyCount(0), 1000) + const timeout = setTimeout(() => setCopyCount(0), 1000) return () => { clearTimeout(timeout) } @@ -117,7 +117,7 @@ function CodePanelHeader({ tag, label }) { } function CodePanel({ tag, label, code, children }) { - let child = Children.only(children) + const child = Children.only(children) return (
@@ -134,7 +134,7 @@ function CodePanel({ tag, label, code, children }) { } function CodeGroupHeader({ title, children, selectedIndex }) { - let hasTabs = Children.count(children) > 1 + const hasTabs = Children.count(children) > 1 if (!title && !hasTabs) { return null @@ -168,7 +168,7 @@ function CodeGroupHeader({ title, children, selectedIndex }) { } function CodeGroupPanels({ children, ...props }) { - let hasTabs = Children.count(children) > 1 + const hasTabs = Children.count(children) > 1 if (hasTabs) { return ( @@ -186,24 +186,25 @@ function CodeGroupPanels({ children, ...props }) { } function usePreventLayoutShift() { - let positionRef = useRef() - let rafRef = useRef() + const positionRef = useRef() + const rafRef = useRef() - useEffect(() => { - return () => { + useEffect( + () => () => { window.cancelAnimationFrame(rafRef.current) - } - }, []) + }, + [] + ) return { positionRef, preventLayoutShift(callback) { - let initialTop = positionRef.current.getBoundingClientRect().top + const initialTop = positionRef.current.getBoundingClientRect().top callback() rafRef.current = window.requestAnimationFrame(() => { - let newTop = positionRef.current.getBoundingClientRect().top + const newTop = positionRef.current.getBoundingClientRect().top window.scrollBy(0, newTop - initialTop) }) }, @@ -224,18 +225,19 @@ const usePreferredLanguageStore = create((set) => ({ })) function useTabGroupProps(availableLanguages) { - let { preferredLanguages, addPreferredLanguage } = usePreferredLanguageStore() - let [selectedIndex, setSelectedIndex] = useState(0) - let activeLanguage = [...availableLanguages].sort( + const { preferredLanguages, addPreferredLanguage } = + usePreferredLanguageStore() + const [selectedIndex, setSelectedIndex] = useState(0) + const activeLanguage = [...availableLanguages].sort( (a, z) => preferredLanguages.indexOf(z) - preferredLanguages.indexOf(a) )[0] - let languageIndex = availableLanguages.indexOf(activeLanguage) - let newSelectedIndex = languageIndex === -1 ? selectedIndex : languageIndex + const languageIndex = availableLanguages.indexOf(activeLanguage) + const newSelectedIndex = languageIndex === -1 ? selectedIndex : languageIndex if (newSelectedIndex !== selectedIndex) { setSelectedIndex(newSelectedIndex) } - let { positionRef, preventLayoutShift } = usePreventLayoutShift() + const { positionRef, preventLayoutShift } = usePreventLayoutShift() return { as: 'div', @@ -252,12 +254,14 @@ function useTabGroupProps(availableLanguages) { const CodeGroupContext = createContext(false) export function CodeGroup({ children, title, ...props }) { - let languages = Children.map(children, (child) => getPanelTitle(child.props)) - let tabGroupProps = useTabGroupProps(languages) - let hasTabs = Children.count(children) > 1 - let Container = hasTabs ? Tab.Group : 'div' - let containerProps = hasTabs ? tabGroupProps : {} - let headerProps = hasTabs + const languages = Children.map(children, (child) => + getPanelTitle(child.props) + ) + const tabGroupProps = useTabGroupProps(languages) + const hasTabs = Children.count(children) > 1 + const Container = hasTabs ? Tab.Group : 'div' + const containerProps = hasTabs ? tabGroupProps : {} + const headerProps = hasTabs ? { selectedIndex: tabGroupProps.selectedIndex } : {} @@ -277,7 +281,7 @@ export function CodeGroup({ children, title, ...props }) { } export function Code({ children, ...props }) { - let isGrouped = useContext(CodeGroupContext) + const isGrouped = useContext(CodeGroupContext) if (isGrouped) { return @@ -287,7 +291,7 @@ export function Code({ children, ...props }) { } export function Pre({ children, ...props }) { - let isGrouped = useContext(CodeGroupContext) + const isGrouped = useContext(CodeGroupContext) if (isGrouped) { return children diff --git a/apps/docs/src/components/Footer.jsx b/apps/docs/src/components/Footer.jsx index b1486ef32..339150cf5 100644 --- a/apps/docs/src/components/Footer.jsx +++ b/apps/docs/src/components/Footer.jsx @@ -65,7 +65,7 @@ const FeedbackThanks = forwardRef(function FeedbackThanks(_props, ref) { }) function Feedback() { - let [submitted, setSubmitted] = useState(false) + const [submitted, setSubmitted] = useState(false) function onSubmit(event) { event.preventDefault() @@ -124,9 +124,9 @@ function PageLink({ label, page, previous = false }) { } function PageNavigation() { - let router = useRouter() - let allPages = navigation.flatMap((group) => group.links) - let currentPageIndex = allPages.findIndex( + const router = useRouter() + const allPages = navigation.flatMap((group) => group.links) + const currentPageIndex = allPages.findIndex( (page) => page.href === router.pathname ) @@ -134,8 +134,8 @@ function PageNavigation() { return null } - let previousPage = allPages[currentPageIndex - 1] - let nextPage = allPages[currentPageIndex + 1] + const previousPage = allPages[currentPageIndex - 1] + const nextPage = allPages[currentPageIndex + 1] if (!previousPage && !nextPage) { return null @@ -207,7 +207,10 @@ function SmallPrint() { Follow us on GitHub - + Join our Discord server
@@ -216,7 +219,7 @@ function SmallPrint() { } export function Footer() { - let router = useRouter() + const router = useRouter() return (