diff --git a/.eslintrc b/.eslintrc index b4388b83..6cbaf5ca 100644 --- a/.eslintrc +++ b/.eslintrc @@ -49,7 +49,7 @@ "@typescript-eslint/naming-convention": [ "error", { - "selector": "typeParameter", + "selector": "typeParameter", "format": ["PascalCase"], "leadingUnderscore": "forbid", "trailingUnderscore": "forbid", @@ -59,6 +59,7 @@ }, }, ], + "@typescript-eslint/no-deprecated": "error", "@typescript-eslint/no-empty-function": "error", "@typescript-eslint/no-empty-interface": "error", "@typescript-eslint/no-explicit-any": "off", diff --git a/apps/documentation/.eslintrc b/apps/documentation/.eslintrc index b4388b83..6cbaf5ca 100644 --- a/apps/documentation/.eslintrc +++ b/apps/documentation/.eslintrc @@ -49,7 +49,7 @@ "@typescript-eslint/naming-convention": [ "error", { - "selector": "typeParameter", + "selector": "typeParameter", "format": ["PascalCase"], "leadingUnderscore": "forbid", "trailingUnderscore": "forbid", @@ -59,6 +59,7 @@ }, }, ], + "@typescript-eslint/no-deprecated": "error", "@typescript-eslint/no-empty-function": "error", "@typescript-eslint/no-empty-interface": "error", "@typescript-eslint/no-explicit-any": "off", diff --git a/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx b/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx index 0b4bae4c..6d5db605 100644 --- a/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx +++ b/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Breadcrumbs, Button } from '@mantine/core' import { Link, Head } from 'tuono' diff --git a/apps/documentation/src/components/edit-page/edit-page.tsx b/apps/documentation/src/components/edit-page/edit-page.tsx index dfb511ef..80b6959a 100644 --- a/apps/documentation/src/components/edit-page/edit-page.tsx +++ b/apps/documentation/src/components/edit-page/edit-page.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Button } from '@mantine/core' import { IconEdit } from '@tabler/icons-react' import { useRouter } from 'tuono' diff --git a/apps/documentation/src/components/hero/hero.tsx b/apps/documentation/src/components/hero/hero.tsx index 5c9c1842..906b1d2e 100644 --- a/apps/documentation/src/components/hero/hero.tsx +++ b/apps/documentation/src/components/hero/hero.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Button, Center, diff --git a/apps/documentation/src/components/mdx-provider/mdx-bold/mdx-bold.tsx b/apps/documentation/src/components/mdx-provider/mdx-bold/mdx-bold.tsx index 20d37034..bd14c596 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-bold/mdx-bold.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-bold/mdx-bold.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Text, type TextProps } from '@mantine/core' export default function MdxBold(props: TextProps): JSX.Element { diff --git a/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx b/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx index c89986e1..3b0af777 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Code } from '@mantine/core' import type { HTMLAttributes } from 'react' diff --git a/apps/documentation/src/components/mdx-provider/mdx-link/mdx-link.tsx b/apps/documentation/src/components/mdx-provider/mdx-link/mdx-link.tsx index 5ad4678d..a60ed9ba 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-link/mdx-link.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-link/mdx-link.tsx @@ -1,4 +1,4 @@ -import type { AnchorHTMLAttributes } from 'react' +import type { JSX, AnchorHTMLAttributes } from 'react' import { Button } from '@mantine/core' import { Link } from 'tuono' import { IconExternalLink } from '@tabler/icons-react' diff --git a/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx b/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx index 7a91e396..6047ea35 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { CodeHighlight } from '@mantine/code-highlight' import styles from './mdx-pre.module.css' diff --git a/apps/documentation/src/components/mdx-provider/mdx-provider.tsx b/apps/documentation/src/components/mdx-provider/mdx-provider.tsx index 3e5be0eb..7e56dac1 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-provider.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-provider.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { MDXProvider } from '@mdx-js/react' import MdxLink from './mdx-link' diff --git a/apps/documentation/src/components/mdx-provider/mdx-quote/mdx-quote.tsx b/apps/documentation/src/components/mdx-provider/mdx-quote/mdx-quote.tsx index c0ca4171..9384dca7 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-quote/mdx-quote.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-quote/mdx-quote.tsx @@ -1,5 +1,5 @@ +import type { JSX, HTMLAttributes } from 'react' import { Blockquote, Space } from '@mantine/core' -import type { HTMLAttributes } from 'react' export default function MdxQuote( props: HTMLAttributes, diff --git a/apps/documentation/src/components/mdx-provider/mdx-title/mdx-title.tsx b/apps/documentation/src/components/mdx-provider/mdx-title/mdx-title.tsx index c445250d..0383c33a 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-title/mdx-title.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-title/mdx-title.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Title, type TitleProps } from '@mantine/core' export default function MdxTitle(props: TitleProps): JSX.Element { diff --git a/apps/documentation/src/components/navbar/actions.tsx b/apps/documentation/src/components/navbar/actions.tsx index 4e76bc20..64cf27dc 100644 --- a/apps/documentation/src/components/navbar/actions.tsx +++ b/apps/documentation/src/components/navbar/actions.tsx @@ -1,8 +1,10 @@ +import type { JSX } from 'react' import { Flex, Button, ActionIcon, Group } from '@mantine/core' import { IconBrandGithub, IconBook, IconBrandX } from '@tabler/icons-react' -import ThemeBtn from '../theme-btn' import { Link } from 'tuono' +import ThemeBtn from '../theme-btn' + export default function Actions(): JSX.Element { return ( diff --git a/apps/documentation/src/components/navbar/navbar.tsx b/apps/documentation/src/components/navbar/navbar.tsx index 21b44e75..4340cab9 100644 --- a/apps/documentation/src/components/navbar/navbar.tsx +++ b/apps/documentation/src/components/navbar/navbar.tsx @@ -1,5 +1,7 @@ +import type { JSX } from 'react' import { AppShell, Burger, Button, Flex } from '@mantine/core' import { Link, useRouter } from 'tuono' + import Actions from './actions' interface NavbarProps { diff --git a/apps/documentation/src/components/navigation-buttons/navigation-buttons.tsx b/apps/documentation/src/components/navigation-buttons/navigation-buttons.tsx index a7c2375c..10e032a1 100644 --- a/apps/documentation/src/components/navigation-buttons/navigation-buttons.tsx +++ b/apps/documentation/src/components/navigation-buttons/navigation-buttons.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { Box, Button, Text, Title, Flex } from '@mantine/core' import { Link } from 'tuono' import { IconArrowRight, IconArrowLeft } from '@tabler/icons-react' diff --git a/apps/documentation/src/components/sidebar/sidebar-link.tsx b/apps/documentation/src/components/sidebar/sidebar-link.tsx index a1a662a5..15323c34 100644 --- a/apps/documentation/src/components/sidebar/sidebar-link.tsx +++ b/apps/documentation/src/components/sidebar/sidebar-link.tsx @@ -1,5 +1,6 @@ +import type { JSX, ReactNode } from 'react' +import { useState } from 'react' import { NavLink, type NavLinkProps } from '@mantine/core' -import { useState, type ReactNode } from 'react' import { Link, useRouter } from 'tuono' import { IconChevronRight } from '@tabler/icons-react' diff --git a/apps/documentation/src/components/sidebar/sidebar.tsx b/apps/documentation/src/components/sidebar/sidebar.tsx index 2ced85de..6a61b6ff 100644 --- a/apps/documentation/src/components/sidebar/sidebar.tsx +++ b/apps/documentation/src/components/sidebar/sidebar.tsx @@ -1,4 +1,6 @@ +import type { JSX } from 'react' import { AppShell } from '@mantine/core' + import SidebarLink from './sidebar-link' export default function Sidebar({ close }: { close: () => void }): JSX.Element { diff --git a/apps/documentation/src/components/table-of-content/table-of-content.tsx b/apps/documentation/src/components/table-of-content/table-of-content.tsx index 12826f3b..865a4aea 100644 --- a/apps/documentation/src/components/table-of-content/table-of-content.tsx +++ b/apps/documentation/src/components/table-of-content/table-of-content.tsx @@ -1,6 +1,7 @@ /* * Component inspired by: https://github.com/mantinedev/mantine/tree/master/apps/mantine.dev/src/components/TableOfContents */ +import type { JSX } from 'react' import { useEffect, useRef, useState } from 'react' import { useRouter, Link } from 'tuono' import { IconList } from '@tabler/icons-react' diff --git a/apps/documentation/src/components/theme-btn/theme-btn.tsx b/apps/documentation/src/components/theme-btn/theme-btn.tsx index 638e6413..a6217c74 100644 --- a/apps/documentation/src/components/theme-btn/theme-btn.tsx +++ b/apps/documentation/src/components/theme-btn/theme-btn.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import { ActionIcon, useMantineColorScheme, diff --git a/apps/documentation/src/routes/__root.tsx b/apps/documentation/src/routes/__root.tsx index d5a3fa73..f59a8088 100644 --- a/apps/documentation/src/routes/__root.tsx +++ b/apps/documentation/src/routes/__root.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react' +import type { ReactNode, JSX } from 'react' import { ColorSchemeScript, createTheme, diff --git a/apps/documentation/src/routes/documentation/__root.tsx b/apps/documentation/src/routes/documentation/__root.tsx index b27e26c9..80a3ca08 100644 --- a/apps/documentation/src/routes/documentation/__root.tsx +++ b/apps/documentation/src/routes/documentation/__root.tsx @@ -1,5 +1,6 @@ -import type { ReactNode } from 'react' +import type { ReactNode, JSX } from 'react' import { AppShell, Container } from '@mantine/core' + import MdxProvider from '../../components/mdx-provider' import EditPage from '../../components/edit-page' diff --git a/apps/documentation/src/routes/documentation/tutorial/api-fetching.mdx b/apps/documentation/src/routes/documentation/tutorial/api-fetching.mdx index 4c4669a2..82779c49 100644 --- a/apps/documentation/src/routes/documentation/tutorial/api-fetching.mdx +++ b/apps/documentation/src/routes/documentation/tutorial/api-fetching.mdx @@ -64,6 +64,7 @@ Now the Pokémon are correctly fetched and hydrated on the client side, so we ca ```tsx // src/routes/index.tsx +import type { JSX } from 'react' import type { TuonoProps } from 'tuono' interface Pokemon { @@ -76,9 +77,9 @@ interface IndexProps { export default function IndexPage({ data, -}: TuonoProps): JSX.Element { +}: TuonoProps): JSX.Element | null { if (!data?.results) { - return <> + return null } return ( diff --git a/apps/documentation/src/routes/documentation/tutorial/components.mdx b/apps/documentation/src/routes/documentation/tutorial/components.mdx index 2207986e..5da76bce 100644 --- a/apps/documentation/src/routes/documentation/tutorial/components.mdx +++ b/apps/documentation/src/routes/documentation/tutorial/components.mdx @@ -25,6 +25,7 @@ Create the following file `src/components/PokemonLink.tsx` and fill the content ```tsx // src/components/PokemonLink.tsx +import type { JSX } from 'react' import { Link } from 'tuono' interface Pokemon { @@ -109,8 +110,9 @@ Then import the styles into the `PokemonLink` component as following: ```diff // src/components/PokemonLink.tsx -import { Link } from "tuono"; -import type { Pokemon } from "./../types/pokemon"; +import type { JSX } from 'react' +import { Link } from "tuono" +import type { Pokemon } from "./../types/pokemon" ++ import styles from './PokemonLink.module.css' export default function PokemonLink({ diff --git a/apps/documentation/src/routes/documentation/tutorial/dynamic-routes.mdx b/apps/documentation/src/routes/documentation/tutorial/dynamic-routes.mdx index 2a0cb13e..54161201 100644 --- a/apps/documentation/src/routes/documentation/tutorial/dynamic-routes.mdx +++ b/apps/documentation/src/routes/documentation/tutorial/dynamic-routes.mdx @@ -63,6 +63,7 @@ async fn get_pokemon(req: Request, fetch: Client) -> Response { Then let’s work on the frontend. Paste into the `[pokemon].tsx` file the following code: ```tsx +import type { JSX } from 'react' import { TuonoProps } from 'tuono' import PokemonView from '../../components/PokemonView' diff --git a/apps/documentation/src/routes/documentation/tutorial/seo.mdx b/apps/documentation/src/routes/documentation/tutorial/seo.mdx index 479edc1e..f5f0dec2 100644 --- a/apps/documentation/src/routes/documentation/tutorial/seo.mdx +++ b/apps/documentation/src/routes/documentation/tutorial/seo.mdx @@ -26,6 +26,7 @@ To do so `tuono` also exposes the `` component useful exactly for handli ```diff // src/routes/index.tsx +import type { JSX } from 'react' import type { TuonoProps } from "tuono"; ++ import { Head } from "tuono" @@ -80,6 +81,7 @@ export default function IndexPage({ ```diff // src/routes/pokemons/[pokemon].tsx +import type { JSX } from 'react' -- import { TuonoProps } from "tuono"; ++ import { TuonoProps, Head } from "tuono"; import PokemonView from "../../components/PokemonView"; diff --git a/apps/documentation/src/routes/index.tsx b/apps/documentation/src/routes/index.tsx index ef91ef72..1bdfdb6a 100644 --- a/apps/documentation/src/routes/index.tsx +++ b/apps/documentation/src/routes/index.tsx @@ -1,3 +1,5 @@ +import type { JSX } from 'react' + import Hero from '../components/hero' import MetaTags from '../components/meta-tags' diff --git a/examples/mdx/src/routes/__root.tsx b/examples/mdx/src/routes/__root.tsx index b4a0ad50..f85690e2 100644 --- a/examples/mdx/src/routes/__root.tsx +++ b/examples/mdx/src/routes/__root.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react' +import type { ReactNode, JSX } from 'react' import { MDXProvider } from '@mdx-js/react' interface RootRouteProps { diff --git a/examples/tuono/src/routes/__root.tsx b/examples/tuono/src/routes/__root.tsx index 1a39e91f..2a9d1425 100644 --- a/examples/tuono/src/routes/__root.tsx +++ b/examples/tuono/src/routes/__root.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react' +import type { ReactNode, JSX } from 'react' interface RootRouteProps { children: ReactNode diff --git a/examples/tuono/src/routes/index.tsx b/examples/tuono/src/routes/index.tsx index 2c1ce2f0..faa78cf7 100644 --- a/examples/tuono/src/routes/index.tsx +++ b/examples/tuono/src/routes/index.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'react' import type { TuonoProps } from 'tuono' interface IndexProps { diff --git a/examples/tutorial/src/components/PokemonLink.tsx b/examples/tutorial/src/components/PokemonLink.tsx index 1266e8df..700b6004 100644 --- a/examples/tutorial/src/components/PokemonLink.tsx +++ b/examples/tutorial/src/components/PokemonLink.tsx @@ -1,4 +1,6 @@ +import type { JSX } from 'react' import { Link } from 'tuono' + import styles from './PokemonLink.module.css' interface Pokemon { diff --git a/examples/tutorial/src/routes/__root.tsx b/examples/tutorial/src/routes/__root.tsx index 1a39e91f..2a9d1425 100644 --- a/examples/tutorial/src/routes/__root.tsx +++ b/examples/tutorial/src/routes/__root.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react' +import type { ReactNode, JSX } from 'react' interface RootRouteProps { children: ReactNode diff --git a/examples/tutorial/src/routes/index.tsx b/examples/tutorial/src/routes/index.tsx index 3fc04a11..5700f0ee 100644 --- a/examples/tutorial/src/routes/index.tsx +++ b/examples/tutorial/src/routes/index.tsx @@ -1,5 +1,7 @@ // src/routes/index.tsx +import type { JSX } from 'react' import { Head, type TuonoProps } from 'tuono' + import PokemonLink from '../components/PokemonLink' interface Pokemon { @@ -12,9 +14,9 @@ interface IndexProps { export default function IndexPage({ data, -}: TuonoProps): JSX.Element { +}: TuonoProps): JSX.Element | null { if (!data?.results) { - return <> + return null } return ( diff --git a/examples/tutorial/src/routes/pokemons/[pokemon].tsx b/examples/tutorial/src/routes/pokemons/[pokemon].tsx index 5de353e1..251f1efe 100644 --- a/examples/tutorial/src/routes/pokemons/[pokemon].tsx +++ b/examples/tutorial/src/routes/pokemons/[pokemon].tsx @@ -1,22 +1,24 @@ +import type { JSX } from 'react' import { Head, type TuonoProps } from 'tuono' + import PokemonView from '../../components/PokemonView' interface Pokemon { - name: string - id: string - weight: number - height: number + name: string + id: string + weight: number + height: number } export default function PokemonPage({ - data, + data, }: TuonoProps): JSX.Element { - return ( - <> - - {`Pokemon: ${data?.name}`} - - - - ) + return ( + <> + + {`Pokemon: ${data?.name}`} + + + + ) } diff --git a/packages/router/src/components/Link.tsx b/packages/router/src/components/Link.tsx index 235b6144..d6570c84 100644 --- a/packages/router/src/components/Link.tsx +++ b/packages/router/src/components/Link.tsx @@ -17,7 +17,7 @@ interface TuonoLinkProps { export default function Link( componentProps: AnchorHTMLAttributes & TuonoLinkProps, -): JSX.Element { +): React.JSX.Element { const { preload = true, scroll = true, ...props } = componentProps const router = useRouter() const route = useRoute(props.href) diff --git a/packages/router/src/components/Matches.tsx b/packages/router/src/components/Matches.tsx index 5b0f43a9..3710ea42 100644 --- a/packages/router/src/components/Matches.tsx +++ b/packages/router/src/components/Matches.tsx @@ -9,7 +9,7 @@ interface MatchesProps { serverSideProps: any } -export function Matches({ serverSideProps }: MatchesProps): JSX.Element { +export function Matches({ serverSideProps }: MatchesProps): React.JSX.Element { const location = useRouterStore((st) => st.location) const route = useRoute(location.pathname) diff --git a/packages/router/src/components/NotFound.tsx b/packages/router/src/components/NotFound.tsx index 48533668..1513fd92 100644 --- a/packages/router/src/components/NotFound.tsx +++ b/packages/router/src/components/NotFound.tsx @@ -3,7 +3,7 @@ import { RouteMatch } from './RouteMatch' import Link from './Link' import { useInternalRouter } from '../hooks/useInternalRouter' -export default function NotFound(): JSX.Element { +export default function NotFound(): React.JSX.Element { const router = useInternalRouter() const custom404Route = router.routesById['/404'] diff --git a/packages/router/src/components/RouteMatch.tsx b/packages/router/src/components/RouteMatch.tsx index 77f6590c..6534f659 100644 --- a/packages/router/src/components/RouteMatch.tsx +++ b/packages/router/src/components/RouteMatch.tsx @@ -16,7 +16,7 @@ interface MatchProps { export const RouteMatch = ({ route, serverSideProps, -}: MatchProps): JSX.Element => { +}: MatchProps): React.JSX.Element => { const { data, isLoading } = useServerSideProps(route, serverSideProps) const routes = React.useMemo(() => loadParentComponents(route), [route.id]) @@ -55,13 +55,13 @@ const TraverseRootComponents = React.memo( isLoading, index = 0, children, - }: TraverseRootComponentsProps): JSX.Element => { + }: TraverseRootComponentsProps): React.JSX.Element => { if (routes.length > index) { const Parent = React.useMemo( () => routes[index]?.component as unknown as ( props: ParentProps, - ) => JSX.Element, + ) => React.JSX.Element, [], ) diff --git a/packages/router/src/components/RouterProvider.tsx b/packages/router/src/components/RouterProvider.tsx index a12213da..1a2e947e 100644 --- a/packages/router/src/components/RouterProvider.tsx +++ b/packages/router/src/components/RouterProvider.tsx @@ -1,9 +1,10 @@ -import { getRouterContext } from './RouterContext' -import { Matches } from './Matches' +import React from 'react' +import type { ReactNode, JSX } from 'react' import { useListenBrowserUrlUpdates } from '../hooks/useListenBrowserUrlUpdates' -import React, { type ReactNode } from 'react' import { initRouterStore } from '../hooks/useRouterStore' import type { ServerProps } from '../types' +import { getRouterContext } from './RouterContext' +import { Matches } from './Matches' type Router = any diff --git a/packages/router/src/dynamic.tsx b/packages/router/src/dynamic.tsx index 7ac598f6..bb1c5388 100644 --- a/packages/router/src/dynamic.tsx +++ b/packages/router/src/dynamic.tsx @@ -13,7 +13,7 @@ type ImportFn = () => Promise<{ default: React.ComponentType }> * It can be wrapped within a React.Suspense component in order to handle its loading state. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -export const dynamic = (importFn: ImportFn): JSX.Element => { +export const dynamic = (importFn: ImportFn): React.JSX.Element => { /** * * This function is just a placeholder. The real work is done by the bundler. diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 2a618122..da2239a0 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -1,3 +1,5 @@ +import type { JSX } from 'react' + import { trimPath, trimPathRight } from './utils' import type { Route } from './route'