mirror of
https://github.com/brendan-ch/todo-tracker-obsidian.git
synced 2026-04-19 08:10:29 +00:00
Fix linting issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ItemView, Platform, TFile, WorkspaceLeaf } from 'obsidian';
|
||||
import { App, ItemView, Platform, TFile, WorkspaceLeaf } from 'obsidian';
|
||||
import type { TodoItem, TodoGroup } from '../core/types';
|
||||
import { parseTodosGroupedByHeading } from '../core/todo-parser';
|
||||
import { toggleTodo } from '../core/todo-transformer';
|
||||
@@ -27,7 +27,7 @@ export class TodoSidebarView extends ItemView {
|
||||
}
|
||||
|
||||
getDisplayText(): string {
|
||||
return 'Todo Tracker';
|
||||
return 'Todo tracker';
|
||||
}
|
||||
|
||||
getIcon(): string {
|
||||
@@ -44,14 +44,14 @@ export class TodoSidebarView extends ItemView {
|
||||
|
||||
this.registerEvent(
|
||||
this.app.workspace.on('active-leaf-change', () => {
|
||||
this.refresh();
|
||||
void this.refresh();
|
||||
})
|
||||
);
|
||||
|
||||
this.registerEvent(
|
||||
this.app.vault.on('modify', (file) => {
|
||||
if (this.currentFile && file.path === this.currentFile.path) {
|
||||
this.refresh();
|
||||
void this.refresh();
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -142,7 +142,7 @@ export class TodoSidebarView extends ItemView {
|
||||
group: TodoGroup
|
||||
): void {
|
||||
const itemEl = createTodoItemEl(container, todo, {
|
||||
onToggle: (t) => this.handleToggle(file, t),
|
||||
onToggle: (t) => { void this.handleToggle(file, t); },
|
||||
onMoveClick: (t) => this.handleMoveClick(t, file),
|
||||
onMoveDailyNoteClick: (t) => this.handleMoveDailyNoteClick(t, file),
|
||||
onClick: (t) => this.openTodoInEditor(file, t),
|
||||
@@ -163,9 +163,9 @@ export class TodoSidebarView extends ItemView {
|
||||
group: TodoGroup
|
||||
): void {
|
||||
// Find the child's <li> element within the parent
|
||||
const childEl = parentEl.querySelector(
|
||||
const childEl = parentEl.querySelector<HTMLElement>(
|
||||
`li[data-line-number="${todo.lineNumber}"]`
|
||||
) as HTMLElement | null;
|
||||
);
|
||||
if (childEl) {
|
||||
this.flatTodoList.push({ todo, element: childEl, group });
|
||||
|
||||
@@ -222,15 +222,19 @@ export class TodoSidebarView extends ItemView {
|
||||
}
|
||||
|
||||
private isToggleCheckboxHotkey(evt: KeyboardEvent): boolean {
|
||||
// Bug 3 fix: properly match Obsidian hotkeys using correct API
|
||||
const hotkeyManager = (this.app as any).hotkeyManager;
|
||||
interface HotkeyDef { modifiers: string[]; key: string; }
|
||||
interface HotkeyManager {
|
||||
getHotkeys(commandId: string): HotkeyDef[];
|
||||
getDefaultHotkeys(commandId: string): HotkeyDef[];
|
||||
}
|
||||
const hotkeyManager = (this.app as App & { hotkeyManager?: HotkeyManager }).hotkeyManager;
|
||||
if (!hotkeyManager) return false;
|
||||
|
||||
const commandId = 'editor:toggle-checklist-status';
|
||||
|
||||
// Get custom hotkeys (user-configured), then fall back to defaults
|
||||
const customHotkeys = hotkeyManager.getHotkeys?.(commandId) ?? [];
|
||||
const defaultHotkeys = hotkeyManager.getDefaultHotkeys?.(commandId) ?? [];
|
||||
const customHotkeys = hotkeyManager.getHotkeys(commandId);
|
||||
const defaultHotkeys = hotkeyManager.getDefaultHotkeys(commandId);
|
||||
const allHotkeys = [...customHotkeys, ...defaultHotkeys];
|
||||
|
||||
if (allHotkeys.length === 0) return false;
|
||||
@@ -256,8 +260,6 @@ export class TodoSidebarView extends ItemView {
|
||||
|
||||
// "Mod" means Cmd on Mac, Ctrl on Windows/Linux
|
||||
const isMac = Platform.isMacOS;
|
||||
const modPressed = isMac ? evt.metaKey : evt.ctrlKey;
|
||||
const modExpected = needsMod;
|
||||
|
||||
// On Mac, Ctrl is separate from Mod (Cmd)
|
||||
// On Windows/Linux, Mod and Ctrl both map to ctrlKey
|
||||
@@ -315,7 +317,7 @@ export class TodoSidebarView extends ItemView {
|
||||
|
||||
private openTodoInEditor(file: TFile, todo: TodoItem): void {
|
||||
const leaf = this.app.workspace.getLeaf(false);
|
||||
leaf.openFile(file).then(() => {
|
||||
void leaf.openFile(file).then(() => {
|
||||
const editor = this.app.workspace.activeEditor?.editor;
|
||||
if (editor) {
|
||||
const line = todo.lineNumber;
|
||||
@@ -328,7 +330,7 @@ export class TodoSidebarView extends ItemView {
|
||||
private toggleFocusedTodo(file: TFile): void {
|
||||
const entry = this.flatTodoList[this.focusedIndex];
|
||||
if (!entry) return;
|
||||
this.handleToggle(file, entry.todo);
|
||||
void this.handleToggle(file, entry.todo);
|
||||
}
|
||||
|
||||
private moveFocusedTodo(file: TFile): void {
|
||||
@@ -346,7 +348,7 @@ export class TodoSidebarView extends ItemView {
|
||||
}
|
||||
|
||||
private handleMoveClick(todo: TodoItem, file: TFile): void {
|
||||
import('../modals/note-select-modal').then(({ NoteSelectModal }) => {
|
||||
void import('../modals/note-select-modal').then(({ NoteSelectModal }) => {
|
||||
new NoteSelectModal(this.app, todo, file).open();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user