Skip to main content

Module css_classes

Module css_classes 

Source
Expand description

Markup CSS-class reference scanning and class-name similarity.

Supports the fallow health --css class-reach candidates (the CSS analogue of unresolved-import). scan_markup_class_tokens pulls the STATIC class tokens out of class / className attributes across every markup surface fallow visits (JSX/TSX, HTML, Vue/Svelte/Astro), and flags whether the file also constructs classes DYNAMICALLY (clsx(...), `btn-${x}`, :class, spread props), which downstream consumers use to abstain.

The scanner is intentionally regex-based and conservative: it only collects tokens from a fully-static quoted attribute value, and treats anything that could be an interpolation as a dynamic signal rather than a token. It never tries to evaluate a dynamic expression.

Structs§

MarkupClassScan
The result of scanning one markup source for class references.
MarkupClassToken
A static class token referenced in markup, with the 1-based line it sits on.

Functions§

is_edit_distance_one
True when a and b differ by exactly one single-character edit (one substitution, insertion, or deletion). Equal strings return false. Runs in O(min(len)) without building a full edit-distance matrix.
is_typo_edit
True when defined is a likely TYPO target for token: exactly one edit apart AND that edit is a believable mistake, not a deliberate naming variation. This is stricter than is_edit_distance_one because real codebases are full of one-edit class pairs that are NOT typos:
scan_markup_class_tokens
Scan a markup source for static class tokens and a dynamic-construction flag.