From 8d63b1e80bd52c201701e6608aeded420ab87d13 Mon Sep 17 00:00:00 2001 From: rex Date: Thu, 23 Oct 2025 16:31:00 +0800 Subject: [PATCH] lint --- biome.json | 3 +- src/main.tsx | 6 ++-- src/pages/about/index.tsx | 4 +-- src/pages/home/index.tsx | 54 ++++++++++++++-------------- src/providers/MujianProvider.tsx | 60 ++++++++++++++++---------------- src/providers/RouterProvider.tsx | 18 +++++----- src/store/global.tsx | 14 ++++---- src/styles/global.css | 16 ++++----- 8 files changed, 88 insertions(+), 87 deletions(-) diff --git a/biome.json b/biome.json index 3358a1d..6a815f2 100644 --- a/biome.json +++ b/biome.json @@ -10,7 +10,8 @@ }, "formatter": { "enabled": true, - "indentStyle": "tab" + "indentStyle": "space", + "indentWidth": 2 }, "linter": { "enabled": true, diff --git a/src/main.tsx b/src/main.tsx index f369948..79e526e 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,7 +5,7 @@ import { MujianProvider } from './providers/MujianProvider.tsx'; import { ReactRouterProvider } from './providers/RouterProvider.tsx'; createRoot(document.getElementById('root')!).render( - - - , + + + , ); diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index fb278f9..e7ee1f0 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -2,9 +2,9 @@ import './index.css'; // import { useGlobalStore } from "@/store/global"; function About() { - // const { count, increment } = useGlobalStore((state) => state); + // const { count, increment } = useGlobalStore((state) => state); - return
about page
; + return
about page
; } export default About; diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index f9e190c..3d9d52b 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -4,39 +4,39 @@ import { isEmpty } from 'lodash-es'; import { EVENT, useMujian } from '@/providers/MujianProvider'; function Home() { - const { count, increment } = useGlobalStore((state) => state); - const mujian = useMujian(); + const { count, increment } = useGlobalStore((state) => state); + const mujian = useMujian(); - console.log('count', count); + console.log('count', count); - console.log('isEmpty', isEmpty(count)); + console.log('isEmpty', isEmpty(count)); - return ( - <> -
-
Hello World2
-
-

Vite + React

- + return ( + <> +
+
Hello World2
+
+

Vite + React

+ -

Count: {count}

+

Count: {count}

-
+
- - - ); + + + ); } export default Home; diff --git a/src/providers/MujianProvider.tsx b/src/providers/MujianProvider.tsx index d85e79f..d69e6af 100644 --- a/src/providers/MujianProvider.tsx +++ b/src/providers/MujianProvider.tsx @@ -2,11 +2,11 @@ import { MujianSdk } from '@mujian/js-sdk'; import { - createContext, - type ReactNode, - useContext, - useEffect, - useState, + createContext, + type ReactNode, + useContext, + useEffect, + useState, } from 'react'; export { EVENT } from '@mujian/js-sdk'; @@ -14,38 +14,38 @@ export { EVENT } from '@mujian/js-sdk'; const MujianContext = createContext(null); export interface MujianProviderProps { - children: ReactNode; - loadingPage?: ReactNode; + children: ReactNode; + loadingPage?: ReactNode; } export const MujianProvider = ({ - children, - loadingPage, + children, + loadingPage, }: MujianProviderProps) => { - const [mujian, setMujian] = useState(null); + const [mujian, setMujian] = useState(null); - useEffect(() => { - (async () => { - const mujian = new MujianSdk(); - await mujian.init(); - setMujian(mujian); - })(); - }, []); + useEffect(() => { + (async () => { + const mujian = new MujianSdk(); + await mujian.init(); + setMujian(mujian); + })(); + }, []); - return ( - - {mujian ? children : (loadingPage ?? 'Mujian is loading')} - - ); + return ( + + {mujian ? children : (loadingPage ?? 'Mujian is loading')} + + ); }; export const useMujian = () => { - const mujian = useContext(MujianContext); - if (!mujian) { - const message = - 'Mujian is not initialized. Please check that useMujian is called inside MujianProvider'; - console.error(message); - throw new Error(message); - } - return mujian; + const mujian = useContext(MujianContext); + if (!mujian) { + const message = + 'Mujian is not initialized. Please check that useMujian is called inside MujianProvider'; + console.error(message); + throw new Error(message); + } + return mujian; }; diff --git a/src/providers/RouterProvider.tsx b/src/providers/RouterProvider.tsx index 0e7717d..ead1e77 100644 --- a/src/providers/RouterProvider.tsx +++ b/src/providers/RouterProvider.tsx @@ -4,16 +4,16 @@ import About from '@/pages/about'; import Home from '@/pages/home'; const router = createBrowserRouter([ - { - path: '/', - element: , - }, - { - path: '/about', - element: , - }, + { + path: '/', + element: , + }, + { + path: '/about', + element: , + }, ]); export const ReactRouterProvider = () => { - return ; + return ; }; diff --git a/src/store/global.tsx b/src/store/global.tsx index 6459e25..c4ae7f0 100644 --- a/src/store/global.tsx +++ b/src/store/global.tsx @@ -1,14 +1,14 @@ import { create } from 'zustand'; type GlobalState = { - count: number; - increment: () => void; + count: number; + increment: () => void; }; export const useGlobalStore = create((set) => ({ - count: 0, - increment: () => { - console.log('increment'); - set((state) => ({ count: state.count + 1 })); - }, + count: 0, + increment: () => { + console.log('increment'); + set((state) => ({ count: state.count + 1 })); + }, })); diff --git a/src/styles/global.css b/src/styles/global.css index e87dd7b..5aa6cf6 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -1,14 +1,14 @@ @import "tailwindcss"; :root { - font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; - color-scheme: light dark; + color-scheme: light dark; - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; }