@apdesign/code-style-react 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # 更新日志
2
2
 
3
+ ## [2.0.3] - 实际项目扫描对齐版本
4
+
5
+ ### 🎯 重要更新
6
+
7
+ 根据实际项目的 ESLint 扫描结果,精确对齐 Biome 规则配置,确保迁移时检查结果高度一致。
8
+
9
+ ### 🔧 新增规则映射
10
+
11
+ **无障碍性 (a11y)** - 对应 ESLint errors:
12
+ - `useAltText: error` ← `jsx-a11y/alt-text`
13
+ - `useAnchorContent: error` ← `jsx-a11y/anchor-is-valid`
14
+ - `useValidAnchor: error` ← `jsx-a11y/control-has-associated-label`
15
+
16
+ **风格 (style)** - 对应 ESLint errors/warnings:
17
+ - `useShorthandAssign: warn` ← `object-shorthand`
18
+ - `noNegationElse: warn` ← `no-else-return`
19
+ - `noUselessElse: warn` ← `no-lonely-if`
20
+ - `noUnusedTemplateLiteral: warn` ← `prefer-template`
21
+
22
+ **可疑代码 (suspicious)** - 对应实际扫描:
23
+ - `noConsole: warn` ← `no-console` (59个警告)
24
+ - `noEmptyBlockStatements: warn` ← 保持一致
25
+
26
+ **复杂度 (complexity)**:
27
+ - `useOptionalChain: warn` ← `prefer-destructuring` 相关
28
+
29
+ **正确性 (correctness)**:
30
+ - `noUnusedImports: warn` ← `import/newline-after-import` 相关
31
+ - `noConstantCondition: error` ← `consistent-return` 相关
32
+
33
+ ### 🎨 Scripts 目录特殊处理
34
+
35
+ 添加 `overrides` 配置,针对 CLI 工具相关文件:
36
+ - `scripts/**` 目录关闭 `noConsole` 检查
37
+ - `cli.js`、`index.js` 关闭 `noConsole` 检查
38
+
39
+ ### 📊 对齐效果
40
+
41
+ 配置现在能检测到与 ESLint 类似的问题:
42
+
43
+ **ESLint 高频 warnings**:
44
+ - ✅ `@typescript-eslint/no-explicit-any` → `noExplicitAny: warn`
45
+ - ✅ `@typescript-eslint/no-unused-vars` → `noUnusedVariables: warn`
46
+ - ✅ `no-console` → `noConsole: warn`
47
+ - ✅ `no-param-reassign` → `noParameterAssign: warn`
48
+ - ✅ `prefer-template` → `useTemplate: warn`
49
+
50
+ **ESLint 常见 errors**:
51
+ - ✅ `react/no-array-index-key` → `noArrayIndexKey: warn`
52
+ - ✅ `jsx-a11y/alt-text` → `useAltText: error`
53
+ - ✅ `jsx-a11y/anchor-is-valid` → `useValidAnchor: error`
54
+
55
+ ---
56
+
3
57
  ## [2.0.2] - Airbnb 风格对齐版本
4
58
 
5
59
  ### 🎯 重要调整
package/biome.jsonc CHANGED
@@ -27,18 +27,26 @@
27
27
  "a11y": {
28
28
  "noNoninteractiveElementInteractions": "off",
29
29
  "noStaticElementInteractions": "off",
30
- "useKeyWithClickEvents": "off"
30
+ "useKeyWithClickEvents": "off",
31
+ "useAltText": "error",
32
+ "useAnchorContent": "error",
33
+ "useValidAnchor": "error"
31
34
  },
32
35
  "complexity": {
33
36
  "noUselessConstructor": "error",
34
37
  "noUselessFragments": "off",
35
38
  "noForEach": "off",
36
- "noExcessiveCognitiveComplexity": "off"
39
+ "noExcessiveCognitiveComplexity": "off",
40
+ "useOptionalChain": "warn"
37
41
  },
38
42
  "correctness": {
39
43
  "noUndeclaredVariables": "off",
40
44
  "noUnusedVariables": "warn",
41
- "useExhaustiveDependencies": "off"
45
+ "noUnusedImports": "warn",
46
+ "useExhaustiveDependencies": "off",
47
+ "noUnreachable": "error",
48
+ "noConstantCondition": "error",
49
+ "noUnusedFunctionParameters": "off"
42
50
  },
43
51
  "style": {
44
52
  "noParameterAssign": "warn",
@@ -47,13 +55,27 @@
47
55
  "useNamingConvention": "off",
48
56
  "useTemplate": "warn",
49
57
  "useFilenamingConvention": "off",
50
- "useNodejsImportProtocol": "off"
58
+ "useNodejsImportProtocol": "off",
59
+ "useShorthandAssign": "warn",
60
+ "noNegationElse": "warn",
61
+ "useConsistentArrayType": "off",
62
+ "useExportType": "off",
63
+ "useImportType": "off",
64
+ "noUnusedTemplateLiteral": "warn",
65
+ "useSingleVarDeclarator": "off",
66
+ "noUselessElse": "warn"
51
67
  },
52
68
  "suspicious": {
53
69
  "noExplicitAny": "warn",
54
70
  "noArrayIndexKey": "warn",
55
- "noConsole": "off",
56
- "noDoubleEquals": "off"
71
+ "noConsole": "warn",
72
+ "noDoubleEquals": "off",
73
+ "noEmptyBlockStatements": "warn",
74
+ "noConfusingVoidType": "off",
75
+ "noConstEnum": "off"
76
+ },
77
+ "nursery": {
78
+ "useSortedClasses": "off"
57
79
  }
58
80
  }
59
81
  },
@@ -68,5 +90,17 @@
68
90
  "**/build/**",
69
91
  "**/coverage/**"
70
92
  ]
71
- }
93
+ },
94
+ "overrides": [
95
+ {
96
+ "includes": ["scripts/**", "cli.js", "index.js"],
97
+ "linter": {
98
+ "rules": {
99
+ "suspicious": {
100
+ "noConsole": "off"
101
+ }
102
+ }
103
+ }
104
+ }
105
+ ]
72
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/code-style-react",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "基于 Ultracite (Biome) 的现代化前端代码规范工具集,专为 React/TypeScript 项目设计",
5
5
  "keywords": [
6
6
  "biome",