/** * @angular-modernizer/plugin-angular - Service Injection Cleanup Rule */ import type { TransformRule, TransformContext, TransformResult } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; /** * Transform rule for cleaning up manual service instantiation. * * @remarks * This rule implements the {@link TransformRule} interface and serves as the * bridge between the Angular Modernizer's plugin system and the service * injection cleanup orchestrator. It follows the "Thin Rule, Thick Orchestrator" pattern * where the rule handles protocol compliance while delegating all business logic * to the {@link ServiceInjectionCleanupOrchestrator}. * * ## What It Does * * The rule orchestrates the cleanup of: * - **Manual service instantiation**: Converts `new Service()` to `inject(Service)` * - **Constructor assignments**: Removes manual assignments in constructors * - **Property initializers**: Converts property initializers to inject() calls * - **Import management**: Adds `inject` import from `@angular/core` when needed * * ## Example Usage * * This rule is typically not used directly, but rather accessed through the * {@link AngularPlugin}: * * ```typescript * const plugin = new AngularPlugin(); * const rules = plugin.getTransformRules(); * const rule = rules.find(r => r.id === 'angular:transform:service-injection-cleanup'); * const result = await rule.transform(context); * ``` * * ## Transformation Behavior * * **Service Instantiation Cleanup**: * ```typescript * // Before * export class MyComponent { * private http = new HttpClient(); * * constructor() { * this.http = new HttpClient(); * } * } * * // After * export class MyComponent { * private http = inject(HttpClient); * } * ``` * * @see {@link ServiceInjectionCleanupOrchestrator} for transformation logic * @see {@link TransformRule} for the interface contract * @see {@link AngularPlugin} for plugin integration * * @public */ export declare class ServiceInjectionCleanupRule implements TransformRule { /** * Unique rule identifier. * Format: "plugin-name:rule-name" */ readonly id = "angular:transform:service-injection-cleanup"; /** * Human-readable rule name. */ readonly name = "Service Injection Cleanup"; /** * Rule description. */ readonly description = "Clean up manual service instantiation and ensure proper dependency injection patterns"; /** * Rule category for grouping. */ readonly category = "transform"; /** * Tags for filtering and search. */ readonly tags: string[]; /** * The orchestrator that performs the actual transformation. */ private readonly orchestrator; /** * Transform a source file by cleaning up manual service instantiation. * * @remarks * This method implements the {@link TransformRule.transform} contract. * It delegates to the {@link ServiceInjectionCleanupOrchestrator} for the actual * transformation work, then packages the result into a {@link TransformResult}. * * The method: * 1. Captures the file's initial state * 2. Invokes the orchestrator to perform the cleanup * 3. Detects whether the file was modified * 4. Returns a standardized {@link TransformResult} * * ## Return Value * * The transform result includes: * - `modified`: Whether the file was changed * - `message`: A human-readable summary * - `filePath`: The path to the transformed file * - `ruleId`: This rule's identifier * * @param context - Transform context with file, project, and API access * * @returns Promise resolving to the transformation result * * @example * ```typescript * const rule = new ServiceInjectionCleanupRule(); * const result = await rule.transform(context); * * if (result.modified) { * console.info(`Cleaned up service injection: ${result.filePath}`); * } * ``` * * @public */ transform(context: TransformContext): Promise; } //# sourceMappingURL=service-injection-cleanup.rule.d.ts.map