Skip to content

Commit

Permalink
merge(#14): lint
Browse files Browse the repository at this point in the history
style: lint
  • Loading branch information
bietiaop authored Dec 19, 2024
2 parents 5c42bee + 0036ea2 commit 201ab36
Show file tree
Hide file tree
Showing 89 changed files with 454 additions and 315 deletions.
16 changes: 15 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,19 @@
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"bracketSpacing": true
"bracketSpacing": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"^@/const/(.*)$",
"^@/store/(.*)$",
"^@/components/(.*)$",
"^@/contexts/(.*)$",
"^@/hooks/(.*)$",
"^@/utils/(.*)$",
"^@/(.*)$",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
9 changes: 4 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import globals from 'globals'
import eslint_js from '@eslint/js'
import reactPlugin from 'eslint-plugin-react'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import tsEslintPlugin from '@typescript-eslint/eslint-plugin'
import tsEslintParser from '@typescript-eslint/parser'

import reactHooksPlugin from 'eslint-plugin-react-hooks'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import globals from 'globals'

const customTsFlatConfig = [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@commitlint/config-conventional": "^19.6.0",
"@eslint/js": "^9.17.0",
"@react-types/shared": "^3.26.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.0",
"@types/event-source-polyfill": "^1.0.5",
"@types/node": "22.10.2",
"@types/react": "19.0.1",
Expand Down
63 changes: 40 additions & 23 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
import { Route, Routes, useNavigate } from 'react-router-dom'
import { lazy, Suspense, useEffect } from 'react'
import { useLocalStorage } from '@uidotdev/usehooks'
import { Suspense, lazy, useEffect } from 'react'
import { Provider } from 'react-redux'
import DialogProvider from '@/contexts/dialog'
import AudioProvider from '@/contexts/songs'
import Toaster from '@/components/toaster'
import { Route, Routes, useNavigate } from 'react-router-dom'

import key from '@/const/key'

import PageBackground from '@/components/page_background'
import store from '@/store'
import PageLoading from '@/components/page_loading'
import Toaster from '@/components/toaster'

import DialogProvider from '@/contexts/dialog'
import AudioProvider from '@/contexts/songs'

import { useLocalStorage } from '@uidotdev/usehooks'
import key from '@/const/key'
import useAuth from '@/hooks/auth'

import store from '@/store'

const WebLoginPage = lazy(() => import('@/pages/web_login'))
const IndexPage = lazy(() => import('@/pages/index'))
const QQLoginPage = lazy(() => import('@/pages/qq_login'))

function App() {
return (
<DialogProvider>
<Provider store={store}>
<PageBackground />
<Toaster />
<AudioProvider>
<Suspense fallback={<PageLoading />}>
<AuthChecker>
<AppRoutes />
</AuthChecker>
</Suspense>
</AudioProvider>
</Provider>
</DialogProvider>
)
}

function AuthChecker({ children }: { children: React.ReactNode }) {
const { isAuth } = useAuth()
const [storeURL] = useLocalStorage(key.storeURL)
const navigate = useNavigate()
Expand All @@ -40,22 +62,17 @@ function App() {
navigate(url, { replace: true })
}
}, [isAuth, storeURL, navigate])

return <>{children}</>
}

function AppRoutes() {
return (
<DialogProvider>
<Provider store={store}>
<PageBackground />
<Toaster />
<AudioProvider>
<Suspense fallback={<PageLoading />}>
<Routes>
<Route element={<IndexPage />} path="/*" />
<Route element={<QQLoginPage />} path="/qq_login" />
<Route element={<WebLoginPage />} path="/web_login" />
</Routes>
</Suspense>
</AudioProvider>
</Provider>
</DialogProvider>
<Routes>
<Route element={<IndexPage />} path="/*" />
<Route element={<QQLoginPage />} path="/qq_login" />
<Route element={<WebLoginPage />} path="/web_login" />
</Routes>
)
}

