mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
Add @puaros/guardian package v0.1.0 - code quality guardian for vibe coders and enterprise teams. Features: - Hardcode detection (magic numbers, magic strings) - Circular dependency detection - Naming convention enforcement (Clean Architecture) - Architecture violation detection - CLI tool with comprehensive reporting - 159 tests with 80%+ coverage - Smart suggestions for fixes - Built for AI-assisted development Built with Clean Architecture and DDD principles. Works with Claude, GPT, Copilot, Cursor, and any AI coding assistant.
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
/**
|
|
* BAD EXAMPLE: Framework Leak in Domain Layer
|
|
*
|
|
* Guardian should detect:
|
|
* ❌ Prisma import in domain layer
|
|
* ❌ Framework dependency in domain
|
|
*
|
|
* Why bad:
|
|
* - Domain coupled to infrastructure
|
|
* - Hard to test
|
|
* - Can't change DB without changing domain
|
|
* - Violates Dependency Inversion Principle
|
|
* - Violates Clean Architecture
|
|
*/
|
|
|
|
// ❌ BAD: Framework in domain!
|
|
import { PrismaClient } from "@prisma/client"
|
|
|
|
export class UserEntity {
|
|
constructor(
|
|
public id: string,
|
|
public email: string,
|
|
private readonly prisma: PrismaClient,
|
|
) {}
|
|
|
|
public async save(): Promise<void> {
|
|
await this.prisma.user.create({
|
|
data: {
|
|
id: this.id,
|
|
email: this.email,
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ✅ GOOD VERSION:
|
|
*
|
|
* // domain/entities/User.ts - NO framework imports!
|
|
* export class User {
|
|
* constructor(
|
|
* private readonly id: UserId,
|
|
* private readonly email: Email,
|
|
* ) {}
|
|
*
|
|
* // No persistence logic here
|
|
* }
|
|
*
|
|
* // domain/repositories/IUserRepository.ts
|
|
* export interface IUserRepository {
|
|
* save(user: User): Promise<void>
|
|
* }
|
|
*
|
|
* // infrastructure/repositories/PrismaUserRepository.ts
|
|
* export class PrismaUserRepository implements IUserRepository {
|
|
* constructor(private readonly prisma: PrismaClient) {}
|
|
*
|
|
* async save(user: User): Promise<void> {
|
|
* // Prisma code here
|
|
* }
|
|
* }
|
|
*/
|