diff --git a/eslint.config.mjs b/eslint.config.mjs index e930b6ef..b413ff63 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -24,6 +24,15 @@ const commaDangle = val => { val.rules.camelcase = 'off'; } + /** 未使用的变量强制报错 */ + if (val?.rules?.['@typescript-eslint/no-unused-vars']) { + val.rules['@typescript-eslint/no-unused-vars'] = ['error', { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }]; + } + return val; }; diff --git a/napcat.webui/eslint.config.mjs b/napcat.webui/eslint.config.mjs new file mode 100644 index 00000000..ecbdd00f --- /dev/null +++ b/napcat.webui/eslint.config.mjs @@ -0,0 +1,2 @@ +import eslintConfig from '../eslint.config.mjs'; +export default eslintConfig; diff --git a/napcat.webui/src/components/file_manage/move_modal.tsx b/napcat.webui/src/components/file_manage/move_modal.tsx index 1a424c66..621b4c8d 100644 --- a/napcat.webui/src/components/file_manage/move_modal.tsx +++ b/napcat.webui/src/components/file_manage/move_modal.tsx @@ -44,7 +44,7 @@ function DirectoryTree ({ // 直接使用 basePath 调用接口,移除 process.platform 判断 const list = await FileManager.listDirectories(basePath); setDirs(list.map((item) => item.name)); - } catch (error) { + } catch (_error) { // ...error handling... } }; diff --git a/napcat.webui/src/components/hitokoto.tsx b/napcat.webui/src/components/hitokoto.tsx index ef7f0b4f..15034262 100644 --- a/napcat.webui/src/components/hitokoto.tsx +++ b/napcat.webui/src/components/hitokoto.tsx @@ -24,7 +24,7 @@ export default function Hitokoto () { const text = `${data?.hitokoto} —— ${data?.from} ${data?.from_who}`; navigator.clipboard.writeText(text); toast.success('复制成功'); - } catch (error) { + } catch (_error) { toast.error('复制失败, 请手动复制'); } }; diff --git a/napcat.webui/src/components/input/file_input.tsx b/napcat.webui/src/components/input/file_input.tsx index 382f10fd..38035985 100644 --- a/napcat.webui/src/components/input/file_input.tsx +++ b/napcat.webui/src/components/input/file_input.tsx @@ -34,7 +34,7 @@ const FileInput: React.FC = ({ if (file) { await onChange(file); } - } catch (error) { + } catch (_error) { console.error(error); } finally { setIsLoading(false); @@ -49,7 +49,7 @@ const FileInput: React.FC = ({ try { setIsLoading(true); if (onDelete) await onDelete(); - } catch (error) { + } catch (_error) { console.error(error); } finally { setIsLoading(false); diff --git a/napcat.webui/src/components/log_com/realtime.tsx b/napcat.webui/src/components/log_com/realtime.tsx index 5d07c936..94106715 100644 --- a/napcat.webui/src/components/log_com/realtime.tsx +++ b/napcat.webui/src/components/log_com/realtime.tsx @@ -51,7 +51,7 @@ const RealTimeLogs = () => { .join('\r\n'); Xterm.current?.clear(); Xterm.current?.write(_data); - } catch (error) { + } catch (_error) { console.error(error); toast.error('获取实时日志失败'); } @@ -76,7 +76,7 @@ const RealTimeLogs = () => { return () => { source.close(); }; - } catch (error) { + } catch (_error) { toast.error('获取实时日志失败'); } }; diff --git a/napcat.webui/src/components/network_edit/modal.tsx b/napcat.webui/src/components/network_edit/modal.tsx index 3139261b..669f38f9 100644 --- a/napcat.webui/src/components/network_edit/modal.tsx +++ b/napcat.webui/src/components/network_edit/modal.tsx @@ -41,7 +41,7 @@ const NetworkFormModal = ( await updateNetworkConfig(field, data); } toast.success('保存配置成功'); - } catch (error) { + } catch (_error) { const msg = (error as Error).message; toast.error(`保存配置失败: ${msg}`); diff --git a/napcat.webui/src/components/onebot/api/debug.tsx b/napcat.webui/src/components/onebot/api/debug.tsx index 4139e617..08bad899 100644 --- a/napcat.webui/src/components/onebot/api/debug.tsx +++ b/napcat.webui/src/components/onebot/api/debug.tsx @@ -77,7 +77,7 @@ const OneBotApiDebug: React.FC = (props) => { }); toast.dismiss(r); }); - } catch (error) { + } catch (_error) { toast.error('请求体 JSON 格式错误'); setIsFetching(false); toast.dismiss(r); diff --git a/napcat.webui/src/components/onebot/send_modal.tsx b/napcat.webui/src/components/onebot/send_modal.tsx index 0e28f2e8..0d6ba019 100644 --- a/napcat.webui/src/components/onebot/send_modal.tsx +++ b/napcat.webui/src/components/onebot/send_modal.tsx @@ -15,7 +15,7 @@ import CodeEditor from '@/components/code_editor'; import type { CodeEditorRef } from '@/components/code_editor'; export interface OneBotSendModalProps { - sendMessage: (msg: string) => void + sendMessage: (msg: string) => void; } const OneBotSendModal: React.FC = (props) => { @@ -34,7 +34,7 @@ const OneBotSendModal: React.FC = (props) => { sendMessage(msg); toast.success('消息发送成功'); onClose(); - } catch (error) { + } catch (_error) { toast.error('消息发送失败'); } }, diff --git a/napcat.webui/src/components/tailwind_markdown.tsx b/napcat.webui/src/components/tailwind_markdown.tsx index bd649f35..0299c9d1 100644 --- a/napcat.webui/src/components/tailwind_markdown.tsx +++ b/napcat.webui/src/components/tailwind_markdown.tsx @@ -7,36 +7,36 @@ const TailwindMarkdown: React.FC<{ content: string }> = ({ content }) => { className='prose prose-sm sm:prose lg:prose-lg xl:prose-xl' remarkPlugins={[remarkGfm]} components={{ - h1: ({ node, ...props }) => ( + h1: ({ node: _node, ...props }) => (

), - h2: ({ node, ...props }) => ( + h2: ({ node: _node, ...props }) => (

), - h3: ({ node, ...props }) => ( + h3: ({ node: _node, ...props }) => (

), - p: ({ node, ...props }) =>

, - a: ({ node, ...props }) => ( + p: ({ node: _node, ...props }) =>

, + a: ({ node: _node, ...props }) => ( ), - ul: ({ node, ...props }) => ( + ul: ({ node: _node, ...props }) => (