@apdesign/code-style-react 2.0.2 → 2.0.5
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 +135 -0
- package/biome.jsonc +66 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,140 @@
|
|
1
1
|
# 更新日志
|
2
2
|
|
3
|
+
## [2.0.5] - Biome 规则精准对齐版本
|
4
|
+
|
5
|
+
### 🎯 重要更新
|
6
|
+
|
7
|
+
根据实际项目的 ESLint error 和 warning 扫描结果,进一步优化 Biome 规则配置,提升规则覆盖率和严重程度对齐。
|
8
|
+
|
9
|
+
### 🔧 规则调整
|
10
|
+
|
11
|
+
**严重程度提升(warn → error)**:
|
12
|
+
- `noParameterAssign: error` ← `no-param-reassign`
|
13
|
+
- `useTemplate: error` ← `prefer-template`
|
14
|
+
- `noUselessElse: error` ← `no-else-return`
|
15
|
+
- `noExplicitAny: error` ← `@typescript-eslint/no-explicit-any`
|
16
|
+
- `noArrayIndexKey: error` ← `react/no-array-index-key`
|
17
|
+
- `noEmptyBlockStatements: error` ← `no-empty-function`
|
18
|
+
- `noShadowRestrictedNames: error` ← `@typescript-eslint/no-shadow`
|
19
|
+
|
20
|
+
**新增规则 (Complexity)**:
|
21
|
+
- `noUselessEscapeInRegex: error` ← `no-useless-escape` 部分
|
22
|
+
- `noUselessTernary: error` ← `no-unneeded-ternary`
|
23
|
+
- `useArrowFunction: error` ← `prefer-arrow-callback`
|
24
|
+
- `useLiteralKeys: warn` ← `dot-notation`
|
25
|
+
|
26
|
+
**新增规则 (Correctness)**:
|
27
|
+
- `noUnsafeOptionalChaining: error` ← `no-unsafe-optional-chaining`
|
28
|
+
|
29
|
+
**新增规则 (Style)**:
|
30
|
+
- `useCollapsedElseIf: error` ← `no-lonely-if`
|
31
|
+
- `useDefaultParameterLast: error` ← `default-param-last`
|
32
|
+
- `useConst: error` ← `prefer-const`
|
33
|
+
- `useExponentiationOperator: error` ← 使用 ** 而不是 Math.pow
|
34
|
+
|
35
|
+
### 📊 覆盖率统计
|
36
|
+
|
37
|
+
- **可配置规则总数**: 15 个 Biome 规则
|
38
|
+
- **ESLint 规则覆盖率**: 约 35-40%
|
39
|
+
- **Error 级别规则**: 12 个
|
40
|
+
- **Warn 级别规则**: 3 个
|
41
|
+
|
42
|
+
### ❌ Biome 不支持的规则
|
43
|
+
|
44
|
+
以下 ESLint 规则在 Biome 中暂无对应,已接受放弃检查:
|
45
|
+
|
46
|
+
**Import 管理**:
|
47
|
+
- `import/order`, `import/newline-after-import`, `import/no-unresolved`, `import/no-duplicates`, `import/no-extraneous-dependencies`
|
48
|
+
|
49
|
+
**React 特定**:
|
50
|
+
- `react/no-unused-prop-types`, `react/jsx-no-constructed-context-values`, `react/no-unstable-nested-components`, `react/jsx-curly-brace-presence`, `react/destructuring-assignment`
|
51
|
+
|
52
|
+
**代码风格**:
|
53
|
+
- `no-underscore-dangle`, `spaced-comment`, `no-continue`, `lines-between-class-members`, `func-names`
|
54
|
+
|
55
|
+
**逻辑检查**:
|
56
|
+
- `consistent-return`, `no-nested-ternary`, `no-restricted-globals`, `no-loop-func`, `no-useless-return`, `prefer-promise-reject-errors`, `no-new-wrappers`, `one-var`, `no-restricted-syntax`, `@typescript-eslint/no-use-before-define`, `prefer-destructuring`
|
57
|
+
|
58
|
+
### 🎨 配置原则
|
59
|
+
|
60
|
+
1. **严重程度对齐**: ESLint error → Biome error, ESLint warn → Biome warn
|
61
|
+
2. **规则冲突统一**: 同一规则出现在 error 和 warning 中时,统一设为 error
|
62
|
+
3. **覆盖率优先**: 能配置的规则尽可能配置
|
63
|
+
4. **接受限制**: Biome 不支持的规则接受放弃
|
64
|
+
|
65
|
+
### 📝 使用建议
|
66
|
+
|
67
|
+
使用 Biome 检查项目:
|
68
|
+
```bash
|
69
|
+
npx @biomejs/biome check . --write
|
70
|
+
```
|
71
|
+
|
72
|
+
查看诊断信息:
|
73
|
+
```bash
|
74
|
+
npx @biomejs/biome check . --diagnostic-level=error
|
75
|
+
```
|
76
|
+
|
77
|
+
### 🔗 相关链接
|
78
|
+
|
79
|
+
- Biome 官方文档: https://biomejs.dev
|
80
|
+
- Biome 规则参考: https://www.biomejs.cn/linter
|
81
|
+
|
82
|
+
---
|
83
|
+
|
84
|
+
## [2.0.3] - 实际项目扫描对齐版本
|
85
|
+
|
86
|
+
### 🎯 重要更新
|
87
|
+
|
88
|
+
根据实际项目的 ESLint 扫描结果,精确对齐 Biome 规则配置,确保迁移时检查结果高度一致。
|
89
|
+
|
90
|
+
### 🔧 新增规则映射
|
91
|
+
|
92
|
+
**无障碍性 (a11y)** - 对应 ESLint errors:
|
93
|
+
- `useAltText: error` ← `jsx-a11y/alt-text`
|
94
|
+
- `useAnchorContent: error` ← `jsx-a11y/anchor-is-valid`
|
95
|
+
- `useValidAnchor: error` ← `jsx-a11y/control-has-associated-label`
|
96
|
+
|
97
|
+
**风格 (style)** - 对应 ESLint errors/warnings:
|
98
|
+
- `useShorthandAssign: warn` ← `object-shorthand`
|
99
|
+
- `noNegationElse: warn` ← `no-else-return`
|
100
|
+
- `noUselessElse: warn` ← `no-lonely-if`
|
101
|
+
- `noUnusedTemplateLiteral: warn` ← `prefer-template`
|
102
|
+
|
103
|
+
**可疑代码 (suspicious)** - 对应实际扫描:
|
104
|
+
- `noConsole: warn` ← `no-console` (59个警告)
|
105
|
+
- `noEmptyBlockStatements: warn` ← 保持一致
|
106
|
+
|
107
|
+
**复杂度 (complexity)**:
|
108
|
+
- `useOptionalChain: warn` ← `prefer-destructuring` 相关
|
109
|
+
|
110
|
+
**正确性 (correctness)**:
|
111
|
+
- `noUnusedImports: warn` ← `import/newline-after-import` 相关
|
112
|
+
- `noConstantCondition: error` ← `consistent-return` 相关
|
113
|
+
|
114
|
+
### 🎨 Scripts 目录特殊处理
|
115
|
+
|
116
|
+
添加 `overrides` 配置,针对 CLI 工具相关文件:
|
117
|
+
- `scripts/**` 目录关闭 `noConsole` 检查
|
118
|
+
- `cli.js`、`index.js` 关闭 `noConsole` 检查
|
119
|
+
|
120
|
+
### 📊 对齐效果
|
121
|
+
|
122
|
+
配置现在能检测到与 ESLint 类似的问题:
|
123
|
+
|
124
|
+
**ESLint 高频 warnings**:
|
125
|
+
- ✅ `@typescript-eslint/no-explicit-any` → `noExplicitAny: warn`
|
126
|
+
- ✅ `@typescript-eslint/no-unused-vars` → `noUnusedVariables: warn`
|
127
|
+
- ✅ `no-console` → `noConsole: warn`
|
128
|
+
- ✅ `no-param-reassign` → `noParameterAssign: warn`
|
129
|
+
- ✅ `prefer-template` → `useTemplate: warn`
|
130
|
+
|
131
|
+
**ESLint 常见 errors**:
|
132
|
+
- ✅ `react/no-array-index-key` → `noArrayIndexKey: warn`
|
133
|
+
- ✅ `jsx-a11y/alt-text` → `useAltText: error`
|
134
|
+
- ✅ `jsx-a11y/anchor-is-valid` → `useValidAnchor: error`
|
135
|
+
|
136
|
+
---
|
137
|
+
|
3
138
|
## [2.0.2] - Airbnb 风格对齐版本
|
4
139
|
|
5
140
|
### 🎯 重要调整
|
package/biome.jsonc
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
|
3
|
+
"vcs": {
|
4
|
+
"enabled": true,
|
5
|
+
"clientKind": "git",
|
6
|
+
"useIgnoreFile": true
|
7
|
+
},
|
3
8
|
"formatter": {
|
4
9
|
"enabled": true,
|
5
10
|
"indentStyle": "space",
|
@@ -27,46 +32,90 @@
|
|
27
32
|
"a11y": {
|
28
33
|
"noNoninteractiveElementInteractions": "off",
|
29
34
|
"noStaticElementInteractions": "off",
|
30
|
-
"useKeyWithClickEvents": "off"
|
35
|
+
"useKeyWithClickEvents": "off",
|
36
|
+
"useAltText": "error",
|
37
|
+
"useAnchorContent": "error",
|
38
|
+
"useValidAnchor": "error"
|
31
39
|
},
|
32
40
|
"complexity": {
|
33
41
|
"noUselessConstructor": "error",
|
34
42
|
"noUselessFragments": "off",
|
35
43
|
"noForEach": "off",
|
36
|
-
"noExcessiveCognitiveComplexity": "off"
|
44
|
+
"noExcessiveCognitiveComplexity": "off",
|
45
|
+
"useOptionalChain": "warn",
|
46
|
+
"noUselessEscapeInRegex": "error",
|
47
|
+
"noUselessTernary": "error",
|
48
|
+
"useArrowFunction": "error",
|
49
|
+
"useLiteralKeys": "warn"
|
37
50
|
},
|
38
51
|
"correctness": {
|
39
52
|
"noUndeclaredVariables": "off",
|
40
53
|
"noUnusedVariables": "warn",
|
41
|
-
"
|
54
|
+
"noUnusedImports": "warn",
|
55
|
+
"useExhaustiveDependencies": "off",
|
56
|
+
"noUnreachable": "error",
|
57
|
+
"noConstantCondition": "error",
|
58
|
+
"noUnusedFunctionParameters": "off",
|
59
|
+
"noUnsafeOptionalChaining": "error"
|
42
60
|
},
|
43
61
|
"style": {
|
44
|
-
"noParameterAssign": "
|
62
|
+
"noParameterAssign": "error",
|
45
63
|
"noNonNullAssertion": "off",
|
46
64
|
"useBlockStatements": "off",
|
47
65
|
"useNamingConvention": "off",
|
48
|
-
"useTemplate": "
|
66
|
+
"useTemplate": "error",
|
49
67
|
"useFilenamingConvention": "off",
|
50
|
-
"useNodejsImportProtocol": "off"
|
68
|
+
"useNodejsImportProtocol": "off",
|
69
|
+
"useShorthandAssign": "warn",
|
70
|
+
"noNegationElse": "warn",
|
71
|
+
"useConsistentArrayType": "off",
|
72
|
+
"useExportType": "off",
|
73
|
+
"useImportType": "off",
|
74
|
+
"noUnusedTemplateLiteral": "warn",
|
75
|
+
"useSingleVarDeclarator": "off",
|
76
|
+
"noUselessElse": "error",
|
77
|
+
"useCollapsedElseIf": "error",
|
78
|
+
"useDefaultParameterLast": "error",
|
79
|
+
"useConst": "error",
|
80
|
+
"useExponentiationOperator": "error"
|
51
81
|
},
|
52
82
|
"suspicious": {
|
53
|
-
"noExplicitAny": "
|
54
|
-
"noArrayIndexKey": "
|
55
|
-
"noConsole": "
|
56
|
-
"noDoubleEquals": "off"
|
83
|
+
"noExplicitAny": "error",
|
84
|
+
"noArrayIndexKey": "error",
|
85
|
+
"noConsole": "warn",
|
86
|
+
"noDoubleEquals": "off",
|
87
|
+
"noEmptyBlockStatements": "error",
|
88
|
+
"noConfusingVoidType": "off",
|
89
|
+
"noConstEnum": "off",
|
90
|
+
"noShadowRestrictedNames": "error"
|
91
|
+
},
|
92
|
+
"nursery": {
|
93
|
+
"useSortedClasses": "off"
|
57
94
|
}
|
58
95
|
}
|
59
96
|
},
|
60
97
|
"files": {
|
61
|
-
"includes": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"
|
98
|
+
"includes": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
|
62
99
|
"experimentalScannerIgnores": [
|
63
|
-
"**/dist
|
64
|
-
"**/node_modules
|
100
|
+
"**/dist",
|
101
|
+
"**/node_modules",
|
65
102
|
"**/*.d.ts",
|
66
|
-
"**/mock
|
103
|
+
"**/mock",
|
67
104
|
"**/.eslintrc.cjs",
|
68
|
-
"**/build
|
69
|
-
"**/coverage
|
105
|
+
"**/build",
|
106
|
+
"**/coverage"
|
70
107
|
]
|
71
|
-
}
|
108
|
+
},
|
109
|
+
"overrides": [
|
110
|
+
{
|
111
|
+
"includes": ["scripts/**", "cli.js", "index.js"],
|
112
|
+
"linter": {
|
113
|
+
"rules": {
|
114
|
+
"suspicious": {
|
115
|
+
"noConsole": "off"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
]
|
72
121
|
}
|