@agile-team/wl-skills-kit 2.10.0 → 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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  inclusion: always
3
- description: 项目编码规范(13 条标准 + 11 个 Skill 自动调度)
3
+ description: 项目编码规范(14 条标准 + 11 个 Skill 自动调度)
4
4
  ---
5
5
 
6
6
  <!-- Kiro Steering 规则。由 @agile-team/wl-skills-kit 自动生成。-->
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "项目编码规范(13 条标准 + 11 个 Skill 自动调度,由 wl-skills-kit 自动生成)"
2
+ description: "项目编码规范(14 条标准 + 11 个 Skill 自动调度,由 wl-skills-kit 自动生成)"
3
3
  globs: ["**/*.vue", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.scss"]
4
4
  alwaysApply: true
5
5
  ---
@@ -2,6 +2,7 @@
2
2
 
3
3
  > 本文件定义 Skill 间的输入/输出契约和推荐后续动作,是 Agent Pipeline 的调度依据。
4
4
  > Pipeline 只做**建议式串联**:AI 完成一步后提示下一步,是否继续由用户确认。
5
+ > **例外**:code-fix → validate 复扫是**强制约定**,不需要用户确认即自动执行。
5
6
 
6
7
  ---
7
8
 
@@ -58,7 +59,7 @@ spec-doc-parse // 规范线:wl-skills-design 标准说
58
59
  | `api-contract` | `prototype-scan` 输出、`spec-doc-parse` 输出、`docs/business/0X-xx/requirement.md` + `field.md` 或用户口述接口信息 | `src/views/**/api.md` | `page-codegen` |
59
60
  | `page-codegen` | `api.md` / page-spec / 用户口述需求 | `src/views/**/{index.vue,data.ts,index.scss,api.md}` + `.github/reports/SYS_MENU_INFO.md` | `convention-audit`;如有菜单则 `menu-sync` |
60
61
  | `convention-audit` | 任意源码目录或文件;`--mode spec-align` 时额外入 `spec-doc-parse` 的 page-spec / 说明书 | `.github/reports/AUDIT_*.md`;`--mode spec-align` 输出 `SPEC_GAP_*.md` | 有可自动修复项时 `code-fix`;有菜单/字典/权限差异时对应 sync Skill |
61
- | `code-fix` | `convention-audit` 报告 | 源码 diff / 修复摘要 | `convention-audit` 复扫 |
62
+ | `code-fix` | `convention-audit` 报告 | 源码 diff / 修复摘要 | **强制** `wl-skills validate` 复扫(自动执行,不等确认);可选 `convention-audit --quick` |
62
63
  | `menu-sync` | `.github/reports/SYS_MENU_INFO.md` | 后端菜单数据 + 同步摘要 | `permission-sync`(如需角色授权/动作) |
63
64
  | `dict-sync` | `.github/reports/SYS_DICT_INFO.md` | 后端字典数据 + 同步摘要 | `convention-audit` 复扫(如页面依赖字典) |
64
65
  | `permission-sync` | `.github/reports/SYS_PERMISSION_INFO.md` 或用户口述权限需求 | 后端角色/授权/动作数据 + 同步摘要 | `convention-audit` 复扫权限码使用 |
@@ -75,13 +76,24 @@ AI 每完成一个 Skill,必须输出:
75
76
  - 产物:{output_file}
76
77
  - 关键数据:{counts / changed files / backend ids}
77
78
  - 风险:{manual review items}
79
+ - 复扫结果:{code-fix 专属,其他 Skill 可省略}
78
80
 
79
81
  ## 建议下一步
80
82
  - next_suggest:{skill-name}
81
83
  - 原因:{why}
82
- - 是否需要用户确认:是
84
+ - 是否需要用户确认:是 / 否(code-fix 复扫为"否",自动执行)
83
85
  ```
84
86
 
87
+ ### 强制执行 vs 建议执行
88
+
89
+ | 步骤 | 类型 | 说明 |
90
+ |------|------|------|
91
+ | code-fix → wl-skills validate | **强制** | 修复后自动复扫,不等用户确认 |
92
+ | code-fix → convention-audit --quick | **建议** | 大规模修复后推荐 |
93
+ | page-codegen → convention-audit | **建议** | 生成后建议审计 |
94
+ | convention-audit → code-fix | **建议** | 有可修复项时推荐 |
95
+ | 其他所有 next_suggest | **建议** | 用户确认后执行 |
96
+
85
97
  ---
86
98
 
87
99
  ## 5. MCP/CLI 辅助能力
@@ -68,8 +68,14 @@ skills/
68
68
  5. 如用户表达连续交付/智能体/全流程意图,同时读取 `_pipeline.md` 获取 Skill I/O 与 `next_suggest`
69
69
  6. 在 SKILL.md 指示下输出 **Pre-flight 声明**(强制约定式输出)
70
70
  7. 页面生成任务必须额外读取 `standards/12-base-table.md`,并执行 `BaseTable + render-type="agGrid" + cid + defineColumns + renderOps` 硬约束
71
- 8. 若消息包含"风格 / skills-ui / 状态标签 / 操作列 / AGGrid",同时建议运行 `wl-skills doctor-ui`
71
+ 8. 若消息包含“风格 / skills-ui / 状态标签 / 操作列 / AGGrid”,同时建议运行 `wl-skills doctor-ui`
72
72
  9. `business-doc-extract` 不依赖关键词匹配,AI 必须按 `资料源 + 意图 + 范围` 三因素自行判断;缺资料时先询问用户提供原型/详设/字段资料路径,不要凭推断写入 `docs/business`
73
+ 10. **闭环强制约定**:code-fix 完成后必须自动执行 `wl-skills validate` 复扫,不等待用户确认
74
+ 11. **高风险 Skill 确认机制**:以下 Skill 触发前必须二次确认用户意图(输出“即将执行 XX,确认继续?”):
75
+ - `page-codegen`(会创建/覆盖文件)
76
+ - `menu-sync` / `dict-sync` / `permission-sync`(会调用后端接口写数据)
77
+ - `code-fix`(会修改源码)
78
+ 12. **误触发防护**:当用户消息同时匹配 2+ Skill 且非明确流水线意图时,必须先输出“检测到多个可能的 Skill,您的意图是?”并列出候选,而不是自行决定
73
79
 
74
80
  ---
75
81
 
@@ -45,6 +45,51 @@ description: "Use when: auditing project source code against the 14 modular stan
45
45
 
46
46
  ---
47
47
 
48
+ ## 复扫模式(--quick,v2.11+ 新增)
49
+
50
+ > 闭环专用:code-fix 修复后快速验证,不做全量 14 条扫描,仅复查上次报告中的 🔴🟡 项。
51
+
52
+ ### 触发方式
53
+
54
+ ```
55
+ 复扫验证 / 复扫上次审计 / convention-audit --quick / 确认修复效果
56
+ ```
57
+
58
+ ### 执行逻辑
59
+
60
+ 1. 读取 `reports/规范审查报告.md` 最新章节中的 🔴🟡 偏差清单
61
+ 2. **仅对这些偏差涉及的文件**重新检测(不扫描全项目)
62
+ 3. 对比上次报告数据,输出变化矩阵
63
+ 4. 追加复扫结果到报告
64
+
65
+ ### 复扫报告格式
66
+
67
+ ```markdown
68
+ ## 🔄 复扫 {YYYY-MM-DD HH:mm} | 触发:code-fix 后自动复扫
69
+
70
+ | 指标 | 修复前 | 修复后 | 变化 |
71
+ |---|---:|---:|---|
72
+ | 🔴 严重 | {N} | {N} | {-N} ✅ |
73
+ | 🟡 警告 | {N} | {N} | {-N} ✅ |
74
+ | 未解决 | - | {N} | 待处理 |
75
+
76
+ ### 结论
77
+ - ✔ 闭环完成,可提交
78
+ - 或:✖ 仍有 {N} 个未解决项,建议继续处理
79
+ ```
80
+
81
+ ### 与全量审计的区别
82
+
83
+ | | 全量审计 | --quick 复扫 |
84
+ |---|---|---|
85
+ | 规范覆盖 | 14 条全部 | 仅上次报告中的偏差项 |
86
+ | 扫描范围 | 指定目录或全项目 | 仅偏差涉及文件 |
87
+ | token 消耗 | 高 | 低(约全量的 10%) |
88
+ | 适用场景 | 首次体检/定期审计 | code-fix 后闭环验证 |
89
+ | 输出 | 完整报告 12 章 | 复扫对比矩阵 |
90
+
91
+ ---
92
+
48
93
  ## 审计范围(14 条规范全覆盖)
49
94
 
50
95
  ### 审计方式分层
@@ -110,7 +155,7 @@ description: "Use when: auditing project source code against the 14 modular stan
110
155
 
111
156
  ### 步骤 2:加载规范基线 + 工具链检测
112
157
 
113
- 1. 读取 `standards/01 ~ 13` 全部规范文件
158
+ 1. 读取 `standards/01 ~ 14` 全部规范文件
114
159
  2. 检测工具链状态:
115
160
  - ESLint:是否可执行
116
161
  - TypeScript:`tsc --noEmit` 是否可执行
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: page-codegen
3
- description: "Use when: generating complete Vue 3 page code (index.vue + data.ts + modal components + api.md + pages.ts registration) from a prototype page inventory and API contract, strictly following the cx-ui-produce project conventions. Read SKILL.md first (rules+constraints), then read the matching TPL-*.md for the template code. Triggers on: generate page, create page, code generation, 生成页面, 页面代码, 代码生成, vue页面, 按原型生成, 口述需求, 建个页面, 写个页面, 帮我生成, natural language page generation."
3
+ description: "Use when: generating complete Vue 3 page code (index.vue + data.ts + modal components + api.md + pages.ts registration) from a prototype page inventory and API contract, strictly following the cx-ui-produce project conventions. Read SKILL.md first (rules+constraints), then read the matching TPL-*.md for the template code. Triggers on: generate page, create page, code generation, 生成页面, 页面代码, 代码生成, vue页面, 帮我生成, natural language page generation. NOTE: 口述需求/建个页面/写个页面/按原型生成 belong to prototype-scan first (page-codegen chains from it via 模式 0)."
4
4
  ---
5
5
 
6
6
  # Skill: 页面代码生成(page-codegen)
@@ -45,14 +45,34 @@ description: "Use when: generating complete Vue 3 page code (index.vue + data.ts
45
45
  ✅ src/views/.../{页面}/api.md
46
46
  ✅ reports/SYS_MENU_INFO.md → 已追加菜单条目
47
47
  ────────────────────────────────────────────────
48
+ 🔍 强制自检(不可跳过):
49
+ wl-skills validate src/views/{生成的页面目录}
50
+ → 结果:{0 error / N warn} 或列出 error 待修复
51
+ ────────────────────────────────────────────────
48
52
  📌 后续步骤:
49
53
  1. 在 router/pages.ts 注册路由
50
54
  2. 若本页 hiddenMenu=true → 在 src/util/navigate-hidden.ts 的 HIDDEN_ROUTE_MAP 追加一行
51
- 3. 提交:git cz(禁止直接 git commit
52
- 4. 可选:触发 convention-audit 扫描本次生成文件
55
+ 3. 提交:git cz(禁止直接 git commit,pre-commit 会自动检测规范)
53
56
  ────────────────────────────────────────────────
54
57
  ```
55
58
 
59
+ ### 生成后强制自检(不可跳过,不可标记为"可选")
60
+
61
+ > **v2.10.0+ 硬约束**:生成页面代码后,AI **必须**立即执行规范自检,不可跳过。
62
+
63
+ 1. **调用 MCP 工具** `wls_validate_page`,path 参数为**本次生成的页面目录**(精确到具体页面,不传 src/views 全局)
64
+ 2. 如有 **error**:
65
+ - 仅修复**本次生成的文件**中的 error(index.vue / data.ts / index.scss / api.md)
66
+ - 如 error 来自同目录下的**旧文件**(非本次生成),不要修改,在摘要中标注"已跳过 N 个旧文件 error"
67
+ - 修复后重新自检直到本次生成的文件 0 error
68
+ 3. 如有 **warn** → 尝试修复,确实无法修复的在摘要中说明原因
69
+ 4. 自检结果(error 数 / warn 数 / 跳过的旧文件数)写入上方"生成完成摘要"
70
+ 5. 自检范围为本次生成的**单个页面目录**,不对无关页面负责
71
+
72
+ > 这条规则确保 AI 不会"写完就跑"——生成和验证形成闭环。
73
+ > **作用域隔离原则**:AI 只对自己本次生成的文件负责,不强制修复历史遗留偏差。
74
+ > git commit 时 pre-commit hook 会再次拦截,但 AI 应在生成阶段就消除本次生成的 error。
75
+
56
76
  ---
57
77
 
58
78
  ## 前置检查
@@ -1,96 +1,135 @@
1
- ---
2
- name: code-fix
3
- description: "Use when: fixing code convention issues found in convention-audit reports. Triggers on: 自动修复, 整改偏差, 修复报告, 规范整改, 修复偏差, code fix, 整改规范."
4
- ---
5
-
6
- # Skill: 受控自动修复(code-fix)
7
-
8
- 读取 `reports/规范审查报告.md` 中的偏差条目,在用户确认 diff 后执行单条或分组修复。
9
-
10
- > **前置**:必须先运行 `convention-audit` 生成审计报告,code-fix 依赖其输出。
11
- > **范围**:仅修复 🟡 / 🟢 等级偏差;🔴 严重偏差必须人工或 page-codegen 重新生成。
12
-
13
- ---
14
-
15
- ## 工作流
16
-
17
- ```
18
- reports/规范审查报告.md(convention-audit 输出)
19
-
20
-
21
- [1] 用户从报告挑选 issueId(或 issueGroup),或说"列出可修复项"
22
-
23
-
24
- [2] 解析 issue → 定位文件 + 行号 + 偏差类型
25
-
26
-
27
- [3] 选择修复策略:
28
- ├─ rule-based(如缺 :scoped、缺 cid 等)→ 直接按规则生成 patch
29
- └─ ai-based(语义性偏差)→ AI 生成 patch
30
-
31
-
32
- [4] Pre-flight 输出 diff 预览(人读,必须等待确认)
33
-
34
-
35
- [5] 用户 yes → 写入文件 + 在报告中标记该条目为 ✅ 已修复
36
- 用户 no → 跳过该 issue,回到挑选界面
37
- ```
38
-
39
- ---
40
-
41
- ## 受控原则(严格执行,不可绕过)
42
-
43
- | 原则 | 说明 |
44
- | --- | --- |
45
- | **不修 🔴** | 严重偏差必须人工或 page-codegen 处理,code-fix 不介入 |
46
- | **不破坏功能** | 只改报告点名的行,不顺手"重构"周边代码 |
47
- | **不批量盲改** | 每个文件都先 diff 预览,禁止跳过用户确认 |
48
- | **不生成新逻辑** | 只修偏差,不做功能补全(那是 page-codegen 的职责) |
49
- | **范围明确** | 若用户引导修改业务逻辑,必须拒绝并说明原因 |
50
-
51
- ---
52
-
53
- ## 偏差类型 修复策略
54
-
55
- | 偏差类型 | 来源 standards | 策略 |
56
- | --- | --- | --- |
57
- | EColumn 缺 cid | standards/12-base-table.md | rule-based |
58
- | 列级 cid 只用缩写前缀(如 `mca-steelCode`) | standards/12-base-table.md | rule-based |
59
- | scss 文件缺 `:scoped` 包裹 | standards/02-code-structure.md | rule-based |
60
- | import 路径不规范 | standards/04-coding-basics.md | rule-based |
61
- | `any` 滥用(> 3 处/页) | standards/09-typescript.md | ai-based |
62
- | API_CONFIG URL 命名偏差 | api-contract.md | ai-based |
63
- | 表格列定义与 api.md 字段不一致 | api-contract + data-ts | ai-based |
64
- | 业务语义偏差(流程不对)| 多 standards 综合 | **不修复,标记人工** |
65
-
66
- ---
67
-
68
- ## 触发命令形态
69
-
70
- ```
71
- "修复 reports/规范审查报告.md 中的 issue#3" → 单条修复
72
- "修复 reports/规范审查报告.md 中所有 scss 偏差" → 分组修复
73
- "修复全部 rule-based 偏差,跳过 ai-based" → 受控批量
74
- "列出可修复的 issue" 仅列清单,不动任何文件
75
- ```
76
-
77
- ---
78
-
79
- ## Pre-flight 声明示例
80
-
81
- ```
82
- 🚀 已触发技能 ops/code-fix/SKILL.md 受控自动修复偏差
83
- 已读取 reports/规范审查报告.md → 找到 12 条偏差(rule-based 8 条,ai-based 4 条)
84
- 当前目标:issue#3(EColumn cid)→ 文件 src/views/sale/order/data.ts L42
85
- ⚠️ 以下操作会修改文件,请在 diff 预览后确认
86
- ```
87
-
88
- ---
89
-
90
- ## 与其他 Skill 的关系
91
-
92
- | Skill | 关系 |
93
- | --- | --- |
94
- | convention-audit | **前置**:必须先有审计报告,code-fix 才有输入 |
95
- | page-codegen | 互斥:生成新页面用 codegen,不用 fix |
96
- | template-extract | 无直接关系 |
1
+ ---
2
+ name: code-fix
3
+ description: "Use when: fixing code convention issues found in convention-audit reports. Triggers on: 自动修复, 整改偏差, 修复报告, 规范整改, 修复偏差, code fix, 整改规范."
4
+ ---
5
+
6
+ # Skill: 受控自动修复(code-fix)
7
+
8
+ 读取 `reports/规范审查报告.md` 中的偏差条目,在用户确认 diff 后执行单条或分组修复。
9
+
10
+ > **前置**:必须先运行 `convention-audit` 生成审计报告,code-fix 依赖其输出。
11
+ > **范围**:仅修复 🟡 / 🟢 等级偏差;🔴 严重偏差必须人工或 page-codegen 重新生成。
12
+
13
+ ---
14
+
15
+ ## 工作流
16
+
17
+ ```
18
+ reports/规范审查报告.md(convention-audit 输出)
19
+
20
+
21
+ [1] 用户从报告挑选 issueId(或 issueGroup),或说"列出可修复项"
22
+
23
+
24
+ [2] 解析 issue → 定位文件 + 行号 + 偏差类型
25
+
26
+
27
+ [3] 选择修复策略:
28
+ ├─ rule-based(如缺 :scoped、缺 cid 等)→ 直接按规则生成 patch
29
+ └─ ai-based(语义性偏差)→ AI 生成 patch
30
+
31
+
32
+ [4] Pre-flight 输出 diff 预览(人读,必须等待确认)
33
+
34
+
35
+ [5] 用户 yes → 写入文件 + 在报告中标记该条目为 ✅ 已修复
36
+ 用户 no → 跳过该 issue,回到挑选界面
37
+
38
+
39
+ [6] ★ 强制复扫验证(闭环关键步骤,不可跳过)
40
+ ├─ 本轮修复完成后,自动执行 wl-skills validate 检测修复结果
41
+ ├─ 如仍有 error → 提示未完全修复,建议继续处理
42
+ └─ 全部通过 → 输出 ✔ 闭环完成,可安全提交
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 强制复扫验证(v2.11+ 闭环保障)
48
+
49
+ > **闭环原则**:code-fix 修复后必须验证修复效果,不允许"改完就走"。
50
+
51
+ AI 在完成**本轮全部修复**后(单条或批量),**必须自动执行**:
52
+
53
+ 1. 调用 `wl-skills validate`(或 MCP `wls_validate_page`)对修复文件检测
54
+ 2. 检测通过(0 error)→ 输出 "✔ 复扫通过,闭环完成"
55
+ 3. 检测仍有 error 输出残余问题清单,建议继续修复或标记人工
56
+ 4. 完成摘要中记录复扫结果
57
+
58
+ ```
59
+ ## 完成摘要
60
+ - 修复项:{N} 条(rule-based {N} / ai-based {N})
61
+ - 复扫结果:✔ 通过 / 残余 {N} error
62
+ - 涉及文件:{file list}
63
+
64
+ ## 复扫验证
65
+ - 执行:wl-skills validate
66
+ - error: 0 / warn: {N}
67
+ - 结论:可安全提交 / 需继续处理
68
+
69
+ ## 建议下一步
70
+ - next_suggest:git add + git commit(复扫通过时)
71
+ - next_suggest:继续 code-fix 或人工处理(复扫未通过时)
72
+ ```
73
+
74
+ **不可跳过**:即使用户说"不用验证了",AI 也必须执行复扫。这是闭环完整性的硬性约束。
75
+
76
+ ---
77
+
78
+ ## 受控原则(严格执行,不可绕过)
79
+
80
+ | 原则 | 说明 |
81
+ | --- | --- |
82
+ | **不修 🔴** | 严重偏差必须人工或 page-codegen 处理,code-fix 不介入 |
83
+ | **不破坏功能** | 只改报告点名的行,不顺手"重构"周边代码 |
84
+ | **不批量盲改** | 每个文件都先 diff 预览,禁止跳过用户确认 |
85
+ | **不生成新逻辑** | 只修偏差,不做功能补全(那是 page-codegen 的职责) |
86
+ | **范围明确** | 若用户引导修改业务逻辑,必须拒绝并说明原因 |
87
+
88
+ ---
89
+
90
+ ## 偏差类型 修复策略
91
+
92
+ | 偏差类型 | 来源 standards | 策略 |
93
+ | --- | --- | --- |
94
+ | EColumn 缺 cid | standards/12-base-table.md | rule-based |
95
+ | 列级 cid 只用缩写前缀(如 `mca-steelCode`) | standards/12-base-table.md | rule-based |
96
+ | scss 文件缺 `:scoped` 包裹 | standards/02-code-structure.md | rule-based |
97
+ | import 路径不规范 | standards/04-coding-basics.md | rule-based |
98
+ | `any` 滥用(> 3 处/页) | standards/09-typescript.md | ai-based |
99
+ | API_CONFIG URL 命名偏差 | api-contract.md | ai-based |
100
+ | 表格列定义与 api.md 字段不一致 | api-contract + data-ts | ai-based |
101
+ | 业务语义偏差(流程不对)| 多 standards 综合 | **不修复,标记人工** |
102
+
103
+ ---
104
+
105
+ ## 触发命令形态
106
+
107
+ ```
108
+ "修复 reports/规范审查报告.md 中的 issue#3" → 单条修复
109
+ "修复 reports/规范审查报告.md 中所有 scss 偏差" → 分组修复
110
+ "修复全部 rule-based 偏差,跳过 ai-based" → 受控批量
111
+ "列出可修复的 issue" → 仅列清单,不动任何文件
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Pre-flight 声明示例
117
+
118
+ ```
119
+ 🚀 已触发技能 ops/code-fix/SKILL.md → 受控自动修复偏差
120
+ ✅ 已读取 reports/规范审查报告.md → 找到 12 条偏差(rule-based 8 条,ai-based 4 条)
121
+ ✅ 当前目标:issue#3(EColumn 缺 cid)→ 文件 src/views/sale/order/data.ts L42
122
+ ⚠️ 以下操作会修改文件,请在 diff 预览后确认
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 与其他 Skill 的关系
128
+
129
+ | Skill | 关系 |
130
+ | --- | --- |
131
+ | convention-audit | **前置**:必须先有审计报告,code-fix 才有输入 |
132
+ | wl-skills validate | **后置**:修复完成后必须复扫验证(闭环保障) |
133
+ | convention-audit(复扫) | **后置可选**:大规模修复后可触发 --quick 模式复扫 |
134
+ | page-codegen | 互斥:生成新页面用 codegen,不用 fix |
135
+ | template-extract | 无直接关系 |
@@ -47,7 +47,7 @@
47
47
  ### 任务类型 C:规范审计(convention-audit)
48
48
 
49
49
  ```
50
- 必读:全部 13 条(审计需要完整对照)
50
+ 必读:全部 14 条(审计需要完整对照)
51
51
  ```
52
52
 
53
53
  ### 任务类型 D:模板提取(template-extract)
@@ -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
+ ];