Files
qiqi 3e1ecb7463 refactor(canvas): nodeEls 构建块搬至 src/ui-canvas-nodes.js
app.js 8448 → 8315 行(-133),Workbench() 2303 → 2169 行(-134)。
140 行节点列表构建块逐字搬到新模块(diff 验证 0 处差异),52 个自由变量由 ctx 在渲染期传入。

附带调整(均非逻辑变更):
1. 棘轮下调至实测(MAX_APP_JS_LINES 8315 / MAX_WORKBENCH_LINES 2169),文档数字由 sync-facts 同步;
2. eslint globals 与 iwb-globals.d.ts 增补 IWBCanvasNodes;
3. 两个文本契约测试的锚点改读新模块(断言内容不变):
   tests/node-drag-jank-test.js 的 dragging 入参、tests/image-node-performance-test.js 的 batchSources 合并文本。

门禁:verify:ci 全绿;真实浏览器 e2e 失败集合与重构前逐条一致(24 点 diff 为空)。
2026-11-26 22:03:19 +08:00

71 lines
3.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ESLint 扁平配置 —— P4-16a。
// 目的:给「要拼接成单文件发布」的两处代码加一道**正确性**静态护栏
// (重复键 / 不可达代码 / 自赋值 / 用例错误 / 未定义标识符等),不做风格化(避免无谓 churn)。
// · src/**/*.js:模块化 IIFE,启用 no-undef(浏览器 + es2022 + Buffer 兜底);
// · app.js :单文件 IIFE,自带数百个顶层全局(含 window.IWB* 导入),
// 故**不启用 no-undef**,只挂与作用域无关的正确性规则。
const globals = require('globals')
const sharedRules = {
'no-dupe-keys': 'error',
'no-dupe-args': 'error',
'no-dupe-else-if': 'error',
'no-redeclare': 'error',
'no-unreachable': 'error',
'no-self-assign': 'error',
'no-cond-assign': 'error',
'no-constant-condition': 'error',
'no-fallthrough': 'error',
'no-sparse-arrays': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
'no-obj-calls': 'error',
'no-unsafe-negation': 'error',
'no-irregular-whitespace': 'error',
'no-unexpected-multiline': 'error',
'no-async-promise-executor': 'error',
'no-shadow-restricted-names': 'error',
'no-debugger': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
}
module.exports = [
{
ignores: ['dist/**', 'node_modules/**', 'test-results/**', 'playwright-report/**', '.wrangler/**'],
},
{
files: ['src/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'script',
// Buffer:双环境(浏览器/Node)兜底分支用(`typeof btoa==='function' ? btoa(...) : Buffer...`),浏览器路径永不触达。
globals: { ...globals.browser, ...globals.es2022, Buffer: 'readonly' },
},
linterOptions: { reportUnusedDisableDirectives: true },
rules: { 'no-undef': 'error', ...sharedRules },
},
{
files: ['app.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'script',
// 2026-10-28:补全 globals 并开启 no-undef。
// 之前 app.js 只跑 sharedRules、没有 no-undef ⇒ 未定义变量长期无人发现。
// 实测扫出 33 处未定义引用,其中 refs / setDiagRev 是真缺陷(会在运行期 ReferenceError)。
// React / ReactDOM 由 index.html 的 CDN script 注入,属只读全局
globals: {
...globals.browser, ...globals.es2022, React: 'readonly', ReactDOM: 'readonly',
// 由 src/canvas-actions.js、src/canvas-node-factory.js 挂在 window 上(跨文件全局)
CanvasActions: 'readonly', CanvasNodeFactory: 'readonly',
// 由 src/workspace-purge.js 挂载(v3.24.76:彻底删除的连带清理,含清标签/session/objectURL)
IWBWorkspacePurge: 'readonly',
// 由 src/boot-load.js 挂载(2026-11-26:启动加载/数据恢复/内存护栏从 app.js 收编)
IWBBootLoad: 'readonly',
IWBCanvasNodes: 'readonly',
},
},
linterOptions: { reportUnusedDisableDirectives: true },
rules: { ...sharedRules, 'no-undef': 'error' },
},
]