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

123 lines 4.57 kB
"use strict"; /** * Naming Convention Detector Constants * * Following Clean Code principles: * - No magic strings * - Single source of truth * - Easy to maintain */ Object.defineProperty(exports, "__esModule", { value: true }); exports.REPOSITORY_METHOD_SUGGESTIONS = exports.DDD_FOLDER_NAMES = exports.NAMING_ERROR_MESSAGES = exports.PATTERN_WORDS = exports.PATH_PATTERNS = exports.FILE_SUFFIXES = exports.EXCLUDED_FILES = void 0; /** * Files to exclude from naming convention checks */ exports.EXCLUDED_FILES = [ "index.ts", "BaseUseCase.ts", "BaseMapper.ts", "IBaseRepository.ts", "BaseEntity.ts", "ValueObject.ts", "BaseRepository.ts", "BaseError.ts", "DomainEvent.ts", "Suggestions.ts", ]; /** * File suffixes for pattern matching */ exports.FILE_SUFFIXES = { SERVICE: "Service.ts", DTO: "Dto.ts", REQUEST: "Request.ts", RESPONSE: "Response.ts", MAPPER: "Mapper.ts", CONTROLLER: "Controller.ts", REPOSITORY: "Repository.ts", ADAPTER: "Adapter.ts", }; /** * Path patterns for detection */ exports.PATH_PATTERNS = { USE_CASES: "/use-cases/", USE_CASES_ALT: "/usecases/", }; /** * Common words for pattern matching */ exports.PATTERN_WORDS = { REPOSITORY: "Repository", I_PREFIX: "I", }; /** * Error messages for naming violations */ exports.NAMING_ERROR_MESSAGES = { DOMAIN_FORBIDDEN: "Domain layer should not contain DTOs, Controllers, or Request/Response objects", USE_PASCAL_CASE: "Use PascalCase noun (e.g., User.ts, Order.ts, Email.ts)", USE_DTO_SUFFIX: "Use *Dto, *Request, or *Response suffix (e.g., UserResponseDto.ts)", USE_VERB_NOUN: "Use verb + noun in PascalCase (e.g., CreateUser.ts, UpdateProfile.ts)", USE_CASE_START_VERB: "Use cases should start with a verb", DOMAIN_SERVICE_PASCAL_CASE: "Domain services must be PascalCase ending with 'Service'", DOMAIN_ENTITY_PASCAL_CASE: "Domain entities must be PascalCase nouns", DTO_PASCAL_CASE: "DTOs must be PascalCase ending with 'Dto', 'Request', or 'Response'", MAPPER_PASCAL_CASE: "Mappers must be PascalCase ending with 'Mapper'", USE_CASE_VERB_NOUN: "Use cases must be PascalCase Verb+Noun (e.g., CreateUser)", CONTROLLER_PASCAL_CASE: "Controllers must be PascalCase ending with 'Controller'", REPOSITORY_IMPL_PASCAL_CASE: "Repository implementations must be PascalCase ending with 'Repository'", SERVICE_ADAPTER_PASCAL_CASE: "Services/Adapters must be PascalCase ending with 'Service' or 'Adapter'", FUNCTION_CAMEL_CASE: "Functions and methods must be camelCase", USE_CAMEL_CASE_FUNCTION: "Use camelCase for function names (e.g., getUserById, createOrder)", INTERFACE_PASCAL_CASE: "Interfaces must be PascalCase", USE_PASCAL_CASE_INTERFACE: "Use PascalCase for interface names", REPOSITORY_INTERFACE_I_PREFIX: "Domain repository interfaces must start with 'I' (e.g., IUserRepository)", REPOSITORY_INTERFACE_PATTERN: "Repository interfaces must be I + PascalCase + Repository", CONSTANT_UPPER_SNAKE_CASE: "Exported constants must be UPPER_SNAKE_CASE", USE_UPPER_SNAKE_CASE_CONSTANT: "Use UPPER_SNAKE_CASE for constant names (e.g., MAX_RETRIES, API_URL)", VARIABLE_CAMEL_CASE: "Variables must be camelCase", USE_CAMEL_CASE_VARIABLE: "Use camelCase for variable names (e.g., userId, orderList)", }; /** * DDD folder names for aggregate boundary detection */ exports.DDD_FOLDER_NAMES = { ENTITIES: "entities", AGGREGATES: "aggregates", VALUE_OBJECTS: "value-objects", VO: "vo", EVENTS: "events", DOMAIN_EVENTS: "domain-events", REPOSITORIES: "repositories", SERVICES: "services", SPECIFICATIONS: "specifications", DOMAIN: "domain", CONSTANTS: "constants", SHARED: "shared", FACTORIES: "factories", PORTS: "ports", INTERFACES: "interfaces", ERRORS: "errors", EXCEPTIONS: "exceptions", }; /** * Repository method suggestions for domain language */ exports.REPOSITORY_METHOD_SUGGESTIONS = { SEARCH: "search", FIND_BY_PROPERTY: "findBy[Property]", GET_ENTITY: "get[Entity]", CREATE: "create", ADD_ENTITY: "add[Entity]", STORE_ENTITY: "store[Entity]", UPDATE: "update", MODIFY_ENTITY: "modify[Entity]", SAVE: "save", DELETE: "delete", REMOVE_BY_PROPERTY: "removeBy[Property]", FIND_ALL: "findAll", LIST_ALL: "listAll", DEFAULT_SUGGESTION: "Use domain-specific names like: findBy[Property], save, create, delete, update, add[Entity]", }; //# sourceMappingURL=detectorPatterns.js.map