{ "$schema": "dss-knowledge-v1", "type": "coding_standards", "version": "1.0.0", "last_updated": "2025-12-08", "description": "Immutable coding best practices for all DSS code. These standards are enforced via pre-commit hooks and guide all code contributions.", "web_components": { "principle": "All UI components MUST be Web Components using Custom Elements API", "rules": [ { "id": "WC-001", "rule": "Shadow DOM Required", "requirement": "MUST use attachShadow({ mode: 'open' }) for all components", "exceptions": "None - this is non-negotiable for style encapsulation", "rationale": "Prevents global CSS pollution and ensures component isolation", "enforcement": "Pre-commit hook fails if component extends HTMLElement without Shadow DOM" }, { "id": "WC-002", "rule": "Lifecycle Management", "requirement": "MUST implement connectedCallback, disconnectedCallback, and attributeChangedCallback where appropriate", "pattern": "Always clean up event listeners and subscriptions in disconnectedCallback", "example": "disconnectedCallback() { if (this.unsubscribe) this.unsubscribe(); if (this.abortController) this.abortController.abort(); }" }, { "id": "WC-003", "rule": "Observable Attributes", "requirement": "Define observedAttributes static getter for reactive attributes", "pattern": "static get observedAttributes() { return ['title', 'value', 'color']; }", "rationale": "Enables reactive attribute changes without manual DOM manipulation" }, { "id": "WC-004", "rule": "Component Registration", "requirement": "Define custom element in component file using customElements.define()", "pattern": "customElements.define('ds-component-name', ComponentClass);", "naming": "All DSS components prefixed with 'ds-' to avoid conflicts" } ] }, "style_management": { "principle": "Zero inline styles policy - all styles in Shadow DOM or external stylesheets", "rules": [ { "id": "STYLE-001", "rule": "NO Inline Styles", "requirement": "FORBIDDEN: style=\"...\" attributes in templates", "exceptions": "ONLY dynamic computed values (e.g., transform: translateX(${x}px), width: ${percent}%)", "enforcement": "Pre-commit hook fails if >10 inline styles detected", "rationale": "Maintainability, separation of concerns, style encapsulation" }, { "id": "STYLE-002", "rule": "Shadow DOM Styles", "requirement": "All component styles in