forked from ChaiHao/BPOS-MVP
@contracts 首版(§8.1 九个文件): - id 品牌 ID / terminal 终态五名与归侧四标签 / envelope 信封六字段与四类事件 - card 工单两模式 + 对话卡族(形状对齐 2026-07-26 原型定稿) - contract7 契约七件 / ledger 三级寻址与写三分 / process-package 流程包 DSL 与触发器三类 - manifest 活动包清单六区(含 CMMN·DMN·步序声明的资产形状)/ org / api 路由契约 模块(L1): - event 信封存储、归属解析三级短路、投递五诺、监听注册表、三级消费裁定 - ledger schema 自生长(最大化合并/最宽类型/只增不破坏)、任务视图叠加、写三分、冲突检查 - org 岗位授权(客体三类×动作三种)、停用前置检查、会话、种子播种 - llm 四元绑定、ModelGateway 三模式(live/record/replay)—— 两缝之一 app 装配:Hono 服务 + 鉴权中间件 + 治理台/工作台路由;drizzle 迁移;AES-256-GCM 凭证密封 ADR-007 工具链与门禁 · ADR-008 投递队列 · ADR-009 凭证加密 (ADR 编号自 007 续:编码规范 §14 已用到 006,README 写「从 005 续」是笔误) 门禁五道全绿;96 个测试通过,含对真实 PG 的 ledger 集成测试 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
167 lines
4.9 KiB
JavaScript
167 lines
4.9 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/**',
|
|
'**/node_modules/**',
|
|
'api-report/**',
|
|
'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' },
|
|
},
|
|
);
|