Browse Source

feat: stylelint and eslint

BaiLuoYan 1 month ago
parent
commit
26e0281f60

+ 2 - 2
package.json

@@ -19,9 +19,9 @@
     "build:test": "tsc && vite build --mode test",
     "preview": "vite preview --mode localdev",
     "lint": "eslint . --report-unused-disable-directives --max-warnings 0",
-    "lint:fix": "eslint . --fix",
+    "lint:fix": "eslint . --fix && prettier --write \"src/**/*.{ts,tsx,js,jsx}\"",
     "stylelint": "stylelint \"src/**/*.{css,less,scss,vue}\"",
-    "stylelint:fix": "stylelint \"src/**/*.{css,less,scss,vue}\" --fix",
+    "stylelint:fix": "stylelint \"src/**/*.{css,less,scss,vue}\" --fix && prettier --write \"src/**/*.{css,less,scss,vue}\"",
     "prepare": "husky install"
   },
   "dependencies": {

+ 0 - 1
src/components/Dialog/index.tsx

@@ -6,7 +6,6 @@ import closeIcon from '@/assets/iconify/single-color/close.svg';
 import { useResponsive } from '@/hooks/useSize';
 import { dialogModel } from '@/models/dialogModel';
 
-
 import { useAction } from './useAction';
 
 export interface DialogButton {

+ 1 - 3
src/components/Topbar/index.tsx

@@ -149,9 +149,7 @@ const Topbar = memo(() => {
                     />
                     <nav
                         className={`fixed end-5 top-[81px] z-50 border border-white/[0.35] bg-black/85 rounded-lg origin-top ${
-                            isMobileMenuClosing
-                                ? 'animate-collapse-up'
-                                : 'animate-expand-down'
+                            isMobileMenuClosing ? 'animate-collapse-up' : 'animate-expand-down'
                         }`}
                         onAnimationEnd={handleMenuAnimationEnd}
                     >

+ 1 - 1
src/config/request/index.ts

@@ -18,7 +18,7 @@ const config: RequestConfig = {
         'Content-Type': 'application/json',
         'X-Requested-With': 'XMLHttpRequest',
         'X-NL-Product-Code': import.meta.env.VITE_API_PRODUCT_CODE!, // 每次请求必须包含产品代码
-        'X-NL-Request-Type': "web", // 请求类型,用于区分请求来源
+        'X-NL-Request-Type': 'web', // 请求类型,用于区分请求来源
     },
     paramsSerializer: (params) => stringify(params),
     ...errorConfig,

+ 0 - 1
src/config/request/requestErrorConfig.ts

@@ -6,7 +6,6 @@ import { message, notification } from '@/utils/antdAppInstance';
 import { RequestConfig } from '@/utils/request/types';
 // import { toLoginPage } from '@/utils/routerUtils';
 
-
 /**
  * @name 错误处理
  */

+ 1 - 1
src/defines/index.ts

@@ -3,4 +3,4 @@ export * from './errorShowType';
 export * from './planTagType';
 export * from './payMethodType';
 export * from './payOrderStatus';
-export * from './payUrlShowType';
+export * from './payUrlShowType';

+ 4 - 4
src/defines/payOrderStatus.ts

@@ -1,6 +1,6 @@
 export enum PayOrderStatus {
-    PAID = 1,  // 已支付
-    FAILED = 2,  // 支付失败
-    PENDING = 3,  // 待支付
-    OTHER = 4,  // 其他状态
+    PAID = 1, // 已支付
+    FAILED = 2, // 支付失败
+    PENDING = 3, // 待支付
+    OTHER = 4, // 其他状态
 }

+ 1 - 1
src/defines/planTagType.ts

@@ -2,4 +2,4 @@ export enum PlanTagType {
     NONE = 0, // 无标签
     MOST_POPULAR = 1, // 最受欢迎标签
     LIMITED_TIME = 2, // 限时优惠标签
-}
+}

+ 0 - 1
src/models/dialogModel.ts

@@ -4,7 +4,6 @@ import type { DialogProps } from '@/components/Dialog';
 
 import { createModel } from '../utils/model/createModel';
 
-
 interface DialogItem extends Omit<DialogProps, 'open' | 'id' | 'zIndex'> {
     id: string;
     zIndex: number;

+ 1 - 1
src/pages/home/components/SectionDivider.tsx

@@ -13,5 +13,5 @@ export function SectionDivider() {
                 />
             </svg>
         </div>
-    )
+    );
 }

+ 5 - 1
src/pages/pricing/components/PayMethodCard/index.tsx

@@ -30,7 +30,11 @@ const PayMethodCard = memo(({ item, isSelected = false, onClick }: PayMethodCard
         >
             <div className="flex items-center gap-2">
                 <div className="w-[50px] h-8 rounded-[4px] border border-[#d9d9d9] bg-white flex items-center justify-center overflow-hidden">
-                    <img src={item.icon} alt={item.name} className="h-5 w-auto max-w-[42px] object-contain" />
+                    <img
+                        src={item.icon}
+                        alt={item.name}
+                        className="h-5 w-auto max-w-[42px] object-contain"
+                    />
                 </div>
                 <span className="text-white text-2xl font-bold leading-8 whitespace-nowrap">
                     {item.name}

+ 0 - 1
src/pages/pricing/components/PlanCard/index.tsx

@@ -3,7 +3,6 @@ import { memo } from 'react';
 import { Icon } from '@iconify/react';
 import { useTranslation } from 'react-i18next';
 
-
 import checkOffIcon from '@/assets/iconify/multi-color/check-off.svg';
 import checkOnIcon from '@/assets/iconify/multi-color/check-on.svg';
 import { PlanTagType } from '@/defines';

+ 13 - 3
src/pages/routeDemo/index.tsx

@@ -81,7 +81,9 @@ const RouteDemo: React.FC = () => {
                                     <Button onClick={() => navigate('/home', { replace: true })}>
                                         替换跳转到首页
                                     </Button>
-                                    <Button onClick={() => navigate('/feature-demo', { replace: true })}>
+                                    <Button
+                                        onClick={() => navigate('/feature-demo', { replace: true })}
+                                    >
                                         替换跳转到功能演示
                                     </Button>
                                 </Space>
@@ -101,10 +103,18 @@ const RouteDemo: React.FC = () => {
                                     使用 useSmartRouter 保持查询参数:
                                 </Paragraph>
                                 <Space wrap>
-                                    <Button onClick={() => smartNavigate('/home', { from: 'routeDemo' })}>
+                                    <Button
+                                        onClick={() =>
+                                            smartNavigate('/home', { from: 'routeDemo' })
+                                        }
+                                    >
                                         智能跳转(保留当前查询参数)
                                     </Button>
-                                    <Button onClick={() => smartNavigate('/feature-demo', { id: '123' })}>
+                                    <Button
+                                        onClick={() =>
+                                            smartNavigate('/feature-demo', { id: '123' })
+                                        }
+                                    >
                                         智能跳转(添加新参数)
                                     </Button>
                                 </Space>