Sfoglia il codice sorgente

✨ feat(eslint): 添加ESLint基础配置和集成

- 安装ESLint核心包和相关插件 (@eslint/js, @typescript-eslint, eslint-plugin-react等)
- 创建ESLint配置文件 (eslint.config.js) 支持TypeScript和React
- 配置浏览器和Node.js环境特定规则
- 更新package.json脚本添加lint相关命令
- 更新Claude配置添加ESLint检查命令

📝 docs(story): 更新ESLint安装配置文档状态

- 将故事状态从Draft更新为Ready for Review
- 添加开发代理记录和完成事项列表
- 记录相关文件变更和调试日志引用
yourname 2 mesi fa
parent
commit
ee36ea47b2
5 ha cambiato i file con 726 aggiunte e 2 eliminazioni
  1. 3 1
      .claude/settings.local.json
  2. 13 1
      docs/stories/003.001.story.md
  3. 96 0
      eslint.config.js
  4. 7 0
      package.json
  5. 607 0
      pnpm-lock.yaml

+ 3 - 1
.claude/settings.local.json

@@ -8,7 +8,9 @@
       "Bash(pnpm run lint)",
       "Bash(find:*)",
       "Bash(npm run test:*)",
-      "Bash(npx vitest:*)"
+      "Bash(npx vitest:*)",
+      "Bash(pnpm run lint:*)",
+      "Bash(npx eslint:*)"
     ],
     "deny": [],
     "ask": []

+ 13 - 1
docs/stories/003.001.story.md

@@ -1,7 +1,7 @@
 # Story 003.001: 安装和配置ESLint基础框架
 
 ## Status
-Draft
+Ready for Review
 
 ## Story
 **As a** 开发者,
@@ -77,11 +77,23 @@ ESLint配置文件应创建在项目根目录:
 ## Dev Agent Record
 
 ### Agent Model Used
+- Developer Agent (James)
 
 ### Debug Log References
+- ESLint v9.35.0 配置迁移
+- TypeScript和React规则配置
+- 环境特定全局变量设置
 
 ### Completion Notes List
+- ✅ 安装ESLint核心包和相关插件
+- ✅ 创建ESLint配置文件 (eslint.config.js)
+- ✅ 配置TypeScript和React特定规则
+- ✅ 集成到package.json脚本
+- ✅ 支持浏览器和Node.js环境
+- ✅ 配置测试环境全局变量
 
 ### File List
+- package.json (更新devDependencies)
+- eslint.config.js (新建配置文件)
 
 ## QA Results

+ 96 - 0
eslint.config.js

@@ -0,0 +1,96 @@
+import js from '@eslint/js';
+import typescriptEslint from '@typescript-eslint/eslint-plugin';
+import typescriptParser from '@typescript-eslint/parser';
+import reactPlugin from 'eslint-plugin-react';
+import reactHooks from 'eslint-plugin-react-hooks';
+import globals from 'globals';
+
+export default [
+  // 基础配置
+  {
+    files: ['**/*.{js,jsx,ts,tsx}'],
+    ignores: [
+      'dist/**',
+      'node_modules/**',
+      '*.config.js',
+      '*.config.ts',
+      'tests/e2e/**',
+      'scripts/**',
+      'server.js',
+      'vitest.config.components.ts',
+      'coverage/**',
+    ],
+    languageOptions: {
+      ecmaVersion: 'latest',
+      sourceType: 'module',
+      parser: typescriptParser,
+      parserOptions: {
+        ecmaFeatures: {
+          jsx: true,
+        },
+      },
+      globals: {
+        ...globals.browser,
+        ...globals.es2021,
+        RequestInfo: 'readonly',
+        RequestInit: 'readonly',
+        URL: 'readonly',
+        Response: 'readonly',
+      },
+    },
+    plugins: {
+      '@typescript-eslint': typescriptEslint,
+      react: reactPlugin,
+      'react-hooks': reactHooks,
+    },
+    rules: {
+      // 基础ESLint规则
+      ...js.configs.recommended.rules,
+
+      // TypeScript规则
+      '@typescript-eslint/no-unused-vars': ['error', {
+        argsIgnorePattern: '^_',
+        varsIgnorePattern: '^_',
+        caughtErrorsIgnorePattern: '^_',
+      }],
+      '@typescript-eslint/no-explicit-any': 'warn',
+      '@typescript-eslint/explicit-function-return-type': 'off',
+
+      // React规则
+      'react/react-in-jsx-scope': 'off',
+      'react/prop-types': 'off',
+
+      // 通用规则
+      'no-console': 'warn',
+      'prefer-const': 'error',
+      'no-undef': 'off', // TypeScript已经处理了未定义变量
+      'no-unused-vars': 'off', // 使用TypeScript的版本
+    },
+    settings: {
+      react: {
+        version: 'detect',
+      },
+    },
+  },
+
+  // Node.js环境配置
+  {
+    files: ['src/server/**/*.{js,ts}', 'src/test/**/*.{js,ts}'],
+    languageOptions: {
+      globals: {
+        ...globals.node,
+      },
+    },
+  },
+
+  // 测试环境配置
+  {
+    files: ['src/**/__tests__/**/*.{js,ts,jsx,tsx}', 'src/**/__integration_tests__/**/*.{js,ts,jsx,tsx}'],
+    languageOptions: {
+      globals: {
+        ...globals.jest,
+        vi: 'readonly',
+      },
+    },
+  },
+];

+ 7 - 0
package.json

@@ -99,6 +99,7 @@
     "zod": "^4.0.15"
   },
   "devDependencies": {
+    "@eslint/js": "^9.35.0",
     "@playwright/test": "^1.55.0",
     "@tailwindcss/vite": "^4.1.11",
     "@testing-library/react": "^16.3.0",
@@ -109,9 +110,15 @@
     "@types/node": "^24.0.10",
     "@types/react": "^19.1.8",
     "@types/react-dom": "^19.1.6",
+    "@typescript-eslint/eslint-plugin": "^8.43.0",
+    "@typescript-eslint/parser": "^8.43.0",
     "@vitejs/plugin-react-swc": "^3.10.2",
     "@vitest/coverage-v8": "^3.2.4",
     "cross-env": "^7.0.3",
+    "eslint": "^9.35.0",
+    "eslint-plugin-react": "^7.37.5",
+    "eslint-plugin-react-hooks": "^5.2.0",
+    "globals": "^16.4.0",
     "happy-dom": "^18.0.1",
     "tailwindcss": "^4.1.11",
     "tsx": "^4.20.3",

File diff suppressed because it is too large
+ 607 - 0
pnpm-lock.yaml


Some files were not shown because too many files changed in this diff