/** * @angular-modernizer/plugin-angular - Component Wrapper Instantiation Rule * * Detects direct `new X()` instantiation of wrapper or adapter classes * (identified by name patterns, explicit class names, base class inheritance, * or decorator presence) in Angular codebases. * * Direct instantiation of component-wrapper, DTO-wrapper, or adapter classes * breaks the Dependency Inversion Principle: callers take responsibility for * constructing the dependency rather than receiving it through Angular's DI. * * Detection scope: * - Tier 1 (fast, name-based): `classNamePatterns` and `explicitClassNames` * - Tier 2 (AST-based): `baseClassNames` and `decoratorNames` after import resolution * * Skipped: * - `.d.ts` declaration files. * - Classes in `excludedClassNames` (Angular framework Ref types by default). * * @example * ```typescript * const rule = new ComponentWrapperInstantiationRule(); * const results = await rule.analyze(createContext(sourceFile, project)); * // results[0].metadata.className → 'SomeRef' * // results[0].metadata.detectionTier → 1 * // results[0].metadata.detectionMechanism → 'classNamePattern' * ``` */ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system'; import { type TwoTierDetectorConfig } from '../utils/two-tier-instantiation-detector.js'; export interface ComponentWrapperInstantiationConfig extends TwoTierDetectorConfig { /** Class names excluded from detection regardless of pattern match. Defaults to Angular framework Ref types. */ excludedClassNames: string[]; } export interface ComponentWrapperInstantiationMetadata { violationType: 'component-wrapper-instantiation'; className: string; detectionTier: 1 | 2; detectionMechanism: 'classNamePattern' | 'explicitClassName' | 'baseClass' | 'decorator'; } export declare class ComponentWrapperInstantiationRule implements AnalysisRule { readonly id = "angular:component-wrapper-instantiation"; readonly name = "Component Wrapper Direct Instantiation"; readonly description = "Detects direct new X() instantiation of component-wrapper or adapter classes that should be injected via DI"; readonly severity: "warning"; readonly category = "angular-architecture"; readonly tags: string[]; private readonly config; private readonly detector; constructor(config?: Partial); analyze(context: AnalysisContext): Promise; /** * Extracts the class name from a `NewExpression`. * * Handles: * - Simple `new Foo()` → `'Foo'` * - Namespace `new ns.Foo()` → `'Foo'` (rightmost identifier) */ private extractClassName; } //# sourceMappingURL=component-wrapper-instantiation.rule.d.ts.map