Skip to content

Commit ed7b175

Browse files
authored
Setup lint rules and resolve all lint issues. (#49)
1 parent 23f2dc8 commit ed7b175

19 files changed

+577
-435
lines changed

.eslintrc.json

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
22
"$schema": "https://json.schemastore.org/eslintrc",
33
"root": true,
4-
"extends": [
5-
"next/core-web-vitals",
6-
"prettier"
7-
],
8-
"plugins": ["import"],
4+
"extends": ["next/core-web-vitals", "prettier", "plugin:tailwindcss/recommended"],
5+
"plugins": ["import", "@typescript-eslint"],
96
"rules": {
107
"import/order": [
118
"error",
@@ -26,10 +23,20 @@
2623
}
2724
}
2825
],
29-
"no-unused-vars": "warn"
30-
},
31-
"settings": {
26+
"@typescript-eslint/no-unused-vars": [
27+
"warn",
28+
{
29+
"vars": "all",
30+
"varsIgnorePattern": "^_",
31+
"args": "after-used",
32+
"argsIgnorePattern": "^_"
33+
}
34+
],
35+
"react-hooks/exhaustive-deps": "off",
36+
"tailwindcss/no-custom-classname": "off",
37+
"tailwindcss/classnames-order": "off"
3238
},
39+
"settings": {},
3340
"overrides": [
3441
{
3542
"files": ["*.ts", "*.tsx"],

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"skipFiles": ["<node_internals>/**"]
1414
}
1515
]
16-
}
16+
}

app/not-found.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Flex, Heading, Separator } from '@radix-ui/themes'
2+
3+
const NotFound = () => {
4+
return (
5+
<Flex justify="center" align="center" className="flex flex-1">
6+
<Flex gap="3" align="center">
7+
<Heading as="h2" size="6" weight="medium">
8+
404
9+
</Heading>
10+
<Separator orientation="vertical" style={{ height: 'var(--space-6)' }} />
11+
This page could not be found.
12+
</Flex>
13+
</Flex>
14+
)
15+
}
16+
17+
export default NotFound

