From 020e24507c8140bf2000e0eb750ed7d101e9603c Mon Sep 17 00:00:00 2001 From: Zero Liu Date: Wed, 13 May 2026 22:09:34 -0700 Subject: [PATCH] chore(eslint): enable @typescript-eslint/unbound-method (#2439) Enabled in the TS-only override block. Disabled for test files since jest assertion patterns (`expect(mock.method).toHaveBeenCalled()`) reference methods unbound by design and have no clean workaround. Fixed the single real source violation in colorOpacityPlugin by calling addUtilities through the plugin API object instead of destructuring it. Co-authored-by: Claude Opus 4.7 (1M context) --- eslint.config.mjs | 15 ++++++++++++++- src/lib/plugins/colorOpacityPlugin.ts | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 507d5fa8..8cc73505 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -92,7 +92,6 @@ export default [ "@typescript-eslint/no-unsafe-call": "off", // 679 violations // --- Medium: promise / method ergonomics --- - "@typescript-eslint/unbound-method": "off", // 68 violations // Enabled in the TS-only block below. // no-deprecated: defer — surface the warnings, but don't fail CI yet @@ -173,6 +172,7 @@ export default [ ], "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-unsafe-return": "error", + "@typescript-eslint/unbound-method": "error", // TypeScript handles undefined-identifier detection (and does so cross-realm // correctly); per typescript-eslint's own guidance, disable no-undef on TS. "no-undef": "off", @@ -223,4 +223,17 @@ export default [ "obsidianmd/rule-custom-message": "off", }, }, + + // Jest assertions like `expect(mock.method).toHaveBeenCalled()` reference + // methods unbound by design. The rule has no clean workaround for jest + // patterns (binding changes the reference identity and breaks the assertion), + // so disable it in tests. Scoped to .ts/.tsx because the @typescript-eslint + // plugin is only registered for those files. Placed last so it overrides the + // TS-only block above. + { + files: ["**/*.test.{ts,tsx}"], + rules: { + "@typescript-eslint/unbound-method": "off", + }, + }, ]; diff --git a/src/lib/plugins/colorOpacityPlugin.ts b/src/lib/plugins/colorOpacityPlugin.ts index 0d5a419e..42be82d6 100644 --- a/src/lib/plugins/colorOpacityPlugin.ts +++ b/src/lib/plugins/colorOpacityPlugin.ts @@ -86,7 +86,8 @@ const processColorObject = * bg-modifier-error/50 * text-background-modifier-success/30 */ -export const colorOpacityPlugin = plugin(function (this: void, { addUtilities, theme, e }) { +export const colorOpacityPlugin = plugin(function (this: void, api) { + const { theme, e } = api; const opacityUtilities: Record = {}; // 处理所有颜色相关的主题配置 @@ -104,5 +105,5 @@ export const colorOpacityPlugin = plugin(function (this: void, { addUtilities, t processThemeColors("borderColor", ""); processThemeColors("colors"); - addUtilities(opacityUtilities); + api.addUtilities(opacityUtilities); });