lint: add explicit return types and drop redundant/unnecessary type constructs

- Add explicit `(): void` return types to several useEffect cleanup
  callbacks (settingTabComponent, ColorPicker, AdvancedToolbarSettings,
  mobileModifyComponent).
- Widen Mode's literal union with `(string & {})` instead of a bare
  string constituent, preserving autocomplete without the redundant
  type warning.
- Drop an unnecessary `as ItemView` cast in pageHeaderManager now that
  the preceding instanceof guard already narrows the type.
- Switch eslint.config.mts from the deprecated tseslint.config() to
  eslint's own defineConfig().

Type-level only, no runtime behavior change.
This commit is contained in:
johnny1093 2026-07-11 09:23:02 -04:00
parent 85da080ae4
commit ebeae5c6c8
7 changed files with 13 additions and 9 deletions

View file

@ -1,9 +1,9 @@
import tseslint from 'typescript-eslint';
import obsidianmd from 'eslint-plugin-obsidianmd';
import globals from 'globals';
import { globalIgnores } from 'eslint/config';
import { defineConfig, globalIgnores } from 'eslint/config';
export default tseslint.config(
export default defineConfig(
globalIgnores([
'node_modules',
'build',

View file

@ -26,7 +26,7 @@ export default class PageHeaderManager extends CommandManagerBase {
const buttons = this.buttonsFor(leaf, true);
if (!buttons || buttons.has(id)) return;
const buttonIcon = (view as ItemView).addAction(icon, name, () => {
const buttonIcon = view.addAction(icon, name, () => {
this.plugin.app.workspace.setActiveLeaf(leaf, { focus: true });
this.plugin.app.commands.executeCommandById(id);
});

View file

@ -61,7 +61,7 @@ export interface Tab {
tab: h.JSX.Element;
}
export type Mode = "desktop" | "any" | "mobile" | string;
export type Mode = "desktop" | "any" | "mobile" | (string & {});
export interface CommandIconPair {
id: string;

View file

@ -221,7 +221,9 @@ export default function AdvancedToolbarSettings({
if (ref.current) {
render(ref.current, plugin);
}
return () => ref.current && ref.current.empty();
return (): void => {
ref.current && ref.current.empty();
};
}, []);
return (

View file

@ -19,7 +19,9 @@ export const ColorPicker = ({
.onChange(onChange);
}
return () => ref.current?.empty?.();
return (): void => {
ref.current?.empty?.();
};
}, [onChange, initialColor]);
return <div ref={ref} className="cmdr-flex cmdr-items-center" />;

View file

@ -18,7 +18,7 @@ export default function MobileModifyComponent({
this.forceUpdate();
};
addEventListener("cmdr-icon-changed", update);
return () => removeEventListener("cmdr-icon-changed", update);
return (): void => removeEventListener("cmdr-icon-changed", update);
}, []);
return (

View file

@ -37,7 +37,7 @@ export default function settingTabComponent({
useEffect(() => {
addEventListener("keydown", tabToNextTab);
return () => removeEventListener("keydown", tabToNextTab);
return (): void => removeEventListener("keydown", tabToNextTab);
}, [activeTab]);
//This is used to remove the initial onclick event listener.
@ -342,7 +342,7 @@ export function TabHeader({
}
el.addEventListener("wheel", handleScroll);
return () => el.removeEventListener("wheel", handleScroll);
return (): void => el.removeEventListener("wheel", handleScroll);
}, []);
useEffect(