Skip to content

Releases: sghani001/rails-css_unused

v0.2.1 — Smart dynamic class variable detection

02 Jun 00:15
bd8c889

Choose a tag to compare

What's new

Eliminates the most common source of false positives — CSS classes that are
assigned to a variable and rendered via <%= variable %> interpolation.

Two new detection rules

Rule 1 — Variable name heuristic: strings assigned to *_class, *_classes,
*_style, or *_css variables are automatically treated as CSS values.

Rule 2 — Hyphenated string heuristic: Ruby variable names cannot contain
hyphens, so any hyphenated quoted string is unambiguously a string value.

Example — now works without any ignore_patterns

<% status_class =
  if exam.cancelled?
    "status-cancelled"   # ✅ now detected as used
  elsif exam.approved?
    "status-approved"    # ✅ now detected as used
  end %>
<span class="<%= status_class %>">

Full changelog: CHANGELOG.md