@empjs/biome-config 0.7.2 → 2.0.0-beta.1
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/README.md +11 -14
- package/biome.jsonc +117 -86
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,27 +6,24 @@ EMP 官方默认格式化配置、`v6.0` 已支持 CSS
|
|
|
6
6
|
## vscode 设置
|
|
7
7
|
### .vscode/settings.json
|
|
8
8
|
```json
|
|
9
|
-
{
|
|
10
|
-
"eslint.enable": false,
|
|
11
|
-
"prettier.enable": false,
|
|
12
|
-
"css.lint.unknownAtRules": "ignore",
|
|
13
9
|
"editor.codeActionsOnSave": {
|
|
14
|
-
"
|
|
15
|
-
"source.organizeImports.biome": "explicit"
|
|
16
|
-
},
|
|
17
|
-
"typescript.tsdk": "node_modules/typescript/lib",
|
|
18
|
-
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
19
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
20
|
-
"[scss]": {
|
|
21
|
-
"editor.defaultFormatter": "vscode.css-language-features"
|
|
10
|
+
"source.fixAll.biome": "explicit"
|
|
22
11
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
12
|
```
|
|
26
13
|
|
|
27
14
|
## 默认配置
|
|
28
15
|
+ [biome.jsonc](./biome.jsonc)
|
|
29
16
|
|
|
17
|
+
## monorepo 配置
|
|
18
|
+
> 根目录 biome.jsonc
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"root": true,
|
|
22
|
+
"extends": ["@empjs/biome-config"]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
30
27
|
|
|
31
28
|
[npm-version-src]: https://img.shields.io/npm/v/@empjs/biome-config?style=flat&colorA=18181B&colorB=F0DB4F
|
|
32
29
|
[npm-version-href]: https://npmjs.com/package/@empjs/biome-config
|
package/biome.jsonc
CHANGED
|
@@ -1,137 +1,168 @@
|
|
|
1
1
|
{
|
|
2
|
+
// 标记为嵌套配置,不是根配置
|
|
3
|
+
"root": false,
|
|
4
|
+
// 引用 Biome 配置的 JSON Schema,提供代码提示和验证
|
|
2
5
|
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
|
6
|
+
// 文件处理配置
|
|
3
7
|
"files": {
|
|
4
|
-
|
|
5
|
-
"dist/**",
|
|
6
|
-
"output/**",
|
|
7
|
-
"node_modules/**"
|
|
8
|
-
],
|
|
8
|
+
// 忽略未知文件类型的错误
|
|
9
9
|
"ignoreUnknown": true,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"emp-config.
|
|
23
|
-
"emp.config.
|
|
24
|
-
".
|
|
10
|
+
// 包含需要处理的文件类型和路径
|
|
11
|
+
"includes": [
|
|
12
|
+
"**/*.js", // JavaScript 文件
|
|
13
|
+
"**/*.ts", // TypeScript 文件
|
|
14
|
+
"**/*.jsx", // React JSX 文件
|
|
15
|
+
"**/*.tsx", // TypeScript JSX 文件
|
|
16
|
+
"**/*.mjs", // ES 模块 JavaScript 文件
|
|
17
|
+
"**/*.tjs", // TypeScript JavaScript 文件
|
|
18
|
+
"**/*.json", // JSON 文件
|
|
19
|
+
"**/*.jsonc", // 带注释的 JSON 文件
|
|
20
|
+
"**/*.css", // CSS 文件
|
|
21
|
+
"**/*.html", // HTML 文件
|
|
22
|
+
"**/emp-config.js", // EMP 配置文件
|
|
23
|
+
"**/emp.config.js", // EMP 配置文件
|
|
24
|
+
"**/emp-config.ts", // EMP TypeScript 配置文件
|
|
25
|
+
"**/emp.config.ts", // EMP TypeScript 配置文件
|
|
26
|
+
"**/.vscode/**", // VS Code 配置文件
|
|
27
|
+
"**/*.svelte", // Svelte 组件文件
|
|
28
|
+
"**/*.astro", // Astro 组件文件
|
|
29
|
+
"**/*.vue", // Vue 组件文件
|
|
30
|
+
// 排除的文件和目录
|
|
31
|
+
"!**/dist/**", // 构建输出目录
|
|
32
|
+
"!**/node_modules/**" // 依赖模块目录
|
|
25
33
|
]
|
|
26
34
|
},
|
|
35
|
+
// 格式化器全局配置
|
|
27
36
|
"formatter": {
|
|
37
|
+
// 每行最大字符数
|
|
28
38
|
"lineWidth": 120
|
|
29
39
|
},
|
|
40
|
+
// CSS 相关配置
|
|
30
41
|
"css": {
|
|
42
|
+
// CSS 格式化器
|
|
31
43
|
"formatter": {
|
|
32
|
-
"enabled": true
|
|
44
|
+
"enabled": true // 启用 CSS 格式化
|
|
33
45
|
},
|
|
46
|
+
// CSS 解析器
|
|
34
47
|
"parser": {
|
|
35
|
-
"cssModules": true
|
|
48
|
+
"cssModules": true // 启用 CSS Modules 支持
|
|
36
49
|
},
|
|
50
|
+
// CSS 检查器
|
|
37
51
|
"linter": {
|
|
38
|
-
"enabled": true
|
|
52
|
+
"enabled": true // 启用 CSS 检查
|
|
39
53
|
}
|
|
40
54
|
},
|
|
55
|
+
// JavaScript/TypeScript 相关配置
|
|
41
56
|
"javascript": {
|
|
57
|
+
// JavaScript 格式化器配置
|
|
42
58
|
"formatter": {
|
|
43
|
-
"arrowParentheses": "asNeeded",
|
|
44
|
-
"bracketSpacing": false,
|
|
45
|
-
"indentStyle": "space",
|
|
46
|
-
"indentWidth": 2,
|
|
47
|
-
"jsxQuoteStyle": "double",
|
|
48
|
-
"quoteStyle": "single",
|
|
49
|
-
"semicolons": "asNeeded"
|
|
59
|
+
"arrowParentheses": "asNeeded", // 箭头函数参数括号:仅在需要时添加
|
|
60
|
+
"bracketSpacing": false, // 对象字面量括号内不添加空格 {foo} 而不是 { foo }
|
|
61
|
+
"indentStyle": "space", // 使用空格缩进
|
|
62
|
+
"indentWidth": 2, // 缩进宽度为 2 个空格
|
|
63
|
+
"jsxQuoteStyle": "double", // JSX 属性使用双引号
|
|
64
|
+
"quoteStyle": "single", // 字符串使用单引号
|
|
65
|
+
"semicolons": "asNeeded" // 仅在需要时添加分号
|
|
50
66
|
},
|
|
67
|
+
// JavaScript 解析器配置
|
|
51
68
|
"parser": {
|
|
69
|
+
// 启用不安全的参数装饰器(实验性功能)
|
|
52
70
|
"unsafeParameterDecoratorsEnabled": true
|
|
53
71
|
}
|
|
54
72
|
},
|
|
73
|
+
// JSON 文件配置
|
|
55
74
|
"json": {
|
|
75
|
+
// JSON 格式化器
|
|
56
76
|
"formatter": {
|
|
57
|
-
"enabled": true,
|
|
58
|
-
"indentStyle": "space",
|
|
59
|
-
"indentWidth": 2
|
|
77
|
+
"enabled": true, // 启用 JSON 格式化
|
|
78
|
+
"indentStyle": "space", // 使用空格缩进
|
|
79
|
+
"indentWidth": 2, // 缩进宽度为 2 个空格
|
|
80
|
+
"expand": "auto" // 自动决定是否展开对象/数组
|
|
60
81
|
},
|
|
82
|
+
// JSON 解析器
|
|
61
83
|
"parser": {
|
|
62
|
-
"allowComments": true,
|
|
63
|
-
"allowTrailingCommas": true
|
|
84
|
+
"allowComments": true, // 允许 JSON 中的注释
|
|
85
|
+
"allowTrailingCommas": true // 允许尾随逗号
|
|
64
86
|
}
|
|
65
87
|
},
|
|
88
|
+
// 代码检查器配置
|
|
66
89
|
"linter": {
|
|
67
|
-
"enabled": true,
|
|
90
|
+
"enabled": true, // 启用代码检查
|
|
91
|
+
// 具体规则配置
|
|
68
92
|
"rules": {
|
|
93
|
+
// 无障碍性规则
|
|
69
94
|
"a11y": {
|
|
70
|
-
"noSvgWithoutTitle": "off",
|
|
71
|
-
"useAltText": "off",
|
|
72
|
-
"useButtonType": "off",
|
|
73
|
-
"useValidAnchor": "off",
|
|
74
|
-
"useKeyWithClickEvents": "off"
|
|
95
|
+
"noSvgWithoutTitle": "off", // 关闭:SVG 必须有 title
|
|
96
|
+
"useAltText": "off", // 关闭:图片必须有 alt 文本
|
|
97
|
+
"useButtonType": "off", // 关闭:button 必须有 type 属性
|
|
98
|
+
"useValidAnchor": "off", // 关闭:a 标签必须有有效的 href
|
|
99
|
+
"useKeyWithClickEvents": "off" // 关闭:点击事件必须配合键盘事件
|
|
75
100
|
},
|
|
101
|
+
// 复杂度规则
|
|
76
102
|
"complexity": {
|
|
77
|
-
"noForEach": "off",
|
|
78
|
-
"noUselessConstructor": "off",
|
|
79
|
-
"useArrowFunction": "off",
|
|
80
|
-
"useOptionalChain": "off",
|
|
81
|
-
"useLiteralKeys": "off",
|
|
82
|
-
"noUselessTernary": "off"
|
|
103
|
+
"noForEach": "off", // 关闭:禁止使用 forEach
|
|
104
|
+
"noUselessConstructor": "off", // 关闭:禁止无用的构造函数
|
|
105
|
+
"useArrowFunction": "off", // 关闭:强制使用箭头函数
|
|
106
|
+
"useOptionalChain": "off", // 关闭:强制使用可选链
|
|
107
|
+
"useLiteralKeys": "off", // 关闭:强制使用字面量键
|
|
108
|
+
"noUselessTernary": "off" // 关闭:禁止无用的三元表达式
|
|
83
109
|
},
|
|
110
|
+
// 正确性规则
|
|
84
111
|
"correctness": {
|
|
85
|
-
"noUnreachable": "off",
|
|
86
|
-
"useExhaustiveDependencies": "off"
|
|
112
|
+
"noUnreachable": "off", // 关闭:禁止不可达代码
|
|
113
|
+
"useExhaustiveDependencies": "off", // 关闭:React Hook 依赖项检查
|
|
114
|
+
"useHookAtTopLevel": "off" // 关闭:Hook 必须在顶层调用
|
|
87
115
|
},
|
|
116
|
+
// 性能规则
|
|
88
117
|
"performance": {
|
|
89
|
-
"noDelete": "off"
|
|
118
|
+
"noDelete": "off" // 关闭:禁止使用 delete 操作符
|
|
90
119
|
},
|
|
120
|
+
// 启用推荐规则集
|
|
91
121
|
"recommended": true,
|
|
122
|
+
// 代码风格规则
|
|
92
123
|
"style": {
|
|
93
|
-
"noUnusedTemplateLiteral": "off",
|
|
94
|
-
"useSelfClosingElements": "off",
|
|
95
|
-
"noNonNullAssertion": "off",
|
|
96
|
-
"noParameterAssign": "off",
|
|
97
|
-
"noUselessElse": "off",
|
|
98
|
-
"useNodejsImportProtocol": "off",
|
|
99
|
-
"useSingleVarDeclarator": "off",
|
|
100
|
-
"useTemplate": "off"
|
|
124
|
+
"noUnusedTemplateLiteral": "off", // 关闭:禁止无用的模板字面量
|
|
125
|
+
"useSelfClosingElements": "off", // 关闭:强制使用自闭合元素
|
|
126
|
+
"noNonNullAssertion": "off", // 关闭:禁止非空断言
|
|
127
|
+
"noParameterAssign": "off", // 关闭:禁止给参数重新赋值
|
|
128
|
+
"noUselessElse": "off", // 关闭:禁止无用的 else
|
|
129
|
+
"useNodejsImportProtocol": "off", // 关闭:强制使用 Node.js 导入协议
|
|
130
|
+
"useSingleVarDeclarator": "off", // 关闭:强制单一变量声明
|
|
131
|
+
"useTemplate": "off", // 关闭:强制使用模板字符串
|
|
132
|
+
"useAsConstAssertion": "error", // 错误:强制使用 as const 断言
|
|
133
|
+
"useDefaultParameterLast": "error", // 错误:默认参数必须在最后
|
|
134
|
+
"useEnumInitializers": "error", // 错误:枚举必须初始化
|
|
135
|
+
"useNumberNamespace": "error", // 错误:使用 Number 命名空间
|
|
136
|
+
"noInferrableTypes": "error", // 错误:禁止可推断的类型注解
|
|
137
|
+
"useConst": "off", // 关闭:强制使用 const
|
|
138
|
+
"useImportType": "off" // 关闭:强制使用 import type
|
|
101
139
|
},
|
|
140
|
+
// 可疑代码规则
|
|
102
141
|
"suspicious": {
|
|
103
|
-
"noAssignInExpressions": "off",
|
|
104
|
-
"noArrayIndexKey": "off",
|
|
105
|
-
"noDoubleEquals": "off",
|
|
106
|
-
"noExplicitAny": "off",
|
|
107
|
-
"noGlobalIsNan": "off",
|
|
108
|
-
"noImplicitAnyLet": "off"
|
|
142
|
+
"noAssignInExpressions": "off", // 关闭:禁止在表达式中赋值
|
|
143
|
+
"noArrayIndexKey": "off", // 关闭:禁止使用数组索引作为 key
|
|
144
|
+
"noDoubleEquals": "off", // 关闭:禁止使用 ==
|
|
145
|
+
"noExplicitAny": "off", // 关闭:禁止显式 any 类型
|
|
146
|
+
"noGlobalIsNan": "off", // 关闭:禁止使用全局 isNaN
|
|
147
|
+
"noImplicitAnyLet": "off" // 关闭:禁止隐式 any 的 let 声明
|
|
109
148
|
}
|
|
110
149
|
}
|
|
111
150
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"*.svelte",
|
|
119
|
-
"*.astro",
|
|
120
|
-
"*.vue"
|
|
121
|
-
],
|
|
122
|
-
"linter": {
|
|
123
|
-
"rules": {
|
|
124
|
-
"style": {
|
|
125
|
-
"useConst": "off",
|
|
126
|
-
"useImportType": "off"
|
|
127
|
-
}
|
|
128
|
-
}
|
|
151
|
+
// 辅助功能配置
|
|
152
|
+
"assist": {
|
|
153
|
+
"actions": {
|
|
154
|
+
"source": {
|
|
155
|
+
// 启用导入语句自动组织
|
|
156
|
+
"organizeImports": "on"
|
|
129
157
|
}
|
|
130
158
|
}
|
|
131
|
-
|
|
159
|
+
},
|
|
160
|
+
// 覆盖规则(针对特定文件的特殊配置)
|
|
161
|
+
"overrides": [],
|
|
162
|
+
// 版本控制系统配置
|
|
132
163
|
"vcs": {
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"useIgnoreFile": true
|
|
164
|
+
"enabled": true, // 启用版本控制集成
|
|
165
|
+
"clientKind": "git", // 使用 Git 作为版本控制系统
|
|
166
|
+
"useIgnoreFile": true // 使用 .gitignore 文件
|
|
136
167
|
}
|
|
137
|
-
}
|
|
168
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/biome-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"main": "biome.jsonc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@biomejs/biome": "^
|
|
29
|
+
"@biomejs/biome": "^2.0.5"
|
|
30
30
|
}
|
|
31
31
|
}
|