ursamu-mud
Version:
Ursamu - Modular MUD Engine with sandboxed scripting and plugin system
109 lines (108 loc) • 2.41 kB
TypeScript
/**
* Script validation and linting
*/
interface ValidationResult {
valid: boolean;
errors: string[];
warnings: string[];
metrics?: ValidationMetrics;
}
interface ValidationMetrics {
lines: number;
functions: number;
variables: number;
dependencies: number;
complexity: number;
}
interface ValidationOptions {
strict?: boolean;
checkDependencies?: boolean;
scriptPath?: string;
maxComplexity?: number;
maxLines?: number;
}
export declare class ScriptValidator {
private config;
constructor(config: any);
/**
* Validate script content
*/
validate(scriptContent: string, options?: ValidationOptions): Promise<ValidationResult>;
/**
* Validate basic JavaScript/TypeScript syntax
*/
private validateSyntax;
/**
* Validate script structure and required exports
*/
private validateStructure;
/**
* Validate security aspects of the script
*/
private validateSecurity;
/**
* Validate performance aspects
*/
private validatePerformance;
/**
* Validate script dependencies
*/
private validateDependencies;
/**
* Strict mode validations
*/
private validateStrict;
/**
* Calculate script metrics
*/
private calculateMetrics;
/**
* Remove comments from content for parsing
*/
private removeComments;
/**
* Check for balanced braces
*/
private checkBraces;
/**
* Check for balanced parentheses
*/
private checkParentheses;
/**
* Check for balanced quotes
*/
private checkQuotes;
/**
* Check semicolon usage
*/
private checkSemicolons;
/**
* Check if line should have semicolon
*/
private shouldHaveSemicolon;
/**
* Extract functions from content
*/
private extractFunctions;
/**
* Extract function body
*/
private extractFunctionBody;
/**
* Calculate cyclomatic complexity for a function
*/
private calculateCyclomaticComplexity;
/**
* Calculate overall script complexity
*/
private calculateOverallComplexity;
/**
* Find undeclared variables (simplified)
*/
private findUndeclaredVariables;
/**
* Validate dependency usage matches declarations
*/
private validateDependencyUsage;
}
export {};