components/Chat/Chat.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ const Chat = (props: ChatProps, ref: any) => {
264264
justify="center"
265265
style={{ color: 'var(--accent-11)' }}
266266
>
267-
<AiOutlineLoading3Quarters className="animate-spin h-4 w-4" />
267+
<AiOutlineLoading3Quarters className="animate-spin size-4" />
268268
</Flex>
269269
)}
270270
<Tooltip content={'Send Message'}>
@@ -276,7 +276,7 @@ const Chat = (props: ChatProps, ref: any) => {
276276
className="rounded-xl cursor-pointer"
277277
onClick={sendMessage}
278278
>
279-
<FiSend className="h-4 w-4" />
279+
<FiSend className="size-4" />
280280
</IconButton>
281281
</Tooltip>
282282
<Tooltip content={'Clear Message'}>
@@ -288,7 +288,7 @@ const Chat = (props: ChatProps, ref: any) => {
288288
disabled={isLoading}
289289
onClick={clearMessages}
290290
>
291-
<AiOutlineClear className="h-4 w-4" />
291+
<AiOutlineClear className="size-4" />
292292
</IconButton>
293293
</Tooltip>
294294
<Tooltip content={'Toggle Sidebar'}>
@@ -300,7 +300,7 @@ const Chat = (props: ChatProps, ref: any) => {
300300
disabled={isLoading}
301301
onClick={onToggleSidebar}
302302
>
303-
<AiOutlineUnorderedList className="h-4 w-4" />
303+
<AiOutlineUnorderedList className="size-4" />
304304
</IconButton>
305305
</Tooltip>
306306
</Flex>

components/Chat/ChatSideBar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const ChatSideBar = () => {
3131
onClick={() => onCreateChat?.(DefaultPersonas[0])}
3232
className="bg-token-surface-primary active:scale-95 cursor-pointer"
3333
>
34-
<FiPlus className="h-4 w-4" />
34+
<FiPlus className="size-4" />
3535
<Text>New Chat</Text>
3636
</Box>
3737
<ScrollArea className="flex-1" type="auto" scrollbars="vertical">
@@ -46,7 +46,7 @@ export const ChatSideBar = () => {
4646
onClick={() => onChangeChat?.(chat)}
4747
>
4848
<Flex gap="2" align="center">
49-
<BiMessageDetail className="h-4 w-4" />
49+
<BiMessageDetail className="size-4" />
5050
<Text as="p" className="truncate">
5151
{chat.persona?.name}
5252
</Text>
@@ -62,7 +62,7 @@ export const ChatSideBar = () => {
6262
onDeleteChat?.(chat)
6363
}}
6464
>
65-
<AiOutlineCloseCircle className="h-4 w-4" />
65+
<AiOutlineCloseCircle className="size-4" />
6666
</IconButton>
6767
</Box>
6868
))}
@@ -73,7 +73,7 @@ export const ChatSideBar = () => {
7373
onClick={() => onOpenPersonaPanel?.('chat')}
7474
className="bg-token-surface-primary active:scale-95 cursor-pointer"
7575
>
76-
<RiRobot2Line className="h-4 w-4" />
76+
<RiRobot2Line className="size-4" />
7777
<Text>Persona Store</Text>
7878
</Box>
7979
</Flex>

components/Chat/Message.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Message = (props: MessageProps) => {
1717
return (
1818
<Flex gap="4" className="mb-5">
1919
<Avatar
20-
fallback={isUser ? <HiUser className="h-4 w-4" /> : <SiOpenai className="h-4 w-4" />}
20+
fallback={isUser ? <HiUser className="size-4" /> : <SiOpenai className="size-4" />}
2121
color={isUser ? undefined : 'green'}
2222
size="2"
2323
radius="full"

components/Chat/PersonaPanel.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Persona } from './interface'
2121

2222
export interface PersonaPanelProps {}
2323

24-
const PersonaPanel = (props: PersonaPanelProps) => {
24+
const PersonaPanel = (_props: PersonaPanelProps) => {
2525
const {
2626
personaPanelType,
2727
DefaultPersonas,
@@ -83,10 +83,10 @@ const PersonaPanel = (props: PersonaPanelProps) => {
8383
radius="full"
8484
onClick={onClosePersonaPanel}
8585
>
86-
<AiOutlineClose className="w-4 h-4" />
86+
<AiOutlineClose className="size-4" />
8787
</IconButton>
8888
</Flex>
89-
<Container size="3" className="flex-grow-0 px-4">
89+
<Container size="3" className="grow-0 px-4">
9090
<Flex gap="4" py="5">
9191
<TextField.Root size="3" className="flex-1" radius="large">
9292
<TextField.Slot>
@@ -134,7 +134,7 @@ const PersonaPanel = (props: PersonaPanelProps) => {
134134
onCreateChat?.(prompt)
135135
}}
136136
>
137-
<LuMessageSquarePlus className="h-4 w-4" />
137+
<LuMessageSquarePlus className="size-4" />
138138
</IconButton>
139139
<IconButton
140140
size="2"
@@ -145,7 +145,7 @@ const PersonaPanel = (props: PersonaPanelProps) => {
145145
onEditPersona?.(prompt)
146146
}}
147147
>
148-
<AiOutlineEdit className="h-4 w-4" />
148+
<AiOutlineEdit className="size-4" />
149149
</IconButton>
150150
<IconButton
151151
size="2"
@@ -156,7 +156,7 @@ const PersonaPanel = (props: PersonaPanelProps) => {
156156
onDeletePersona?.(prompt)
157157
}}
158158
>
159-
<AiOutlineDelete className="h-4 w-4" />
159+
<AiOutlineDelete className="size-4" />
160160
</IconButton>
161161
</Flex>
162162
</Flex>

components/Chat/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client'
2+
13
export * from './interface'
24
export { default as Chat } from './Chat'
35
export { default as ChatSideBar } from './ChatSideBar'

components/Header.tsx

+3-11
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,13 @@ import { HamburgerMenuIcon } from '@radix-ui/react-icons'
55
import { Avatar, Flex, Heading, IconButton, Select, Tooltip } from '@radix-ui/themes'
66
import cs from 'classnames'
77
import NextLink from 'next/link'
8-
import { usePathname } from 'next/navigation'
98
import { FaAdjust, FaGithub, FaMoon, FaRegSun } from 'react-icons/fa'
109
import { Link } from './Link'
1110
import { useTheme } from './Themes'
1211

13-
export interface HeaderProps {
14-
children?: React.ReactNode
15-
gitHubLink?: string
16-
ghost?: boolean
17-
}
18-
19-
export const Header = ({ children, gitHubLink, ghost }: HeaderProps) => {
20-
const pathname = usePathname()
12+
export const Header = () => {
2113
const { theme, setTheme } = useTheme()
22-
const [show, setShow] = useState(false)
14+
const [, setShow] = useState(false)
2315

2416
const toggleNavBar = useCallback(() => {
2517
setShow((state) => !state)
@@ -32,7 +24,7 @@ export const Header = ({ children, gitHubLink, ghost }: HeaderProps) => {
3224
>
3325
<Flex align="center" gap="3">
3426
<NextLink href="/">
35-
<Heading as="h2" size="3" style={{ maxWidth: 200 }}>
27+
<Heading as="h2" size="4" style={{ maxWidth: 200 }}>
3628
ChatGPT Lite
3729
</Heading>
3830
</NextLink>

components/Markdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const Markdown = ({ className, children }: MarkdownProps) => {
2525
rehypePlugins={[rehypeRaw, rehypeKatex, rehypeStringify]}
2626
components={{
2727
code(props) {
28-
const { children, className, node, ref, ...rest } = props
28+
const { children, className, ref, ...rest } = props
2929
const match = /language-(\w+)/.exec(className || '')
3030
return match ? (
3131
<>

components/Spin/DotLoading.tsx

-29
This file was deleted.

components/Spin/Spin.tsx

-118
This file was deleted.

0 commit comments

Comments
 (0)