1- import { TFile , getFrontMatterInfo } from "obsidian" ;
1+ import { TFile , getFrontMatterInfo , EventRef } from "obsidian" ;
22import FirstLineIsTitlePlugin from "../../main" ;
33import { verboseLog } from "../utils" ;
44
5+ /**
6+ * Extended App interface with plugin manager access
7+ */
8+ interface AppWithPlugins {
9+ plugins ?: {
10+ plugins ?: Record < string , unknown > ;
11+ } ;
12+ }
13+
14+ /**
15+ * Extended Workspace interface with custom events
16+ */
17+ interface WorkspaceWithCustomEvents {
18+ on (
19+ name : "templater:new-note-from-template" ,
20+ callback : ( data : Record < string , unknown > ) => void ,
21+ ) : EventRef ;
22+ offref ( ref : EventRef ) : void ;
23+ }
24+
525/**
626 * Context information for file creation decisions
727 */
@@ -347,8 +367,8 @@ export class FileCreationCoordinator {
347367 */
348368 private isTemplaterOn ( ) : boolean {
349369 // Check if Templater plugin exists in app.plugins
350- // eslint-disable-next-line @typescript-eslint/no-explicit-any
351- const templater = ( this . plugin . app as any ) . plugins ?. plugins ;
370+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
371+ ?. plugins ;
352372 return (
353373 templater !== undefined &&
354374 typeof templater === "object" &&
@@ -360,24 +380,22 @@ export class FileCreationCoordinator {
360380 * Node 5: Check if Templater's "Trigger on new file creation" is enabled
361381 */
362382 private isTemplaterTriggerOn ( ) : boolean {
363- // eslint-disable-next-line @typescript-eslint/no-explicit-any
364- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
365- "templater-obsidian"
366- ] ;
383+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
384+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
367385 if ( ! templater ) return false ;
368- return templater . settings ?. trigger_on_file_creation === true ;
386+ const settings = templater . settings as Record < string , unknown > | undefined ;
387+ return settings ?. trigger_on_file_creation === true ;
369388 }
370389
371390 /**
372391 * Node 6: Check if file path matches Templater's template folder location
373392 */
374393 private isInTemplateFolder ( file : TFile ) : boolean {
375- // eslint-disable-next-line @typescript-eslint/no-explicit-any
376- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
377- "templater-obsidian"
378- ] ;
394+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
395+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
379396 if ( ! templater ) return false ;
380- const templateFolder = templater . settings ?. templates_folder || "" ;
397+ const settings = templater . settings as Record < string , unknown > | undefined ;
398+ const templateFolder = ( settings ?. templates_folder as string ) || "" ;
381399
382400 if ( ! templateFolder || templateFolder === "/" ) return false ;
383401
@@ -388,25 +406,23 @@ export class FileCreationCoordinator {
388406 * Node 7: Check if Templater's "Enable folder templates" is ON
389407 */
390408 private isFolderTemplatesEnabled ( ) : boolean {
391- // eslint-disable-next-line @typescript-eslint/no-explicit-any
392- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
393- "templater-obsidian"
394- ] ;
409+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
410+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
395411 if ( ! templater ) return false ;
396- return templater . settings ?. enable_folder_templates === true ;
412+ const settings = templater . settings as Record < string , unknown > | undefined ;
413+ return settings ?. enable_folder_templates === true ;
397414 }
398415
399416 /**
400417 * Node 9: Check if any Templater folder template matches current path
401418 * Uses Templater's walk-up algorithm (deepest match wins)
402419 */
403420 private folderTemplateMatches ( file : TFile ) : boolean {
404- // eslint-disable-next-line @typescript-eslint/no-explicit-any
405- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
406- "templater-obsidian"
407- ] ;
421+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
422+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
408423 if ( ! templater ) return false ;
409- const folderTemplates = templater . settings ?. folder_templates ;
424+ const settings = templater . settings as Record < string , unknown > | undefined ;
425+ const folderTemplates = settings ?. folder_templates ;
410426 if ( ! Array . isArray ( folderTemplates ) ) return false ;
411427
412428 let folder = file . parent ;
@@ -436,24 +452,22 @@ export class FileCreationCoordinator {
436452 * Node 10: Check if Templater's "Enable file regex templates" is ON
437453 */
438454 private isFileRegexEnabled ( ) : boolean {
439- // eslint-disable-next-line @typescript-eslint/no-explicit-any
440- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
441- "templater-obsidian"
442- ] ;
455+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
456+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
443457 if ( ! templater ) return false ;
444- return templater . settings ?. enable_file_templates === true ;
458+ const settings = templater . settings as Record < string , unknown > | undefined ;
459+ return settings ?. enable_file_templates === true ;
445460 }
446461
447462 /**
448463 * Node 11: Check if any Templater file regex matches current path
449464 */
450465 private fileRegexMatches ( file : TFile ) : boolean {
451- // eslint-disable-next-line @typescript-eslint/no-explicit-any
452- const templater = ( this . plugin . app as any ) . plugins ?. plugins ?. [
453- "templater-obsidian"
454- ] ;
466+ const templater = ( this . plugin . app as unknown as AppWithPlugins ) . plugins
467+ ?. plugins ?. [ "templater-obsidian" ] as Record < string , unknown > | undefined ;
455468 if ( ! templater ) return false ;
456- const fileTemplates = templater . settings ?. file_templates ;
469+ const settings = templater . settings as Record < string , unknown > | undefined ;
470+ const fileTemplates = settings ?. file_templates ;
457471 if ( ! Array . isArray ( fileTemplates ) ) return false ;
458472
459473 for ( const ft of fileTemplates ) {
@@ -520,8 +534,9 @@ export class FileCreationCoordinator {
520534 } , remainingTime ) ;
521535
522536 // Listen for Templater event
523- // eslint-disable-next-line @typescript-eslint/no-explicit-any
524- const eventRef = ( this . plugin . app . workspace as any ) . on (
537+ const eventRef = (
538+ this . plugin . app . workspace as unknown as WorkspaceWithCustomEvents
539+ ) . on (
525540 "templater:new-note-from-template" ,
526541 ( data : Record < string , unknown > ) => {
527542 if (
0 commit comments