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

63 lines 2.59 kB
import { ValueObject } from "./ValueObject"; import { HARDCODE_TYPES } from "../../shared/constants/rules"; export type HardcodeType = (typeof HARDCODE_TYPES)[keyof typeof HARDCODE_TYPES]; export type ValueType = "email" | "url" | "ip_address" | "file_path" | "date" | "api_key" | "uuid" | "version" | "color" | "mac_address" | "base64" | "config" | "generic"; export type ValueImportance = "critical" | "high" | "medium" | "low"; export interface DuplicateLocation { file: string; line: number; } interface HardcodedValueProps { readonly value: string | number | boolean; readonly type: HardcodeType; readonly valueType?: ValueType; readonly line: number; readonly column: number; readonly context: string; readonly duplicateLocations?: DuplicateLocation[]; readonly withinFileUsageCount?: number; } /** * Represents a hardcoded value found in source code */ export declare class HardcodedValue extends ValueObject<HardcodedValueProps> { private constructor(); static create(value: string | number | boolean, type: HardcodeType, line: number, column: number, context: string, valueType?: ValueType, duplicateLocations?: DuplicateLocation[], withinFileUsageCount?: number): HardcodedValue; get value(): string | number | boolean; get type(): HardcodeType; get line(): number; get column(): number; get context(): string; get valueType(): ValueType | undefined; get duplicateLocations(): DuplicateLocation[] | undefined; get withinFileUsageCount(): number | undefined; hasDuplicates(): boolean; isAlmostConstant(): boolean; isMagicNumber(): boolean; isMagicString(): boolean; suggestConstantName(): string; private suggestNumberConstantName; private suggestStringConstantName; suggestLocation(currentLayer?: string): string; getDetailedSuggestion(currentLayer?: string): string; /** * Analyzes variable name and context to determine importance */ getImportance(): ValueImportance; /** * Checks if this violation should be skipped based on layer strictness * * Different layers have different tolerance levels: * - domain: strictest (no hardcoded values allowed) * - application: strict (only low importance allowed) * - infrastructure: moderate (low and some medium allowed) * - cli: lenient (UI constants allowed) */ shouldSkip(layer?: string): boolean; /** * Checks if this value is a UI-related constant */ private isUIConstant; } export {}; //# sourceMappingURL=HardcodedValue.d.ts.map