@agile-team/wl-skills-kit 2.9.4 → 2.10.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.
@@ -0,0 +1,123 @@
1
+ /**
2
+ * ESLint Flat Config 模板 — wl-skills-kit 生成
3
+ *
4
+ * init/update 时复制到业务项目根目录作为 eslint.config.cjs
5
+ * 适用于 Vue 3 + TypeScript 项目,与 wl-skills validate 的规则互补:
6
+ * - validate 负责"架构级"约束(页面结构、组件使用、AST 语义)
7
+ * - ESLint 负责"代码级"约束(语法质量、安全、未使用变量、属性顺序)
8
+ *
9
+ * 对齐 wl-skills-kit 14 条 standards:
10
+ * 04 编码基础: eslint:recommended → no-var / prefer-const / no-redeclare / curly / no-restricted-syntax
11
+ * 05 日志: no-console (warn)
12
+ * 06 安全: vue/no-v-html (warn), no-eval, no-new-func
13
+ * 09 TS 质量: @typescript-eslint/recommended
14
+ * 13 组件: vue/attributes-order, vue/no-unused-components
15
+ *
16
+ * 依赖(业务项目需安装):
17
+ * pnpm add -D eslint eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin vue-eslint-parser
18
+ */
19
+
20
+ const pluginVue = require("eslint-plugin-vue");
21
+ const vueParser = require("vue-eslint-parser");
22
+ const tsParser = require("@typescript-eslint/parser");
23
+ const tsPlugin = require("@typescript-eslint/eslint-plugin");
24
+
25
+ module.exports = [
26
+ {
27
+ ignores: [
28
+ "**/dist/**",
29
+ "**/node_modules/**",
30
+ "**/coverage/**",
31
+ "**/*.d.ts",
32
+ "src/auto-imports.d.ts",
33
+ "src/components.d.ts",
34
+ "src/env.d.ts",
35
+ "vite/**/*",
36
+ "scripts/**/*",
37
+ "mock/**/*",
38
+ "demo/**/*",
39
+ ".github/**/*",
40
+ ],
41
+ },
42
+
43
+ // ── JS 基础规则(standard 04: no-var / prefer-const / no-redeclare / curly 等)
44
+ // eslint:recommended 提供 no-var, prefer-const, no-redeclare, no-cond-assign, no-debugger, no-dupe-keys 等
45
+ {
46
+ rules: {
47
+ "no-var": "error",
48
+ "prefer-const": "error",
49
+ "no-redeclare": "error",
50
+ "no-cond-assign": "error",
51
+ "no-debugger": "error",
52
+ "no-dupe-keys": "error",
53
+ "no-duplicate-case": "error",
54
+ "no-empty": "warn",
55
+ "no-irregular-whitespace": "warn",
56
+ "no-sparse-arrays": "warn",
57
+ "no-unreachable": "error",
58
+ "use-isnan": "error",
59
+ "valid-typeof": "error",
60
+ "no-fallthrough": "error",
61
+ "curly": ["warn", "multi-line"],
62
+ },
63
+ },
64
+
65
+ // ── 安全规则(standard 06: eval / new Function / v-html)
66
+ {
67
+ rules: {
68
+ "no-eval": "error",
69
+ "no-implied-eval": "error",
70
+ "no-new-func": "error",
71
+ "no-script-url": "error",
72
+ },
73
+ },
74
+
75
+ // Vue 3 essential rules
76
+ ...pluginVue.configs["flat/essential"],
77
+
78
+ // TypeScript: parser + recommended rules
79
+ {
80
+ files: ["**/*.{ts,tsx,vue}"],
81
+ languageOptions: {
82
+ parser: vueParser,
83
+ parserOptions: {
84
+ parser: tsParser,
85
+ ecmaVersion: 2020,
86
+ sourceType: "module",
87
+ extraFileExtensions: [".vue"],
88
+ },
89
+ },
90
+ plugins: {
91
+ "@typescript-eslint": tsPlugin,
92
+ },
93
+ rules: {
94
+ ...tsPlugin.configs.recommended.rules,
95
+ },
96
+ },
97
+
98
+ // ── 项目专属规则(与 wl-skills-kit 14 条 standards 精确对齐)
99
+ {
100
+ rules: {
101
+ // 09 TS: strict: false 项目允许 any,但标记未使用变量
102
+ "no-undef": "off",
103
+ "no-unused-vars": "off",
104
+ "@typescript-eslint/no-explicit-any": "off",
105
+ "@typescript-eslint/no-unused-vars": [
106
+ "warn",
107
+ { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
108
+ ],
109
+
110
+ // 05 日志: console.log 残留(允许 warn/error)
111
+ "no-console": ["warn", { allow: ["warn", "error"] }],
112
+
113
+ // 06 安全: v-html 必须有注释说明(warn 级,让开发者留意)
114
+ "vue/no-v-html": "warn",
115
+
116
+ // Vue 组件质量
117
+ "vue/multi-word-component-names": ["error", { ignores: ["index"] }],
118
+ "vue/require-default-prop": "off",
119
+ "vue/attributes-order": "warn",
120
+ "vue/no-unused-components": "warn",
121
+ },
122
+ },
123
+ ];