/** * @angular-modernizer/plugin-angular - Promise Cleanup Transform Rule * * Thin rule wrapper. All logic in PromiseCleanupTransformOrchestrator. */ import type { TransformRule, TransformContext, TransformResult, } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; import { PromiseCleanupTransformOrchestrator } from '../orchestrators/promise-cleanup-transform.orchestrator.js'; export class PromiseCleanupTransformRule implements TransformRule { public readonly id = 'angular:promise-cleanup'; public readonly name = 'Promise Cleanup Transform'; public readonly description = 'Removes residual Promise anti-patterns: orphaned .toPromise() calls and manual detectChanges() calls'; public readonly category = 'refactoring'; public readonly tags = [ 'angular', 'rxjs', 'observable', 'promise', 'cleanup', ]; private readonly orchestrator = new PromiseCleanupTransformOrchestrator(); async transform( context: TransformContext, ): Promise { const pluginConfig = context.config[ '@angular-modernizer/plugin-angular' ] as Record | undefined; if (pluginConfig?.['transformationType'] !== 'promise-cleanup') { return { ruleId: this.id, modified: false, message: 'Transformation type not applicable', filePath: context.filePath, }; } return this.orchestrator.run(context); } }