/* ===================================================================== * ESLint 配置:只启用 no-undef 一条规则 * * 目的:抓"引用了未声明的变量"这类运行时才暴露的错误 * (例如 prepareCardTTS 里用了 ttsPreparedCardKey 但声明丢失)。 * npm run lint 的 node --check 只做语法检查,看不见这类问题。 * * 覆盖范围按需渐进:目前只纳入 3 个高频维护的孪生 web tool, * 后续某个 tool 清干净了,再往文件列表里加。 * ===================================================================== */ const globals = require('globals'); /** 三个孪生 web tool 目录(增量扩展时改这里即可) */ const TWIN_WEB_TOOLS = [ 'public/tools/web_order_box/**/*.js', 'public/tools/web_zen_box/**/*.js', 'public/tools/web_mobile_calendar_reminder/**/*.js' ]; /** 非浏览器运行环境的脚本,单独配置 */ const SERVICE_WORKER_FILES = ['public/tools/web_zen_box/sw.js']; const NODE_SCRIPT_FILES = ['public/tools/web_zen_box/generate-icons.js']; module.exports = [ // 浏览器端 tool 脚本(IIFE / 全局脚本) { files: TWIN_WEB_TOOLS, ignores: [...SERVICE_WORKER_FILES, ...NODE_SCRIPT_FILES], languageOptions: { ecmaVersion: 'latest', sourceType: 'script', globals: { ...globals.browser } }, rules: { 'no-undef': 'error' } }, // Service Worker(caches / clients / self / skipWaiting 等) { files: SERVICE_WORKER_FILES, languageOptions: { ecmaVersion: 'latest', sourceType: 'script', globals: { ...globals.serviceworker } }, rules: { 'no-undef': 'error' } }, // Node 辅助脚本(require / module / process 等) { files: NODE_SCRIPT_FILES, languageOptions: { ecmaVersion: 'latest', sourceType: 'commonjs', globals: { ...globals.node } }, rules: { 'no-undef': 'error' } } ];