@apdesign/code-style-react 2.0.1 → 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.
Files changed (3) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/biome.jsonc +37 -38
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
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
+
57
+ ## [2.0.2] - Airbnb 风格对齐版本
58
+
59
+ ### 🎯 重要调整
60
+
61
+ - **启用 Biome recommended 规则**: 改为 `"recommended": true`,更贴合 Airbnb 的基础规则集
62
+ - **移除 ultracite 扩展**: 不再继承 ultracite 预设,使用更接近 Airbnb 的纯净配置
63
+ - **极简规则覆盖**: 只覆盖与 Airbnb + 自定义规则不同的部分
64
+
65
+ ### 🔧 核心规则
66
+
67
+ **仅覆盖以下规则**(其他使用 Biome recommended 默认值):
68
+
69
+ **无障碍性 (a11y)**:
70
+ - 关闭交互性检查(与 Airbnb 一致)
71
+
72
+ **复杂度 (complexity)**:
73
+ - `noUselessConstructor: error`
74
+ - `noUselessFragments: off`
75
+ - `noForEach: off`
76
+ - `noExcessiveCognitiveComplexity: off`
77
+
78
+ **正确性 (correctness)**:
79
+ - `noUndeclaredVariables: off`
80
+ - `noUnusedVariables: warn`
81
+ - `useExhaustiveDependencies: off`(React hooks)
82
+
83
+ **风格 (style)**:
84
+ - `noParameterAssign: warn`
85
+ - `noNonNullAssertion: off`
86
+ - `useTemplate: warn`
87
+ - 关闭文件命名、Node.js 协议等约束
88
+
89
+ **可疑代码 (suspicious)**:
90
+ - `noExplicitAny: warn`
91
+ - `noArrayIndexKey: warn`
92
+ - `noConsole: off`
93
+ - `noDoubleEquals: off`
94
+
95
+ ### 📝 设计理念
96
+
97
+ 此版本完全对齐 **eslint-config-airbnb** 的宽松、实用风格:
98
+ - 启用 Biome 推荐规则作为基础
99
+ - 仅覆盖必要的差异配置
100
+ - 最大化兼容现有 Airbnb 项目
101
+ - 减少迁移时的代码调整
102
+
103
+ ---
104
+
3
105
  ## [2.0.1] - 规则放宽版本
4
106
 
5
107
  ### 🔧 调整
package/biome.jsonc CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
3
- "extends": ["ultracite"],
4
3
  "formatter": {
5
4
  "enabled": true,
6
5
  "indentStyle": "space",
@@ -24,76 +23,64 @@
24
23
  "linter": {
25
24
  "enabled": true,
26
25
  "rules": {
27
- "recommended": false,
26
+ "recommended": true,
28
27
  "a11y": {
29
28
  "noNoninteractiveElementInteractions": "off",
30
29
  "noStaticElementInteractions": "off",
31
- "useKeyWithClickEvents": "off"
30
+ "useKeyWithClickEvents": "off",
31
+ "useAltText": "error",
32
+ "useAnchorContent": "error",
33
+ "useValidAnchor": "error"
32
34
  },
33
35
  "complexity": {
34
- "noBannedTypes": "off",
35
36
  "noUselessConstructor": "error",
36
37
  "noUselessFragments": "off",
37
- "noUselessTypeConstraint": "off",
38
38
  "noForEach": "off",
39
39
  "noExcessiveCognitiveComplexity": "off",
40
- "noVoid": "off"
40
+ "useOptionalChain": "warn"
41
41
  },
42
42
  "correctness": {
43
- "noPrecisionLoss": "warn",
44
43
  "noUndeclaredVariables": "off",
45
44
  "noUnusedVariables": "warn",
46
45
  "noUnusedImports": "warn",
47
- "noUnusedPrivateClassMembers": "warn",
48
- "noUnusedFunctionParameters": "off",
49
46
  "useExhaustiveDependencies": "off",
50
- "noEmptyCharacterClassInRegex": "warn"
47
+ "noUnreachable": "error",
48
+ "noConstantCondition": "error",
49
+ "noUnusedFunctionParameters": "off"
51
50
  },
52
51
  "style": {
53
- "noNamespace": "off",
54
52
  "noParameterAssign": "warn",
55
53
  "noNonNullAssertion": "off",
56
- "useArrayLiterals": "off",
57
- "useAsConstAssertion": "off",
58
54
  "useBlockStatements": "off",
59
55
  "useNamingConvention": "off",
60
56
  "useTemplate": "warn",
61
57
  "useFilenamingConvention": "off",
62
- "useNumberNamespace": "off",
63
58
  "useNodejsImportProtocol": "off",
64
- "noUnusedTemplateLiteral": "off",
65
- "useExponentiationOperator": "warn",
66
- "noNegationElse": "off",
67
- "noMagicNumbers": "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"
68
67
  },
69
68
  "suspicious": {
70
- "noEmptyBlockStatements": "warn",
71
69
  "noExplicitAny": "warn",
72
- "noExtraNonNullAssertion": "warn",
73
- "noMisleadingInstantiator": "warn",
74
- "noUnsafeDeclarationMerging": "warn",
75
70
  "noArrayIndexKey": "warn",
76
- "noShadowRestrictedNames": "warn",
77
- "noConsole": "off",
71
+ "noConsole": "warn",
78
72
  "noDoubleEquals": "off",
79
- "noPrototypeBuiltins": "off"
73
+ "noEmptyBlockStatements": "warn",
74
+ "noConfusingVoidType": "off",
75
+ "noConstEnum": "off"
80
76
  },
81
- "performance": {
82
- "noAccumulatingSpread": "off",
83
- "noDelete": "off",
84
- "useTopLevelRegex": "off"
77
+ "nursery": {
78
+ "useSortedClasses": "off"
85
79
  }
86
80
  }
87
81
  },
88
82
  "files": {
89
- "includes": [
90
- "**/*.js",
91
- "**/*.jsx",
92
- "**/*.ts",
93
- "**/*.tsx",
94
- "**/*.json",
95
- "**/*.jsonc"
96
- ],
83
+ "includes": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "**/*.json", "**/*.jsonc"],
97
84
  "experimentalScannerIgnores": [
98
85
  "**/dist/**",
99
86
  "**/node_modules/**",
@@ -103,5 +90,17 @@
103
90
  "**/build/**",
104
91
  "**/coverage/**"
105
92
  ]
106
- }
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
+ ]
107
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/code-style-react",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "基于 Ultracite (Biome) 的现代化前端代码规范工具集,专为 React/TypeScript 项目设计",
5
5
  "keywords": [
6
6
  "biome",