Archived
任务详情里的「流程链」在 MVP 包上读作 **A1 → A7 → A2 → A6 → A3 → A5 → A4**。
不是随机:`toChain` 按 `layout.col` 排,而 MVP 图是**回形走线**(第 0 行左→右、
第 1 行右→左、第 2 行折回最左),A7 的列位(1)正好跟 A1 并列、A6(3)跟 A2 并列。
原注释还写着「列位是流程的推进次序(拓扑的可视化)」—— 那句话只对 v1 那种一行
从左画到右的包成立,换一张图就是错的。图纸声明为「不影响语义」,那它也不配决定次序。
改为按**边**做拓扑序,新增 `advanceOrder`(process 的 domain,纯函数零 IO):
· 回边(reopen)排除在外 —— 它是重新入场不是往前推进;留着 G4 → A4 就成环,
A4 会等自己的下游,拓扑序无从下手
· 真并行支(G2 分出的 A2 / A3)图上本无先后,按**节点编号**定 ——
同一个包在谁手上都读作同一条链
· 进不了拓扑序的节点(不可达、或排除回边后仍有环)按编号缀在末尾:少排序,不丢节点
实测链已读作 A1 → A2 → A3 → A4 → A5 → A6 → A7(A1 current)。
六条 domain 测试盯住它,第一条就是那张回形图。
顺带修了两处会互相传染的闸:
· `api-report.mjs` 在 tsc 失败那条路径不清 `.api-tmp`,半成品留在盘上,
eslint 扫到生成的 .d.ts 报 1004 条假错 —— 于是 tsc 一红 lint 跟着红。实测踩到。
· eslint 只忽略了 `api-report/**`,把同为产物的 `.api-tmp/**` 一并忽略
契约变更(加法,非破坏):①depcruise 反查六处下游无违规 ②CONTRACT.md 已注明
③快照 api-report/…/process/index.d.ts 仅多一个导出名。
typecheck ✓ lint ✓ depcruise 374 模块 ✓ 487 测试 ✓(以退出码验,不以 echo 验)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
171 lines
5.1 KiB
JavaScript
171 lines
5.1 KiB
JavaScript
// @ts-check
|
|
/**
|
|
* JCAI ESLint 门禁 —— 编码规范 §11.3 + §12.5 禁止清单的可机检部分。
|
|
* **约束报错时,改代码,不改约束(§11)。**
|
|
*/
|
|
import js from '@eslint/js';
|
|
import tseslint from 'typescript-eslint';
|
|
import globals from 'globals';
|
|
|
|
const MODULE_DOMAIN = 'apps/api/src/modules/*/internal/domain/**/*.ts';
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores: [
|
|
'**/dist/**',
|
|
'**/.build/**',
|
|
'**/node_modules/**',
|
|
'api-report/**',
|
|
// api:check 生成声明用的临时盘;它和 api-report 一样是**产物不是源码**。
|
|
// 不排除的话,api:check 中途失败留下的半成品会让 lint 报上千条假错。
|
|
'.api-tmp/**',
|
|
'tools/depcruise-tiers.generated.cjs',
|
|
'docs/**',
|
|
],
|
|
},
|
|
|
|
js.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
|
|
{
|
|
languageOptions: {
|
|
ecmaVersion: 2023,
|
|
sourceType: 'module',
|
|
globals: { ...globals.node },
|
|
},
|
|
linterOptions: { reportUnusedDisableDirectives: 'error' },
|
|
rules: {
|
|
// §11.3
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
patterns: [
|
|
// 别名穿透:@modules/ledger/internal/... 一律拦下(只能 import 到模块根)
|
|
{
|
|
group: ['@modules/*/*', '@features/*/*'],
|
|
message: '只能 import 到模块根(编码规范 §5.2)',
|
|
},
|
|
// 显式写出 modules/ 段的相对穿透
|
|
{
|
|
group: ['**/modules/*/internal/**', '**/features/*/internal/**'],
|
|
message: '禁止穿透模块出口(编码规范 §5.2)',
|
|
},
|
|
// 爬三层及以上 = 跨模块;跨模块请走别名与出口
|
|
{ group: ['../../../*'], message: '跨模块请用路径别名(编码规范 §11.3)' },
|
|
],
|
|
},
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
'@typescript-eslint/consistent-type-imports': 'error',
|
|
'@typescript-eslint/ban-ts-comment': 'error',
|
|
|
|
// §12.5#4:禁 as unknown as
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: 'TSAsExpression > TSAsExpression > TSUnknownKeyword',
|
|
message: '禁止 as unknown as(编码规范 §12.5#4)—— 改类型,不改断言',
|
|
},
|
|
],
|
|
|
|
// §12.5#6:禁模块级可变状态
|
|
'no-var': 'error',
|
|
'prefer-const': 'error',
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
],
|
|
},
|
|
},
|
|
|
|
// 模块出口的公开签名必须显式(ADR-005 #3:契约快照才不被 internal 推断类型带偏)
|
|
{
|
|
files: ['apps/api/src/modules/**/*.ts'],
|
|
rules: {
|
|
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
},
|
|
},
|
|
|
|
// domain/ 零 IO、零 Date.now / Math.random(§5.3 / §12.5#5)
|
|
{
|
|
files: [MODULE_DOMAIN],
|
|
rules: {
|
|
'no-restricted-properties': [
|
|
'error',
|
|
{ object: 'Date', property: 'now', message: 'domain 零时钟:时钟走 port.Clock(§5.3)' },
|
|
{
|
|
object: 'Math',
|
|
property: 'random',
|
|
message: 'domain 零随机:随机走 port(§5.3)',
|
|
},
|
|
],
|
|
'no-restricted-globals': [
|
|
'error',
|
|
{ name: 'fetch', message: 'domain 零 IO(§5.3)' },
|
|
{ name: 'process', message: 'domain 零环境能力(§5.3)' },
|
|
],
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: 'TSAsExpression > TSAsExpression > TSUnknownKeyword',
|
|
message: '禁止 as unknown as(编码规范 §12.5#4)',
|
|
},
|
|
{
|
|
selector: 'NewExpression[callee.name="Date"][arguments.length=0]',
|
|
message: 'domain 零时钟:new Date() 走 port.Clock(§5.3)',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
|
|
// 活动包:零环境能力(ADR-004 / AM 12.1)
|
|
{
|
|
files: ['activities/**/*.ts'],
|
|
rules: {
|
|
'no-restricted-globals': [
|
|
'error',
|
|
{ name: 'fetch', message: '活动包零环境能力:一切能力经基座六件注入(ADR-004)' },
|
|
{ name: 'process', message: '活动包零环境能力(ADR-004)' },
|
|
],
|
|
},
|
|
},
|
|
|
|
// 前端
|
|
{
|
|
files: ['apps/web/**/*.{ts,tsx}', 'packages/ui-kit/**/*.{ts,tsx}'],
|
|
languageOptions: { globals: { ...globals.browser } },
|
|
rules: {
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: 'TSAsExpression > TSAsExpression > TSUnknownKeyword',
|
|
message: '禁止 as unknown as(编码规范 §12.5#4)',
|
|
},
|
|
{
|
|
selector: 'JSXAttribute[name.name="dangerouslySetInnerHTML"]',
|
|
message:
|
|
'feature 不得自行 dangerouslySetInnerHTML:活动 HTML 一律经 @ui 的 ViewContainer(§9.2)',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
|
|
// 前端 feature 内禁裸 fetch(§9.2)
|
|
{
|
|
files: ['apps/web/src/features/**/*.{ts,tsx}'],
|
|
rules: {
|
|
'no-restricted-globals': [
|
|
'error',
|
|
{ name: 'fetch', message: '服务端交互只经 shared/typed-fetch + @contracts/api(§9.2)' },
|
|
],
|
|
},
|
|
},
|
|
|
|
// 工具与配置脚本
|
|
{
|
|
files: ['tools/**/*.{ts,mjs,js}', '*.config.{ts,js,mjs}', 'vite.config.ts'],
|
|
rules: { 'no-restricted-syntax': 'off' },
|
|
},
|
|
);
|