diff --git a/eslint.config.mjs b/eslint.config.mjs index 69f8e7b..a9fb714 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -3,21 +3,23 @@ import globals from 'globals'; import tseslint from 'typescript-eslint'; import importPlugin from 'eslint-plugin-import'; +import reactHooksPlugin from 'eslint-plugin-react-hooks'; export default tseslint.config( { - ignores: ['dist'], + ignores: ['**/node_modules/**', '**/build/**', '**/dist/**'], }, { name: 'default', extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['packages/**/src/**/*.ts'], + files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'], languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, plugins: { import: importPlugin, + 'react-hooks': reactHooksPlugin, }, settings: { react: { @@ -93,6 +95,8 @@ export default tseslint.config( '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-empty-generator-function': 'off', '@typescript-eslint/no-explicit-any': 'off', + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'error', }, }, ); diff --git a/examples/nextjs-ai-chatbot/app/api/chats/[id]/route.ts b/examples/nextjs-ai-chatbot/app/api/chats/[id]/route.ts index 3c13120..d673159 100644 --- a/examples/nextjs-ai-chatbot/app/api/chats/[id]/route.ts +++ b/examples/nextjs-ai-chatbot/app/api/chats/[id]/route.ts @@ -4,12 +4,14 @@ import { createConfigFromEnv } from '@stream-io/ai-sdk-storage/dist/utils'; const storage = createStreamStorageClient(createConfigFromEnv()); -export async function GET(req: Request, { params }: any) { + +export async function GET(_req: Request, { params }: any) { const { id } = await params; try { return NextResponse.json( await storage.streamStorage.getChannelMessages(id), ); + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (error) { return NextResponse.json([], { status: 404 }); } diff --git a/examples/nextjs-ai-chatbot/app/api/transcribe/route.ts b/examples/nextjs-ai-chatbot/app/api/transcribe/route.ts index 57dd879..0a39db6 100644 --- a/examples/nextjs-ai-chatbot/app/api/transcribe/route.ts +++ b/examples/nextjs-ai-chatbot/app/api/transcribe/route.ts @@ -1,4 +1,4 @@ -import { NextRequest } from 'next/server'; +import type { NextRequest } from 'next/server'; import { experimental_transcribe as transcribe } from 'ai'; import { openai } from '@ai-sdk/openai'; diff --git a/examples/nextjs-ai-chatbot/app/layout.tsx b/examples/nextjs-ai-chatbot/app/layout.tsx index 3e24259..dee279b 100644 --- a/examples/nextjs-ai-chatbot/app/layout.tsx +++ b/examples/nextjs-ai-chatbot/app/layout.tsx @@ -4,7 +4,7 @@ import 'animate.css'; import './globals.css'; import Sidebar from '@/components/sidebar'; import Composer from '@/components/composer'; -import { LayoutProps } from '@/types'; +import type { LayoutProps } from '@/types'; import { AppProvider } from '@/contexts/app'; const geistSans = Geist({ @@ -24,20 +24,20 @@ export const metadata: Metadata = { export default function RootLayout({ children }: LayoutProps) { return ( - + -
-
+
+
-
-
-
{children}
-
-
+
+
+
{children}
+
+
diff --git a/examples/nextjs-ai-chatbot/components/composer.tsx b/examples/nextjs-ai-chatbot/components/composer.tsx index 35b7b82..bca39bc 100644 --- a/examples/nextjs-ai-chatbot/components/composer.tsx +++ b/examples/nextjs-ai-chatbot/components/composer.tsx @@ -4,11 +4,9 @@ import { MODELS } from '@/utils/models'; import { ArrowUpIcon, ImageIcon, - Mic, MicIcon, MicOffIcon, Paperclip, - SpeakerIcon, XIcon, } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; @@ -19,7 +17,7 @@ import { useTranscriber } from '@/hooks/usetranscribe'; export default function Composer() { const [isActive, setIsActive] = useState(false); const [input, setInput] = useState(''); - const [files, setFiles] = useState(undefined); + const [files, setFiles] = useState(undefined); const fileInputRef = useRef(null); const { isListening, transcript, start, stop } = useTranscriber(); @@ -53,6 +51,7 @@ export default function Composer() { useEffect(() => { if (transcript) { + // eslint-disable-next-line handleSubmit({ preventDefault: () => {}, target: { value: transcript }, @@ -75,6 +74,7 @@ export default function Composer() { : 'outline-transparent' }`} > + {} {[...(files || [])]?.map((file: any, index) => (
@@ -109,8 +109,7 @@ export default function Composer() { ref={fileInputRef} onChange={(e) => { if (e.target.files) { - //@ts-ignore - setFiles(e.target.files); + setFiles([...e.target.files]); } }} /> diff --git a/examples/nextjs-ai-chatbot/components/markdown.tsx b/examples/nextjs-ai-chatbot/components/markdown.tsx index c7486db..9cf949c 100644 --- a/examples/nextjs-ai-chatbot/components/markdown.tsx +++ b/examples/nextjs-ai-chatbot/components/markdown.tsx @@ -10,7 +10,7 @@ import Weather from './tools/weather'; export const NonMemoizedMarkdown = ({ children }: { children: string }) => { const components = { p: ({ children }: { children: string }) => { - return
{children}
; + return
{children}
; }, pre: ({ children, ...props }: any) => { const codeElement = React.Children.only(children); @@ -33,21 +33,21 @@ export const NonMemoizedMarkdown = ({ children }: { children: string }) => { }, ol: ({ node, children, ...props }: any) => { return ( -
    +
      {children}
    ); }, li: ({ node, children, ...props }: any) => { return ( -
  1. +
  2. {children}
  3. ); }, ul: ({ node, children, ...props }: any) => { return ( -