Expand description
Dead scoped-CSS class detection for Vue/Svelte single-file components.
A class defined in a <style scoped> block applies only to its own
component’s markup (that is what scoped means), so a scoped class whose
name appears nowhere else in the same SFC is a cleanup candidate. The
“appears nowhere else” test is deliberately broad: any occurrence of the
class name as a whole token anywhere outside the <style> blocks (a static
class="...", a dynamic :class="{ name: x }" key, a class:name
directive, or even a string in <script>) counts as a use. That keeps the
signal conservative (it errs toward “used”), so it is reported as a candidate
rather than a hard dead-code finding.
Functions§
- scoped_
unused_ classes - Returns class names defined in
<style scoped>blocks of an SFC that appear nowhere else in the component (cleanup candidates), sorted. Returns an empty vec when the source has no analyzable scoped block. - sfc_
preprocessor_ virtual_ stylesheet - Build a virtual stylesheet from SFC preprocessor
<style>blocks that the health layer can conservatively lower before CSS analytics. - sfc_
virtual_ stylesheet - Build a “virtual stylesheet” from an SFC’s plain-CSS
<style>blocks (any scoping). Each block body is placed at its real line in the SFC via blank-line padding, so CSS metric line numbers fromcompute_css_analyticsmap straight back onto the SFC. ReturnsNonewhen the SFC has no plain-CSS<style>block (e.g. onlylang="scss"blocks, which the CSS parser cannot read), so callers run the standard.cssmetric path on Vue/Svelte component styles.