@4399ywkf/core 5.0.26 → 5.0.27
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/biome.json +88 -0
- package/dist/index.d.ts +15 -27
- package/dist/index.js +24 -118
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/biome.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"defaultBranch": "main",
|
|
6
|
+
"clientKind": "git",
|
|
7
|
+
"useIgnoreFile": true
|
|
8
|
+
},
|
|
9
|
+
"formatter": {
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"indentStyle": "space"
|
|
12
|
+
},
|
|
13
|
+
"css": {
|
|
14
|
+
"formatter": {
|
|
15
|
+
"quoteStyle": "single"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"javascript": {
|
|
19
|
+
"formatter": {
|
|
20
|
+
"quoteStyle": "single",
|
|
21
|
+
"arrowParentheses": "asNeeded",
|
|
22
|
+
"jsxQuoteStyle": "double",
|
|
23
|
+
"lineWidth": 100
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"linter": {
|
|
27
|
+
"enabled": true,
|
|
28
|
+
"rules": {
|
|
29
|
+
"recommended": true,
|
|
30
|
+
"style": {
|
|
31
|
+
"useNodejsImportProtocol": "off",
|
|
32
|
+
"noNonNullAssertion": "off",
|
|
33
|
+
"noUnusedTemplateLiteral": "off",
|
|
34
|
+
"noUselessElse": "off",
|
|
35
|
+
"useNumberNamespace": "off",
|
|
36
|
+
"useFragmentSyntax": "off"
|
|
37
|
+
},
|
|
38
|
+
"suspicious": {
|
|
39
|
+
"noDuplicateFontNames": "off",
|
|
40
|
+
"noExplicitAny": "off",
|
|
41
|
+
"noConfusingVoidType": "off",
|
|
42
|
+
"noImplicitAnyLet": "off",
|
|
43
|
+
"noAssignInExpressions": "off",
|
|
44
|
+
"noPrototypeBuiltins": "off"
|
|
45
|
+
},
|
|
46
|
+
"complexity": {
|
|
47
|
+
"noBannedTypes": "off",
|
|
48
|
+
"noForEach": "off",
|
|
49
|
+
"noUselessThisAlias": "off",
|
|
50
|
+
"noStaticOnlyClass": "off",
|
|
51
|
+
"useArrowFunction": "off"
|
|
52
|
+
},
|
|
53
|
+
"correctness": {
|
|
54
|
+
"useExhaustiveDependencies": "off"
|
|
55
|
+
},
|
|
56
|
+
"a11y": {
|
|
57
|
+
"useAltText": "off",
|
|
58
|
+
"useKeyWithClickEvents": "off",
|
|
59
|
+
"useButtonType": "off",
|
|
60
|
+
"noSvgWithoutTitle": "off"
|
|
61
|
+
},
|
|
62
|
+
"performance": {
|
|
63
|
+
"noDelete": "off"
|
|
64
|
+
},
|
|
65
|
+
"security": {
|
|
66
|
+
"noDangerouslySetInnerHtml": "off"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"assist": {
|
|
71
|
+
"actions": {
|
|
72
|
+
"source": {
|
|
73
|
+
"organizeImports": "on"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"files": {
|
|
78
|
+
"ignoreUnknown": true,
|
|
79
|
+
"includes": [
|
|
80
|
+
"**",
|
|
81
|
+
"!**/.vscode/**/*",
|
|
82
|
+
"!**/node_modules/**/*",
|
|
83
|
+
"!**/dist/**/*",
|
|
84
|
+
"!**/.ywkf/**/*",
|
|
85
|
+
"!**/public/**/*.html"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -179,46 +179,31 @@ interface BiomePluginOptions {
|
|
|
179
179
|
*/
|
|
180
180
|
scaffold?: boolean;
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @default "space"
|
|
184
|
-
*/
|
|
185
|
-
indentStyle?: "space" | "tab";
|
|
186
|
-
/**
|
|
187
|
-
* JS/TS formatter 引号风格
|
|
188
|
-
* @default "double"
|
|
189
|
-
*/
|
|
190
|
-
quoteStyle?: "double" | "single";
|
|
191
|
-
/**
|
|
192
|
-
* 箭头函数参数括号
|
|
193
|
-
* @default "always"
|
|
194
|
-
*/
|
|
195
|
-
arrowParentheses?: "always" | "asNeeded";
|
|
196
|
-
/**
|
|
197
|
-
* JS/TS 行宽
|
|
198
|
-
* @default 100
|
|
182
|
+
* 额外忽略的文件 glob
|
|
199
183
|
*/
|
|
200
|
-
|
|
184
|
+
ignore?: string[];
|
|
201
185
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @default true
|
|
186
|
+
* 自定义 linter 规则覆盖(浅合并到继承的规则上)
|
|
204
187
|
*/
|
|
205
|
-
|
|
188
|
+
rules?: Record<string, Record<string, string>>;
|
|
206
189
|
/**
|
|
207
|
-
*
|
|
190
|
+
* 自定义 formatter 覆盖
|
|
208
191
|
*/
|
|
209
|
-
|
|
192
|
+
formatter?: Record<string, unknown>;
|
|
210
193
|
/**
|
|
211
|
-
* 自定义
|
|
194
|
+
* 自定义 javascript formatter 覆盖
|
|
212
195
|
*/
|
|
213
|
-
|
|
196
|
+
javascript?: Record<string, unknown>;
|
|
214
197
|
}
|
|
215
198
|
/**
|
|
216
199
|
* Biome 代码规范插件
|
|
217
200
|
*
|
|
218
|
-
* 在 setup 阶段自动生成 biome.json
|
|
201
|
+
* 在 setup 阶段自动生成 biome.json,通过 extends 继承
|
|
202
|
+
* @4399ywkf/core 内置的共享配置,为项目提供统一的
|
|
219
203
|
* Lint / Format / Import Sorting 规范。
|
|
220
204
|
*
|
|
221
|
-
*
|
|
205
|
+
* 用户项目的 biome.json 只需 extends 框架配置,
|
|
206
|
+
* 再按需覆盖少量规则即可。
|
|
222
207
|
*
|
|
223
208
|
* @example
|
|
224
209
|
* ```ts
|
|
@@ -234,6 +219,9 @@ interface BiomePluginOptions {
|
|
|
234
219
|
declare const biomePlugin: (options?: BiomePluginOptions | undefined) => YwkfPlugin;
|
|
235
220
|
/**
|
|
236
221
|
* 生成默认 biome.json 配置内容(纯数据,供 CLI 脚手架使用)
|
|
222
|
+
*
|
|
223
|
+
* 生成的配置通过 extends 继承 @4399ywkf/core/biome 共享配置,
|
|
224
|
+
* 用户只需在此基础上按需覆盖。
|
|
237
225
|
*/
|
|
238
226
|
declare function getDefaultBiomeConfig(): Record<string, unknown>;
|
|
239
227
|
|
package/dist/index.js
CHANGED
|
@@ -2545,7 +2545,6 @@ var analyticsPlugin = createPlugin((options = {}) => ({
|
|
|
2545
2545
|
// src/plugin/builtin/biome.ts
|
|
2546
2546
|
import { existsSync as existsSync7, writeFileSync as writeFileSync3 } from "fs";
|
|
2547
2547
|
import { join as join7 } from "path";
|
|
2548
|
-
var DEFAULT_IGNORE = [".vscode/**/*", "node_modules/**/*", "dist/**/*", ".ywkf/**/*"];
|
|
2549
2548
|
var biomePlugin = createPlugin((options = {}) => ({
|
|
2550
2549
|
name: "@4399ywkf/plugin-biome",
|
|
2551
2550
|
version: "1.0.0",
|
|
@@ -2553,30 +2552,19 @@ var biomePlugin = createPlugin((options = {}) => ({
|
|
|
2553
2552
|
setup(context) {
|
|
2554
2553
|
const {
|
|
2555
2554
|
scaffold = true,
|
|
2556
|
-
indentStyle = "space",
|
|
2557
|
-
quoteStyle = "double",
|
|
2558
|
-
arrowParentheses = "always",
|
|
2559
|
-
lineWidth = 100,
|
|
2560
|
-
organizeImports = true,
|
|
2561
2555
|
ignore = [],
|
|
2562
|
-
rules: customRules
|
|
2556
|
+
rules: customRules,
|
|
2557
|
+
formatter: customFormatter,
|
|
2558
|
+
javascript: customJavascript
|
|
2563
2559
|
} = options;
|
|
2564
2560
|
const { cwd, logger } = context;
|
|
2565
2561
|
if (scaffold) {
|
|
2566
2562
|
const biomeConfigPath = join7(cwd, "biome.json");
|
|
2567
2563
|
if (!existsSync7(biomeConfigPath)) {
|
|
2568
|
-
const config = buildBiomeConfig({
|
|
2569
|
-
indentStyle,
|
|
2570
|
-
quoteStyle,
|
|
2571
|
-
arrowParentheses,
|
|
2572
|
-
lineWidth,
|
|
2573
|
-
organizeImports,
|
|
2574
|
-
ignore: [...DEFAULT_IGNORE, ...ignore],
|
|
2575
|
-
customRules
|
|
2576
|
-
});
|
|
2564
|
+
const config = buildBiomeConfig({ ignore, customRules, customFormatter, customJavascript });
|
|
2577
2565
|
writeFileSync3(biomeConfigPath, `${JSON.stringify(config, null, 2)}
|
|
2578
2566
|
`, "utf-8");
|
|
2579
|
-
logger.info("\u5DF2\u751F\u6210 biome.json");
|
|
2567
|
+
logger.info("\u5DF2\u751F\u6210 biome.json\uFF08\u7EE7\u627F @4399ywkf/core/biome\uFF09");
|
|
2580
2568
|
}
|
|
2581
2569
|
}
|
|
2582
2570
|
const hooks = {
|
|
@@ -2589,111 +2577,29 @@ var biomePlugin = createPlugin((options = {}) => ({
|
|
|
2589
2577
|
}
|
|
2590
2578
|
}));
|
|
2591
2579
|
function buildBiomeConfig(params) {
|
|
2592
|
-
const {
|
|
2593
|
-
|
|
2594
|
-
quoteStyle,
|
|
2595
|
-
arrowParentheses,
|
|
2596
|
-
lineWidth,
|
|
2597
|
-
organizeImports: enableOrganizeImports,
|
|
2598
|
-
ignore,
|
|
2599
|
-
customRules
|
|
2600
|
-
} = params;
|
|
2601
|
-
const defaultRules = {
|
|
2602
|
-
recommended: { "": "true" },
|
|
2603
|
-
style: {
|
|
2604
|
-
useNodejsImportProtocol: "off",
|
|
2605
|
-
noNonNullAssertion: "off",
|
|
2606
|
-
noUnusedTemplateLiteral: "off",
|
|
2607
|
-
noUselessElse: "off",
|
|
2608
|
-
useNumberNamespace: "off"
|
|
2609
|
-
},
|
|
2610
|
-
suspicious: {
|
|
2611
|
-
noExplicitAny: "off",
|
|
2612
|
-
noConfusingVoidType: "off",
|
|
2613
|
-
noImplicitAnyLet: "off",
|
|
2614
|
-
noAssignInExpressions: "off",
|
|
2615
|
-
noPrototypeBuiltins: "off"
|
|
2616
|
-
},
|
|
2617
|
-
complexity: {
|
|
2618
|
-
noForEach: "off",
|
|
2619
|
-
noBannedTypes: "off",
|
|
2620
|
-
useArrowFunction: "off"
|
|
2621
|
-
},
|
|
2622
|
-
correctness: {
|
|
2623
|
-
useExhaustiveDependencies: "off"
|
|
2624
|
-
},
|
|
2625
|
-
a11y: {
|
|
2626
|
-
useAltText: "off",
|
|
2627
|
-
useKeyWithClickEvents: "off",
|
|
2628
|
-
useButtonType: "off",
|
|
2629
|
-
noSvgWithoutTitle: "off"
|
|
2630
|
-
},
|
|
2631
|
-
performance: {
|
|
2632
|
-
noDelete: "off"
|
|
2633
|
-
},
|
|
2634
|
-
security: {
|
|
2635
|
-
noDangerouslySetInnerHtml: "off"
|
|
2636
|
-
}
|
|
2637
|
-
};
|
|
2638
|
-
const mergedRules = { recommended: true };
|
|
2639
|
-
for (const [category, categoryRules] of Object.entries(defaultRules)) {
|
|
2640
|
-
if (category === "recommended") continue;
|
|
2641
|
-
const customCategoryRules = customRules[category] || {};
|
|
2642
|
-
mergedRules[category] = { ...categoryRules, ...customCategoryRules };
|
|
2643
|
-
}
|
|
2644
|
-
const includesPatterns = ["**", ...ignore.map((p) => `!${p}`)];
|
|
2645
|
-
return {
|
|
2580
|
+
const { ignore, customRules, customFormatter, customJavascript } = params;
|
|
2581
|
+
const config = {
|
|
2646
2582
|
$schema: "https://biomejs.dev/schemas/2.3.2/schema.json",
|
|
2647
|
-
|
|
2648
|
-
enabled: true,
|
|
2649
|
-
defaultBranch: "main",
|
|
2650
|
-
clientKind: "git",
|
|
2651
|
-
useIgnoreFile: true
|
|
2652
|
-
},
|
|
2653
|
-
formatter: {
|
|
2654
|
-
enabled: true,
|
|
2655
|
-
indentStyle
|
|
2656
|
-
},
|
|
2657
|
-
css: {
|
|
2658
|
-
formatter: {
|
|
2659
|
-
quoteStyle: "single"
|
|
2660
|
-
}
|
|
2661
|
-
},
|
|
2662
|
-
javascript: {
|
|
2663
|
-
formatter: {
|
|
2664
|
-
quoteStyle,
|
|
2665
|
-
arrowParentheses,
|
|
2666
|
-
jsxQuoteStyle: "double",
|
|
2667
|
-
lineWidth
|
|
2668
|
-
}
|
|
2669
|
-
},
|
|
2670
|
-
linter: {
|
|
2671
|
-
enabled: true,
|
|
2672
|
-
rules: mergedRules
|
|
2673
|
-
},
|
|
2674
|
-
assist: {
|
|
2675
|
-
actions: {
|
|
2676
|
-
source: {
|
|
2677
|
-
organizeImports: enableOrganizeImports ? "on" : "off"
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
},
|
|
2681
|
-
files: {
|
|
2682
|
-
ignoreUnknown: true,
|
|
2683
|
-
includes: includesPatterns
|
|
2684
|
-
}
|
|
2583
|
+
extends: ["@4399ywkf/core/biome"]
|
|
2685
2584
|
};
|
|
2585
|
+
if (customFormatter) {
|
|
2586
|
+
config.formatter = customFormatter;
|
|
2587
|
+
}
|
|
2588
|
+
if (customJavascript) {
|
|
2589
|
+
config.javascript = customJavascript;
|
|
2590
|
+
}
|
|
2591
|
+
if (customRules && Object.keys(customRules).length > 0) {
|
|
2592
|
+
config.linter = { rules: customRules };
|
|
2593
|
+
}
|
|
2594
|
+
if (ignore.length > 0) {
|
|
2595
|
+
config.files = {
|
|
2596
|
+
includes: ["**", ...ignore.map((p) => `!${p}`)]
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
return config;
|
|
2686
2600
|
}
|
|
2687
2601
|
function getDefaultBiomeConfig() {
|
|
2688
|
-
return buildBiomeConfig({
|
|
2689
|
-
indentStyle: "space",
|
|
2690
|
-
quoteStyle: "double",
|
|
2691
|
-
arrowParentheses: "always",
|
|
2692
|
-
lineWidth: 100,
|
|
2693
|
-
organizeImports: true,
|
|
2694
|
-
ignore: DEFAULT_IGNORE,
|
|
2695
|
-
customRules: {}
|
|
2696
|
-
});
|
|
2602
|
+
return buildBiomeConfig({ ignore: [] });
|
|
2697
2603
|
}
|
|
2698
2604
|
|
|
2699
2605
|
// src/plugin/builtin/garfish.ts
|