80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
/**
|
|
* Type definitions for @dss/rules
|
|
*/
|
|
|
|
export interface Rule {
|
|
id: string;
|
|
name: string;
|
|
description?: string;
|
|
severity?: 'error' | 'warning' | 'info';
|
|
wcag?: string;
|
|
patterns?: {
|
|
forbidden?: string[];
|
|
allowed?: string[];
|
|
};
|
|
validation?: Record<string, unknown>;
|
|
exceptions?: string[];
|
|
guidelines?: string[];
|
|
components?: Record<string, unknown>;
|
|
}
|
|
|
|
export interface RuleSet {
|
|
id: string;
|
|
version: string;
|
|
name: string;
|
|
description?: string;
|
|
category: 'tokens' | 'components' | 'accessibility' | 'patterns' | 'naming';
|
|
severity?: 'error' | 'warning' | 'info';
|
|
rules: Rule[];
|
|
tokens?: {
|
|
required?: string[];
|
|
optional?: string[];
|
|
scale?: Record<string, string>;
|
|
};
|
|
components?: Record<string, unknown>;
|
|
compliance?: Record<string, unknown>;
|
|
adoption?: {
|
|
thresholds?: {
|
|
minimum?: number;
|
|
target?: number;
|
|
excellent?: number;
|
|
};
|
|
metrics?: string[];
|
|
};
|
|
}
|
|
|
|
export interface ValidationResult {
|
|
valid: boolean;
|
|
violations: Violation[];
|
|
error?: string;
|
|
}
|
|
|
|
export interface Violation {
|
|
rule: string;
|
|
pattern: string;
|
|
matches: string[];
|
|
severity: 'error' | 'warning' | 'info';
|
|
message: string;
|
|
}
|
|
|
|
export interface CIConfig {
|
|
version: string;
|
|
categories: string[];
|
|
errorSeverities: string[];
|
|
warningSeverities: string[];
|
|
blockingRules: string[];
|
|
advisoryRules: string[];
|
|
}
|
|
|
|
export const CATEGORIES: string[];
|
|
|
|
export function loadRules(): Record<string, RuleSet | null>;
|
|
export function getRulesByCategory(category: string): RuleSet | null;
|
|
export function getAllRuleIds(): string[];
|
|
export function getRule(ruleId: string): Rule | null;
|
|
export function validateValue(ruleId: string, value: string): ValidationResult;
|
|
export function getRuleSeverity(ruleId: string): 'error' | 'warning' | 'info';
|
|
export function getRequiredTokens(): Record<string, string[]>;
|
|
export function getVersion(): string;
|
|
export function getCIConfig(): CIConfig;
|