/** * @angular-modernizer/plugin-angular - Unnecessary Change Detection Rule * * Detects Angular components using Default change detection unnecessarily. * Components should use OnPush change detection when possible for better performance. * * Detection Patterns: * - Components with @Input properties using Default change detection * - Components with complex logic using Default change detection * - Components that could benefit from OnPush but don't use it * * This rule promotes better performance by encouraging OnPush change detection. */ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system'; /** * Unnecessary Change Detection Rule - detects components using Default CD unnecessarily. */ export declare class UnnecessaryChangeDetectionRule implements AnalysisRule { readonly id = "angular:unnecessary-change-detection"; readonly name = "Unnecessary Change Detection"; readonly description = "Detects Angular components using Default change detection unnecessarily"; readonly severity = "warning"; readonly category = "angular-performance"; readonly tags: string[]; analyze(context: AnalysisContext): Promise; /** * Analyzes a single class declaration for unnecessary change detection violations. * @param classDecl - The class declaration to analyze. * @param filePath - The file path of the source file. * @returns An analysis result if a violation is found, null otherwise. */ private analyzeClass; /** * Detects components that call `ChangeDetectorRef.detectChanges()` but do NOT * use `ChangeDetectionStrategy.OnPush`. * * Without OnPush, the whole component tree is already re-rendered on every * event. Calling `detectChanges()` additionally is wasteful and suggests a * misunderstanding of Angular's change detection model. * * violationType: `detectchanges-without-onpush` */ private analyzeDetectChangesWithoutOnPush; /** * Gets the @Component decorator from a class declaration. * @param classDecl - The class declaration to check. * @returns The Component decorator if found, undefined otherwise. */ private getComponentDecorator; /** * Checks if a component decorator already uses OnPush change detection. * @param componentDecorator - The Component decorator to check. * @returns True if OnPush is already configured, false otherwise. */ private usesOnPush; /** * Determines if a component should use OnPush change detection. * @param classDecl - The class declaration to analyze. * @returns True if the component should use OnPush, false otherwise. */ private shouldUseOnPush; /** * Checks if a class has @Input properties. * @param classDecl - The class declaration to check. * @returns True if the class has Input properties, false otherwise. */ private hasInputProperties; /** * Checks if a class has complex logic that would benefit from OnPush. * @param classDecl - The class declaration to check. * @returns True if the class has complex logic, false otherwise. */ private hasComplexLogic; } //# sourceMappingURL=angular-unnecessary-change-detection.rule.d.ts.map