Expand Down
22 changes: 12 additions & 10 deletions src/components/audio_player.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Button } from '@nextui-org/button'
import { Card, CardBody, CardHeader } from '@nextui-org/card'
import { Image } from '@nextui-org/image'
import { Button } from '@nextui-org/button'
import { Popover, PopoverContent, PopoverTrigger } from '@nextui-org/popover'
import { Slider } from '@nextui-org/slider'
import { Tooltip } from '@nextui-org/tooltip'
import { useLocalStorage } from '@uidotdev/usehooks'
import clsx from 'clsx'
import { useEffect, useRef, useState } from 'react'
import {
BiSolidSkipPreviousCircle,
BiSolidSkipNextCircle
BiSolidSkipNextCircle,
BiSolidSkipPreviousCircle
} from 'react-icons/bi'
import {
FaPause,
Expand All @@ -13,17 +18,14 @@ import {
FaRepeat,
FaShuffle
} from 'react-icons/fa6'
import { useEffect, useRef, useState } from 'react'
import { PlayMode } from '@/const/enum'
import { TbRepeatOnce } from 'react-icons/tb'
import { Tooltip } from '@nextui-org/tooltip'
import { Popover, PopoverContent, PopoverTrigger } from '@nextui-org/popover'
import { VolumeHighIcon, VolumeLowIcon } from './icons'
import { useMediaQuery } from 'react-responsive'
import clsx from 'clsx'
import { useLocalStorage } from '@uidotdev/usehooks'

import { PlayMode } from '@/const/enum'
import key from '@/const/key'

import { VolumeHighIcon, VolumeLowIcon } from './icons'

export interface AudioPlayerProps
extends React.AudioHTMLAttributes<HTMLAudioElement> {
src: string
Expand Down
13 changes: 6 additions & 7 deletions src/components/button/add_button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Button } from '@nextui-org/button'
import {
Dropdown,
DropdownTrigger,
DropdownItem,
DropdownMenu,
DropdownItem
DropdownTrigger
} from '@nextui-org/dropdown'
import { Tooltip } from '@nextui-org/tooltip'
import { FaRegCircleQuestion } from 'react-icons/fa6'
import { IoAddCircleOutline } from 'react-icons/io5'

import {
HTTPClientIcon,
Expand All @@ -13,11 +17,6 @@ import {
WebsocketIcon
} from '../icons'

import { Button } from '@nextui-org/button'
import { IoAddCircleOutline } from 'react-icons/io5'
import { Tooltip } from '@nextui-org/tooltip'
import { FaRegCircleQuestion } from 'react-icons/fa6'

export interface AddButtonProps {
onOpen: (key: keyof OneBotConfig['network']) => void
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/save_buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@nextui-org/button'
import { IoMdRefresh } from 'react-icons/io'
import toast from 'react-hot-toast'
import { IoMdRefresh } from 'react-icons/io'

export interface SaveButtonsProps {
onSubmit: () => void
Expand Down
7 changes: 5 additions & 2 deletions src/components/code_editor.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react'
import Editor, { OnMount } from '@monaco-editor/react'
import monaco from '@/monaco'
import { loader } from '@monaco-editor/react'
import React from 'react'

import { useTheme } from '@/hooks/use-theme'

import monaco from '@/monaco'

loader.config({
monaco,
paths: {
Expand Down
6 changes: 4 additions & 2 deletions src/components/display_card/common_card.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Button, ButtonGroup } from '@nextui-org/button'
import { useState } from 'react'
import { Switch } from '@nextui-org/switch'
import { FiEdit3 } from 'react-icons/fi'
import { useState } from 'react'
import { CgDebug } from 'react-icons/cg'
import { FiEdit3 } from 'react-icons/fi'
import { MdDeleteForever } from 'react-icons/md'

import DisplayCardContainer from './container'

type NetworkType = OneBotConfig['network']

export type NetworkDisplayCardFields<T extends keyof NetworkType> = Array<{
Expand Down
1 change: 1 addition & 0 deletions src/components/display_card/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Card, CardBody, CardFooter, CardHeader } from '@nextui-org/card'
import clsx from 'clsx'

import { title } from '../primitives'

export interface ContainerProps {
title: string
tag?: React.ReactNode
Expand Down
1 change: 1 addition & 0 deletions src/components/display_card/http_client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chip } from '@nextui-org/chip'

import NetworkDisplayCard from './common_card'
import type { NetworkDisplayCardFields } from './common_card'

Expand Down
1 change: 1 addition & 0 deletions src/components/display_card/http_server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chip } from '@nextui-org/chip'

import NetworkDisplayCard from './common_card'
import type { NetworkDisplayCardFields } from './common_card'

Expand Down
1 change: 1 addition & 0 deletions src/components/display_card/ws_client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chip } from '@nextui-org/chip'

import NetworkDisplayCard from './common_card'
import type { NetworkDisplayCardFields } from './common_card'

Expand Down
1 change: 1 addition & 0 deletions src/components/display_card/ws_server.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chip } from '@nextui-org/chip'

import NetworkDisplayCard from './common_card'
import type { NetworkDisplayCardFields } from './common_card'

Expand Down
4 changes: 2 additions & 2 deletions src/components/github_info/release.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { GithubRelease as GithubReleaseType } from '@/types/github'

import { useEffect, useState } from 'react'

import { getReleaseTime } from '@/utils/time'

import type { GithubRelease as GithubReleaseType } from '@/types/github'

export interface GithubReleaseProps {
releaseData: GithubReleaseType
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/hitokoto.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { request } from '@/utils/request'
import { Button } from '@nextui-org/button'
import { Tooltip } from '@nextui-org/tooltip'
import { useRequest } from 'ahooks'
import PageLoading from './page_loading'
import { IoCopy, IoRefresh } from 'react-icons/io5'
import toast from 'react-hot-toast'
import { Tooltip } from '@nextui-org/tooltip'
import { IoCopy, IoRefresh } from 'react-icons/io5'

import { request } from '@/utils/request'

import PageLoading from './page_loading'

export default function Hitokoto() {
const {
data: dataOri,
Expand Down
3 changes: 2 additions & 1 deletion src/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react'

import { IconSvgProps, IconImageProps } from '@/types'
import logo from '@/assets/images/logo.png'
import { IconImageProps, IconSvgProps } from '@/types'

export const Logo: React.FC<IconImageProps> = ({
size = 36,
height,
Expand Down
13 changes: 8 additions & 5 deletions src/components/log_com/history.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Button } from '@nextui-org/button'
import { Card, CardBody, CardHeader } from '@nextui-org/card'
import XTerm from '../xterm'
import type { XTermRef } from '../xterm'
import { Select, SelectItem } from '@nextui-org/select'
import { Button } from '@nextui-org/button'
import type { Selection } from '@react-types/shared'
import { useEffect, useRef, useState } from 'react'
import PageLoading from '../page_loading'

import { colorizeLogLevel } from '@/utils/terminal'
import type { Selection } from '@react-types/shared'

import PageLoading from '../page_loading'
import XTerm from '../xterm'
import type { XTermRef } from '../xterm'
import LogLevelSelect from './log_level_select'

export interface HistoryLogsProps {
list: string[]
onSelect: (name: string) => void
Expand Down
3 changes: 2 additions & 1 deletion src/components/log_com/log_level_select.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { LogLevel } from '@/const/enum'
import { Chip } from '@nextui-org/chip'
import { Select, SelectItem } from '@nextui-org/select'
import { SharedSelection } from '@nextui-org/system'
import type { Selection } from '@react-types/shared'

import { LogLevel } from '@/const/enum'

export interface LogLevelSelectProps {
selectedKeys: Selection
onSelectionChange: (keys: SharedSelection) => void
Expand Down
15 changes: 9 additions & 6 deletions src/components/log_com/realtime.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Button } from '@nextui-org/button'
import type { Selection } from '@react-types/shared'
import { useEffect, useRef, useState } from 'react'
import type { XTermRef } from '../xterm'
import XTerm from '../xterm'
import WebUIManager, { Log } from '@/controllers/webui_manager'
import toast from 'react-hot-toast'
import { IoDownloadOutline } from 'react-icons/io5'

import { colorizeLogLevelWithTag } from '@/utils/terminal'

import WebUIManager, { Log } from '@/controllers/webui_manager'

import type { XTermRef } from '../xterm'
import XTerm from '../xterm'
import LogLevelSelect from './log_level_select'
import type { Selection } from '@react-types/shared'
import { Button } from '@nextui-org/button'
import { IoDownloadOutline } from 'react-icons/io5'

const RealTimeLogs = () => {
const Xterm = useRef<XTermRef>(null)
Expand Down
11 changes: 6 additions & 5 deletions src/components/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react'
import { Button } from '@nextui-org/button'
import {
Modal as NextUIModal,
ModalContent,
ModalHeader,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
Modal as NextUIModal,
useDisclosure
} from '@nextui-org/modal'
import { Button } from '@nextui-org/button'
import React from 'react'

export interface ModalProps {
content: React.ReactNode
title?: React.ReactNode
Expand Down
Loading

0 comments on commit 201ab36

Please sign in to comment.