UNPKG

@samiyev/guardian

Version:

Research-backed code quality guardian for AI-assisted development. Detects hardcodes, secrets, circular deps, framework leaks, entity exposure, and 9 architecture violations. Enforces Clean Architecture/DDD principles. Works with GitHub Copilot, Cursor, W

59 lines 2.33 kB
import { IFrameworkLeakDetector } from "../../domain/services/IFrameworkLeakDetector"; import { FrameworkLeak } from "../../domain/value-objects/FrameworkLeak"; /** * Detects framework-specific imports in domain layer * * This detector identifies violations where domain layer files import framework-specific packages, * which creates tight coupling and violates Clean Architecture principles. * * The domain layer should only contain business logic and domain interfaces. * Framework implementations should be in the infrastructure layer. * * @example * ```typescript * const detector = new FrameworkLeakDetector() * * // Detect leaks in a domain file * const imports = ['@prisma/client', 'express', '../entities/User'] * const leaks = detector.detectLeaks(imports, 'src/domain/User.ts', 'domain') * * // leaks will contain violations for '@prisma/client' and 'express' * console.log(leaks.length) // 2 * console.log(leaks[0].packageName) // '@prisma/client' * console.log(leaks[0].category) // 'ORM' * ``` */ export declare class FrameworkLeakDetector implements IFrameworkLeakDetector { private readonly frameworkPackages; constructor(); /** * Detects framework leaks in the given file * * @param imports - Array of import paths from the file * @param filePath - Path to the file being analyzed * @param layer - The architectural layer of the file (domain, application, infrastructure, shared) * @returns Array of detected framework leaks */ detectLeaks(imports: string[], filePath: string, layer: string | undefined): FrameworkLeak[]; /** * Checks if a specific import is a framework package * * @param importPath - The import path to check * @returns True if the import is a framework package */ isFrameworkPackage(importPath: string): boolean; /** * Gets the category of a framework package * * @param importPath - The import path to check * @returns The category name if it's a framework package, undefined otherwise */ private getFrameworkCategory; /** * Builds a map of framework packages to their categories * * @returns Map of package names to category names */ private buildFrameworkPackageMap; } //# sourceMappingURL=FrameworkLeakDetector.d.ts.map