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); });