From 584041aba6f0d25e620b05f537c5cfd3d64c5dac Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Sun, 31 Jul 2022 18:17:35 +0800 Subject: [PATCH] format code --- .pre-commit-config.yaml | 8 ++++++++ admin-frontend/package.json | 3 ++- admin-frontend/src/App.tsx | 6 ++---- admin-frontend/src/features/auth/Auth.tsx | 15 ++++++++------- .../subsribeConfigManager/SubscribeManager.tsx | 10 +--------- .../subsribeConfigManager/subscribeConfigSlice.ts | 6 ++---- admin-frontend/src/pages/Home.tsx | 2 +- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d81977..42dc09a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,4 +20,12 @@ repos: hooks: - id: prettier types_or: [markdown, ts, tsx] + + - repo: local + hooks: + - id: admin-eslint + name: eslint + entry: bash -c 'yarn --cwd admin-frontend lint || exit 0' + language: system + pass_filenames: false exclude: 'CHANGELOG.md' diff --git a/admin-frontend/package.json b/admin-frontend/package.json index f67dfd8..af032f2 100644 --- a/admin-frontend/package.json +++ b/admin-frontend/package.json @@ -26,7 +26,8 @@ "start": "react-scripts start", "build": "react-scripts build && cp -r -f build/* ../src/plugins/nonebot_bison/admin_page/dist", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "lint": "eslint --fix src/**/*.ts src/**/*.tsx" }, "eslintConfig": { "extends": [ diff --git a/admin-frontend/src/App.tsx b/admin-frontend/src/App.tsx index 84ad3eb..87900bb 100644 --- a/admin-frontend/src/App.tsx +++ b/admin-frontend/src/App.tsx @@ -18,16 +18,14 @@ function App() { }, [globalConfLoaded]); return ( - <> - { globalConfLoaded + globalConfLoaded && ( } /> } /> } /> - )} - + ) ); } diff --git a/admin-frontend/src/features/auth/Auth.tsx b/admin-frontend/src/features/auth/Auth.tsx index 33303cb..423b3c5 100644 --- a/admin-frontend/src/features/auth/Auth.tsx +++ b/admin-frontend/src/features/auth/Auth.tsx @@ -14,11 +14,12 @@ export default function Auth() { dispatch(login(code)); } }, [isLogin, code]); - return ( - { isLogin - ? - : isFailed - ? - :
login
} - ); + + if (isLogin) { + return ; + } + if (isFailed) { + return ; + } + return
login
; } diff --git a/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx b/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx index 34a6aa0..5842c35 100644 --- a/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx +++ b/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx @@ -1,14 +1,6 @@ import React from 'react'; -import { SubscribeResp } from '../../utils/type'; -import { useGetSubsQuery } from './subscribeConfigSlice'; -export function SubscribeManager() { - const { - data: subs, - isLoading, - isFetching, - isSuccess, - } = useGetSubsQuery(); +export default function SubscribeManager() { return ( <> diff --git a/admin-frontend/src/features/subsribeConfigManager/subscribeConfigSlice.ts b/admin-frontend/src/features/subsribeConfigManager/subscribeConfigSlice.ts index 85dab07..fa64d46 100644 --- a/admin-frontend/src/features/subsribeConfigManager/subscribeConfigSlice.ts +++ b/admin-frontend/src/features/subsribeConfigManager/subscribeConfigSlice.ts @@ -1,7 +1,5 @@ -import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { RootState } from '../../app/store'; -import { StatusResp, SubscribeResp, SubscribeConfig } from '../../utils/type'; -import { subsribeUrl } from '../../utils/urls'; +import { createApi } from '@reduxjs/toolkit/query/react'; +import { StatusResp, SubscribeConfig, SubscribeResp } from '../../utils/type'; import { baseQueryWithAuth } from '../auth/authQuery'; export const subscribeApi = createApi({ diff --git a/admin-frontend/src/pages/Home.tsx b/admin-frontend/src/pages/Home.tsx index ee26c7b..ede2aaa 100644 --- a/admin-frontend/src/pages/Home.tsx +++ b/admin-frontend/src/pages/Home.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { SubscribeManager } from '../features/subsribeConfigManager/SubscribeManager'; +import SubscribeManager from '../features/subsribeConfigManager/SubscribeManager'; export default function Home() { return (