Browse Source

为linter应用规则:tseslint.configs.recommended

dengdx 2 months ago
parent
commit
0bb3dc9a5d
3 changed files with 9 additions and 5 deletions
  1. 2 2
      eslint.config.mjs
  2. 5 2
      src/app.tsx
  3. 2 1
      src/layouts/NavbarFloat.tsx

+ 2 - 2
eslint.config.mjs

@@ -8,8 +8,8 @@ import globals from "globals";
 export default tseslint.config(
     // 基础 ESLint 推荐规则
     eslint.configs.recommended,
-    //   // TypeScript 推荐规则
-    //   ...tseslint.configs.recommended,
+    // TypeScript 推荐规则
+    ...tseslint.configs.recommended,
     //   // TypeScript 风格规则(可选)
     //   ...tseslint.configs.stylistic,
     // Prettier 配置

+ 5 - 2
src/app.tsx

@@ -6,9 +6,12 @@ import './app.css';
 import { lightTheme, darkTheme } from './themes';
 
 const locale = (window.navigator.language || 'en').toLowerCase().split('-')[0]; // Get locale from browser or default to 'en'
-const messages = require(`./assets/i18n/messages/${locale}`).default;
+import messages_en from './assets/i18n/messages/en';
+import messages_zh from './assets/i18n/messages/zh';
 
-function App({ children }: PropsWithChildren<any>) {
+const messages = locale === 'zh' ? messages_zh : messages_en;
+
+function App({ children }: PropsWithChildren<React.ReactNode>) {
   useLaunch(() => {
     console.log('App launched.');
   });

+ 2 - 1
src/layouts/NavbarFloat.tsx

@@ -7,6 +7,7 @@ import {
   ToolOutlined,
   PrinterOutlined,
 } from '@ant-design/icons';
+import type { MenuProps } from 'antd';
 
 interface NavbarFloatProps {
   position?: 'left' | 'right';
@@ -55,7 +56,7 @@ const NavbarFloat: React.FC<NavbarFloatProps> = ({
     },
   ];
 
-  const handleClick = (e: any) => {
+  const handleClick: MenuProps['onClick'] = (e) => {
     console.log('clicked ', e.key);
   };