Skip to main content

Module css_metrics

Module css_metrics 

Source
Expand description

Structural CSS analytics computed from the parsed CSS syntax tree.

fallow health consumes these on demand to surface specificity hotspots, !important density, over-complex selectors, and deep nesting: the kind of codebase-scale structural CSS slop that per-rule linters do not aggregate. The metrics come from the same lightningcss parse used for CSS Module class extraction. Callers gate by file extension: lightningcss parses standard CSS, not Sass, so .scss sources are NOT passed here (with error recovery on, Sass syntax recovers into a partial, inaccurate result rather than failing). A hard parse failure yields None.

Functionsยง

compute_css_analytics
Compute structural CSS analytics for a standard-CSS stylesheet source.
parse_css_color_rgb
Parse one CSS color value and return its sRGB channels when lightningcss can normalize it to RGB. Supports hex, named colors, rgb(), hsl(), and hwb().