/** * Universal Styles Analyzer — Spec 10 R3. * * Detects style fragmentation, value drift, token bypass, dead classes, * off-scale values, mechanism fragmentation, declaration-set similarity, * and z-index sprawl by querying the full style index (SQLite). * * Unlike other analyzers that process one AST at a time via analyzeAST(), * this analyzer queries the cross-file style_declarations table so it can * compute histograms, clusters, and distributions across the entire codebase. */ import { UniversalAnalyzer } from '../../languages/UniversalAnalyzer.js'; import type { AnalyzerResult, Violation } from '../../types.js'; import type { AST, LanguageAdapter } from '../../languages/types.js'; import type { StylesAnalyzerConfig } from '../../types.js'; export declare const DEFAULT_STYLES_CONFIG: StylesAnalyzerConfig; export declare class UniversalStylesAnalyzer extends UniversalAnalyzer { readonly name = "styles"; readonly description: string; readonly category = "style"; /** * Override analyze() to query the full style index in one pass instead * of per-file AST processing. The base class analyze() loop is bypassed. */ analyze(files: string[], config?: any, options?: any): Promise; /** Not used — we override analyze() directly. */ protected analyzeAST(_ast: AST, _adapter: LanguageAdapter, _config: any, _sourceCode: string): Promise; private queryDeclarations; private queryTokens; private queryClassUsage; /** * For each property with enough declarations, cluster values and flag * low-share stragglers (outliers) as style drift. * * - Colors: cluster by delta-E distance (< colorDeltaE). * - Non-colors: exact-value histogram; flag share < outlierMaxShare * when the mode count ≥ modeMinCount. */ private detectValueDrift; /** * Spec 22 R3.1 structural rule: a property whose observed values are all * keywords (non-numeric, non-color) is categorical regardless of the * hardcoded exclusion list. */ private isCategoricalByValues; private isColorProperty; /** * Color drift: cluster values by delta-E, flag stragglers. */ private detectColorDrift; /** * Exact-value drift for non-color properties. */ private detectExactValueDrift; /** * For scale-family properties (margin, padding, gap, font-size), * infer the project scale from modal values + Tailwind defaults, * and flag values that don't fit the scale. */ private detectOffScaleValues; /** * Infer the dominant scale step from a set of px values. * Uses the Tailwind scale as candidate steps. */ private inferScaleStep; /** * Flag CSS classes used in markup that have no matching definition in * any CSS/SCSS file. Files with unresolvable class usage are exempted. * * Uses compile-probe (Spec 22 R1.2): * 1. Init TailwindProbe against project's installed tailwindcss * 2. Collect all candidate class names * 3. Batch-probe unknown classes via @apply compilation * 4. Resolve each class from cache + structural patterns */ private detectUndefinedClasses; /** * Spec 22 Item 1 — Values so common that coincidental token-name matches * are always noise. Filtered before any token comparison. */ private static readonly TRIVIAL_VALUES; /** * Flag raw values that match a known design token's value but don't * reference the token via tokenRef. * * Exclusions (per Spec 22 R2): * - CSS custom-property definition sites (--x: ) — these are where * token values are allowed to be literal. Aliased tokens sharing a value * (e.g. --accent / --brand-action) produce zero findings. * - var(--token) references — tokenRef is already populated by the * style indexer; the existing token_ref check handles these. * * Token-bypass flags exactly one shape: a raw literal value (hex, rgb, * length) in a *usage* position whose normalized value matches a defined * token. */ private detectTokenBypass; /** Normalize a raw value for token-value comparison. */ private normalizeForTokenMatch; /** * Flag when the same (property, value) is applied via ≥3 different * mechanisms across the codebase, or when a single file/component * mixes ≥3 different mechanisms. */ private detectMechanismFragmentation; /** * Detect two rule blocks (contexts) whose declaration sets overlap at * ≥ similarityThreshold (default 0.9) and that each have ≥ minDeclarations. * This catches near-duplicate CSS rules that share most declarations. */ private detectDeclarationSetSimilarity; /** * Z-index sprawl: flag when there are too many distinct z-index values, * suggesting a lack of a z-index scale/system. */ private detectZIndexInventory; private makeViolation; /** Parse a CSS color string to [R, G, B] or null. */ private parseColorToRGB; /** Compute delta-E (CIE76) between two RGB colors. */ private deltaE; /** * Cluster colors by delta-E distance. * Simple greedy algorithm: each item joins the first cluster it's close enough to, * or starts a new cluster. */ private clusterByDeltaE; /** Parse a CSS length value to px-equivalent, or null if not parseable. */ private parseLengthToPx; } //# sourceMappingURL=UniversalStylesAnalyzer.d.ts.map