Files
image-workbench-desktop/eslint.config.js
T
qiqi 4b57344de9 refactor(boot): 启动加载/数据恢复/内存护栏 effect 搬至 src/runtime-boot-load.js
app.js 8656 → 8448 行(-208),Workbench() 2511 → 2303 行(-208)。
209 行挂载 effect 逐字搬到新模块(diff 验证 0 处差异),仍是同一个 effect、同一份依赖数组([])。

实现方式:外层自由变量(47 个)由 ctx() 在 effect 执行时求值——与原「首渲染闭包」取值等价,
同时避开 Workbench 内后声明 const 的 TDZ(渲染期求值会撞)。

附带调整(均非逻辑变更):
1. 棘轮下调至实测(MAX_APP_JS_LINES 8449 / MAX_WORKBENCH_LINES 2303),文档数字由 sync-facts 同步;
2. 模块按 src 命名前缀规范命名为 runtime-boot-load.js;
3. eslint globals 与 iwb-globals.d.ts 增补 IWBBootLoad;
4. tests/image-file-ref-preview-test.js 的 grantKnown 顺序断言改读新模块(内容不变,并加验 grantKnown 先于 setWorkspaces)。

门禁:verify:ci 全绿(含边界守卫/棘轮/facts);真实浏览器 e2e 失败集合与重构前逐条一致(24 点 diff 为空)。
2026-11-26 21:45:29 +08:00

70 lines
3.0 KiB
JavaScript
Raw 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',
},
},
linterOptions: { reportUnusedDisableDirectives: true },
rules: { ...sharedRules, 'no-undef': 'error' },
},
]