/** * @angular-modernizer/plugin-angular - Async Pipe Misuse Rule * * Detects incorrect usage of Angular's async pipe in inline templates. * * Detection Patterns: * - `double-async-subscription`: Observable property used with `| async` in * the template AND manually subscribed via `.subscribe()` in a lifecycle * hook — creates two subscriptions, one of which leaks. * - `multiple-async-subscriptions`: The same observable property appears with * `| async` two or more times in the same inline template — each occurrence * creates an independent subscription; use `*ngIf="obs$ | async as val"` or * `shareReplay(1)` instead. * * Only analyses inline `template:` strings — external `templateUrl:` files are * not parsed (no file system access at analysis time). */ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system'; /** * Async Pipe Misuse Rule. * * Rule ID: `angular:async-pipe-misuse` */ export declare class AsyncPipeMisuseRule implements AnalysisRule { readonly id = "angular:async-pipe-misuse"; readonly name = "Async Pipe Misuse"; readonly description = "Detects incorrect usage of Angular's async pipe in inline templates"; readonly severity: "warning"; readonly category = "angular-performance"; readonly tags: string[]; analyze(context: AnalysisContext): Promise; private analyzeClass; /** * Returns the @Component decorator or null if this is not a component class. */ private getComponentDecorator; /** * Extracts the value of the `template:` property from a @Component decorator. * Returns null when the template is external (templateUrl) or absent. */ private extractInlineTemplate; /** * Scans an inline template string for `propName | async` occurrences. * Returns a map from property name → occurrence count. */ private countAsyncPipeUsages; /** * Returns true if any lifecycle hook method body contains * `this..subscribe(`. */ private hasManualSubscribeInLifecycleHook; /** * Extracts the `templateUrl:` string value from a @Component decorator. * Returns null when the property is absent or not a simple string literal. */ private extractTemplateUrl; /** * Reads the external template file referenced by `templateUrl:`. * Resolves the URL relative to the source file's directory using posix * semantics (Angular always uses forward-slash paths). * Returns null when the file cannot be read (missing, permission error, etc.). */ private readTemplateFile; /** * Converts an observable property name like `user$` → `user` for use in * suggested fix messages. */ private toCamelCase; } //# sourceMappingURL=angular-async-pipe-misuse.rule.d.ts.map