From fcb699ffb9021632d0a8e72a074fd507342be020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A4=A7=E7=8C=AB?= <16399091+binaricat@users.noreply.github.com> Date: Mon, 25 May 2026 13:53:53 +0800 Subject: [PATCH] chore(eslint): lint electron/bridges for undefined references (#1086) --- eslint.config.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index f0bc4fd0..2d8713b3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,11 +3,16 @@ import tsParser from "@typescript-eslint/parser"; import tsPlugin from "@typescript-eslint/eslint-plugin"; import unusedImports from "eslint-plugin-unused-imports"; import reactHooks from "eslint-plugin-react-hooks"; +import globals from "globals"; export default [ - js.configs.recommended, + // The recommended preset has no file scope of its own, so scope it off all of + // electron/ — that main-process tree is historically unlinted. The bridges + // get a focused rule set in the dedicated block at the end of this config; + // every other electron/ file matches no config and stays unlinted as before. + { ...js.configs.recommended, ignores: ["electron/**"] }, { - ignores: ["node_modules/**", "dist/**", "electron/**", "scripts/**", "public/monaco/**", ".github/**", ".claude/**", "release/**", ".worktrees/**"], + ignores: ["node_modules/**", "dist/**", "scripts/**", "public/monaco/**", ".github/**", ".claude/**", "release/**", ".worktrees/**"], }, { files: ["**/*.{ts,tsx}"], @@ -168,4 +173,26 @@ export default [ ], }, }, + { + // Electron main-process bridges are CommonJS and were historically excluded + // from linting. Lint them for undefined references only — the cheap, + // high-value guard against e.g. a removed variable still referenced + // elsewhere. (The TS config disables no-undef because the type-checker + // already covers it there; these .cjs files have no such safety net.) + files: ["electron/bridges/**/*.cjs"], + languageOptions: { + ecmaVersion: "latest", + sourceType: "commonjs", + globals: globals.node, + }, + linterOptions: { + // Only no-undef is enabled here, so pre-existing eslint-disable comments + // for other rules (no-console, no-control-regex, …) would all report as + // "unused". Don't flag them — they stay valid for future rule additions. + reportUnusedDisableDirectives: "off", + }, + rules: { + "no-undef": "error", + }, + }, ];