@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
190 lines • 10.5 kB
TypeScript
/**
* Rule names for code analysis
*/
export declare const RULES: {
readonly CLEAN_ARCHITECTURE: "clean-architecture";
readonly HARDCODED_VALUE: "hardcoded-value";
readonly CIRCULAR_DEPENDENCY: "circular-dependency";
readonly NAMING_CONVENTION: "naming-convention";
readonly FRAMEWORK_LEAK: "framework-leak";
readonly ENTITY_EXPOSURE: "entity-exposure";
readonly DEPENDENCY_DIRECTION: "dependency-direction";
readonly REPOSITORY_PATTERN: "repository-pattern";
readonly AGGREGATE_BOUNDARY: "aggregate-boundary";
readonly SECRET_EXPOSURE: "secret-exposure";
readonly ANEMIC_MODEL: "anemic-model";
};
/**
* Hardcode types
*/
export declare const HARDCODE_TYPES: {
readonly MAGIC_NUMBER: "magic-number";
readonly MAGIC_STRING: "magic-string";
readonly MAGIC_BOOLEAN: "magic-boolean";
readonly MAGIC_CONFIG: "magic-config";
};
/**
* Layer names
*/
export declare const LAYERS: {
readonly DOMAIN: "domain";
readonly APPLICATION: "application";
readonly INFRASTRUCTURE: "infrastructure";
readonly SHARED: "shared";
};
/**
* Naming convention violation types
*/
export declare const NAMING_VIOLATION_TYPES: {
readonly WRONG_SUFFIX: "wrong-suffix";
readonly WRONG_PREFIX: "wrong-prefix";
readonly WRONG_CASE: "wrong-case";
readonly FORBIDDEN_PATTERN: "forbidden-pattern";
readonly WRONG_VERB_NOUN: "wrong-verb-noun";
};
/**
* Naming patterns for each layer
*/
export declare const NAMING_PATTERNS: {
readonly DOMAIN: {
readonly ENTITY: {
readonly pattern: RegExp;
readonly description: "PascalCase noun (User.ts, Order.ts)";
readonly forbidden: readonly ["Dto", "Request", "Response", "Controller"];
};
readonly SERVICE: {
readonly pattern: RegExp;
readonly description: "*Service suffix (UserService.ts)";
};
readonly VALUE_OBJECT: {
readonly pattern: RegExp;
readonly description: "PascalCase noun (Email.ts, Money.ts)";
};
readonly REPOSITORY_INTERFACE: {
readonly pattern: RegExp;
readonly description: "I*Repository prefix (IUserRepository.ts)";
};
};
readonly APPLICATION: {
readonly USE_CASE: {
readonly pattern: RegExp;
readonly description: "Verb in PascalCase (CreateUser.ts, UpdateProfile.ts)";
readonly examples: readonly ["CreateUser.ts", "UpdateProfile.ts", "DeleteOrder.ts"];
};
readonly DTO: {
readonly pattern: RegExp;
readonly description: "*Dto, *Request, *Response suffix";
readonly examples: readonly ["UserResponseDto.ts", "CreateUserRequest.ts"];
};
readonly MAPPER: {
readonly pattern: RegExp;
readonly description: "*Mapper suffix (UserMapper.ts)";
};
};
readonly INFRASTRUCTURE: {
readonly CONTROLLER: {
readonly pattern: RegExp;
readonly description: "*Controller suffix (UserController.ts)";
};
readonly REPOSITORY_IMPL: {
readonly pattern: RegExp;
readonly description: "*Repository suffix (PrismaUserRepository.ts, MongoUserRepository.ts)";
};
readonly SERVICE: {
readonly pattern: RegExp;
readonly description: "*Service or *Adapter suffix (EmailService.ts, S3StorageAdapter.ts)";
};
};
};
/**
* Common verbs for use cases
*/
export declare const USE_CASE_VERBS: readonly ["Aggregate", "Analyze", "Approve", "Authenticate", "Authorize", "Calculate", "Cancel", "Collect", "Confirm", "Create", "Delete", "Execute", "Export", "Fetch", "Find", "Generate", "Get", "Handle", "Import", "List", "Parse", "Place", "Process", "Register", "Reject", "Search", "Send", "Update", "Validate"];
/**
* Framework-specific packages that should not be imported in domain layer
* These frameworks create tight coupling and violate Clean Architecture principles
*/
export declare const FRAMEWORK_PACKAGES: {
readonly ORM: readonly ["@prisma/client", "prisma", "typeorm", "mongoose", "sequelize", "@mikro-orm/core", "@mikro-orm/mongodb", "@mikro-orm/postgresql", "drizzle-orm", "knex", "objection", "bookshelf", "waterline", "massive", "pg", "mysql", "mysql2", "sqlite3", "better-sqlite3", "mongodb", "monk", "tingodb", "nedb", "levelup", "cassandra-driver", "couchbase", "redis-om"];
readonly WEB_FRAMEWORK: readonly ["express", "fastify", "koa", "@koa/router", "koa-router", "@nestjs/common", "@nestjs/core", "@nestjs/platform-express", "@nestjs/platform-fastify", "hapi", "@hapi/hapi", "restify", "polka", "micro", "next", "nuxt", "sails", "adonis", "@adonisjs/core", "loopback", "@loopback/core", "feathers", "@feathersjs/feathers", "meteor", "strapi", "@strapi/strapi", "total.js", "actionhero"];
readonly HTTP_CLIENT: readonly ["axios", "node-fetch", "got", "superagent", "request", "request-promise", "request-promise-native", "needle", "bent", "phin", "ky", "undici", "@apollo/client", "graphql-request", "urql", "isomorphic-fetch", "cross-fetch", "fetch-retry", "wretch", "httpie"];
readonly VALIDATION: readonly ["joi", "yup", "zod", "class-validator", "ajv", "validator", "express-validator", "celebrate", "superstruct", "io-ts", "runtypes", "valibot", "fastest-validator", "validatorjs", "vine", "@vinejs/vine", "vest", "json-schema", "jsonschema"];
readonly DI_CONTAINER: readonly ["inversify", "tsyringe", "awilix", "typedi", "bottlejs", "injection-js", "vue-di", "angular", "@angular/core", "di-ts", "power-di"];
readonly LOGGER: readonly ["winston", "pino", "bunyan", "log4js", "morgan", "signale", "consola", "roarr", "loglevel", "debug", "npmlog", "@nestjs/logger", "fancy-log", "tracer", "electron-log", "simple-node-logger"];
readonly CACHE: readonly ["redis", "ioredis", "memcached", "node-cache", "cache-manager", "keyv", "flat-cache", "lru-cache", "node-cache-manager", "quick-lru", "mem", "memoizee", "micro-memoize", "async-cache", "cacache"];
readonly MESSAGE_QUEUE: readonly ["amqplib", "bull", "bullmq", "bee-queue", "kafkajs", "rabbitmq", "amqp", "aws-sdk", "@aws-sdk/client-sqs", "@aws-sdk/client-sns", "@azure/service-bus", "azure-sb", "@google-cloud/pubsub", "rsmq", "mqtt", "rhea", "stompit", "activemq", "zeromq", "nanomsg", "kue", "agenda", "bree"];
readonly EMAIL: readonly ["nodemailer", "sendgrid", "@sendgrid/mail", "mailgun-js", "mailgun.js", "postmark", "sparkpost", "ses", "@aws-sdk/client-ses", "emailjs", "email-templates", "mjml", "pug", "handlebars", "sendmail", "smtp-server", "mailparser", "imap", "imap-simple"];
readonly STORAGE: readonly ["aws-sdk", "@aws-sdk/client-s3", "@aws-sdk/s3-request-presigner", "multer", "multer-s3", "@google-cloud/storage", "@azure/storage-blob", "azure-storage", "minio", "formidable", "busboy", "multiparty", "express-fileupload", "gridfs-stream", "s3-upload-stream", "knox", "pkgcloud", "@supabase/storage-js", "cloudinary"];
readonly TESTING: readonly ["jest", "@jest/globals", "mocha", "chai", "sinon", "supertest", "cypress", "@cypress/vue", "playwright", "@playwright/test", "vitest", "@vitest/ui", "ava", "tap", "tape", "jasmine", "@testing-library/react", "@testing-library/vue", "enzyme"];
readonly TEMPLATE_ENGINE: readonly ["ejs", "pug", "jade", "handlebars", "mustache", "nunjucks", "dot", "underscore", "lodash.template", "hogan.js", "swig", "twig", "marko", "squirrelly", "eta"];
};
/**
* Error messages for framework leak violations
*/
export declare const FRAMEWORK_LEAK_MESSAGES: {
readonly DOMAIN_IMPORT: "Domain layer imports framework-specific package \"{package}\". Use interfaces and dependency injection instead.";
readonly SUGGESTION: "Create an interface in domain layer and implement it in infrastructure layer.";
readonly PACKAGE_PLACEHOLDER: "{package}";
};
/**
* Repository pattern violation types
*/
export declare const REPOSITORY_VIOLATION_TYPES: {
readonly ORM_TYPE_IN_INTERFACE: "orm-type-in-interface";
readonly CONCRETE_REPOSITORY_IN_USE_CASE: "concrete-repository-in-use-case";
readonly NEW_REPOSITORY_IN_USE_CASE: "new-repository-in-use-case";
readonly NON_DOMAIN_METHOD_NAME: "non-domain-method-name";
};
/**
* Detection patterns for sensitive keywords
*/
export declare const DETECTION_PATTERNS: {
readonly SENSITIVE_KEYWORDS: readonly ["password", "secret", "token", "auth", "credential"];
readonly BUSINESS_KEYWORDS: readonly ["price", "salary", "balance", "amount", "limit", "threshold", "quota"];
readonly TECHNICAL_KEYWORDS: readonly ["timeout", "retry", "attempt", "maxretries", "database", "connection", "host", "port", "endpoint"];
readonly MEDIUM_KEYWORDS: readonly ["delay", "interval", "duration", "size", "count", "max", "min"];
readonly UI_KEYWORDS: readonly ["padding", "margin", "width", "height", "color", "style", "label", "title", "placeholder", "icon", "text", "display"];
};
/**
* Configuration detection keywords
*/
export declare const CONFIG_KEYWORDS: {
readonly NETWORK: readonly ["endpoint", "host", "domain", "path", "route"];
readonly DATABASE: readonly ["connection", "database"];
readonly SECURITY: readonly ["config", "secret", "token", "password", "credential"];
readonly MESSAGES: readonly ["message", "error", "warning", "text", "description", "suggestion", "violation", "expected", "actual"];
readonly TECHNICAL: readonly ["type", "node", "declaration", "definition", "signature", "pattern", "suffix", "prefix"];
};
/**
* Detection comparison values
*/
export declare const DETECTION_VALUES: {
readonly BOOLEAN_TRUE: "true";
readonly BOOLEAN_FALSE: "false";
readonly TYPE_CONFIG: "config";
readonly TYPE_GENERIC: "generic";
};
/**
* Boolean constants for analyzers
*/
export declare const ANALYZER_DEFAULTS: {
readonly HAS_ONLY_GETTERS_SETTERS: false;
readonly HAS_PUBLIC_SETTERS: false;
readonly HAS_BUSINESS_LOGIC: false;
};
/**
* Anemic model detection flags
*/
export declare const ANEMIC_MODEL_FLAGS: {
readonly HAS_ONLY_GETTERS_SETTERS_TRUE: true;
readonly HAS_ONLY_GETTERS_SETTERS_FALSE: false;
readonly HAS_PUBLIC_SETTERS_TRUE: true;
readonly HAS_PUBLIC_SETTERS_FALSE: false;
};
/**
* External package constants
*/
export declare const EXTERNAL_PACKAGES: {
readonly SECRETLINT_PRESET: "@secretlint/secretlint-rule-preset-recommend";
};
//# sourceMappingURL=rules.d.ts.map