Files
dss/packages/dss-rules/schemas/rule.schema.json
2025-12-11 08:03:47 -03:00

144 lines
3.9 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://dss.overbits.luz.uy/schemas/rule.schema.json",
"title": "DSS Rule Definition",
"description": "Schema for defining DSS design system rules",
"type": "object",
"required": ["id", "version", "name", "category", "rules"],
"properties": {
"$schema": {
"type": "string",
"description": "Reference to this schema"
},
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "Unique identifier for this rule set"
},
"version": {
"type": "string",
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
"description": "Semantic version of this rule set"
},
"name": {
"type": "string",
"description": "Human-readable name"
},
"description": {
"type": "string",
"description": "Detailed description of the rule set"
},
"category": {
"type": "string",
"enum": ["tokens", "components", "accessibility", "patterns", "naming"],
"description": "Category this rule set belongs to"
},
"severity": {
"type": "string",
"enum": ["error", "warning", "info"],
"default": "warning",
"description": "Default severity for rules in this set"
},
"rules": {
"type": "array",
"items": {
"$ref": "#/definitions/Rule"
},
"description": "Individual rules in this set"
},
"tokens": {
"type": "object",
"description": "Token requirements and definitions",
"properties": {
"required": {
"type": "array",
"items": { "type": "string" }
},
"optional": {
"type": "array",
"items": { "type": "string" }
},
"scale": {
"type": "object",
"additionalProperties": { "type": "string" }
}
}
},
"components": {
"type": "object",
"description": "Component requirements"
},
"compliance": {
"type": "object",
"description": "Compliance metadata"
},
"adoption": {
"type": "object",
"description": "Adoption threshold definitions"
}
},
"definitions": {
"Rule": {
"type": "object",
"required": ["id", "name"],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "Unique rule identifier"
},
"name": {
"type": "string",
"description": "Human-readable rule name"
},
"description": {
"type": "string",
"description": "What this rule checks for"
},
"severity": {
"type": "string",
"enum": ["error", "warning", "info"],
"description": "Rule severity (overrides set default)"
},
"wcag": {
"type": "string",
"description": "WCAG criterion reference if applicable"
},
"patterns": {
"type": "object",
"properties": {
"forbidden": {
"type": "array",
"items": { "type": "string" },
"description": "Regex patterns that violate this rule"
},
"allowed": {
"type": "array",
"items": { "type": "string" },
"description": "Regex patterns that satisfy this rule"
}
}
},
"validation": {
"type": "object",
"description": "Validation configuration"
},
"exceptions": {
"type": "array",
"items": { "type": "string" },
"description": "File patterns or values to exclude"
},
"guidelines": {
"type": "array",
"items": { "type": "string" },
"description": "Human-readable guidelines for this rule"
},
"components": {
"type": "object",
"description": "Component-specific rule configuration"
}
}
}
}
}