Skip to content

Prototype unknown and allowed CSS prefix checks - #35

Closed
gregjotau wants to merge 1 commit into
css-dead-checkfrom
wt-thim-unknown-css-prefix
Closed

Prototype unknown and allowed CSS prefix checks#35
gregjotau wants to merge 1 commit into
css-dead-checkfrom
wt-thim-unknown-css-prefix

Conversation

@gregjotau

Copy link
Copy Markdown
Contributor

Why

Unused CSS is only half the loop. A class in HTML that CSS never defines is a silent visual bug. Restricting which prefixes may appear on class also makes the check small enough to fail later.

Stacked on #34.

What

  • cssClassPrefixes (default r-, thim-): HTML class / th:class tokens with these prefixes must exist in first-party CSS, or they are reported as unknown
  • cssAllowedPrefixes (default empty / off): if set, any other class token is disallowed
  • failOnUnknownCss / failOnDisallowedCssPrefix default off
  • Standalone: --prefixes=r-,thim- --allowed=r-,wa-,htmx-

Unknown is taken only from HTML class attributes, so ids, custom elements (<r-date-picker>), CSS variables, and JS hook strings are not flagged.

thim {
    cssClassPrefixes.set(listOf("r-", "thim-"))
    cssAllowedPrefixes.set(listOf("r-", "wa-", "htmx-"))
    // failOnUnknownCss.set(true)
    // failOnDisallowedCssPrefix.set(true)
}

After adding the missing ReAI utilities, that app still has ~21 unknown r-* class attributes; those are hooks/component names, not utilities.

Report HTML class tokens that start with an owned prefix and have no
first-party rule. cssClassPrefixes defaults to r- and thim-; set
cssAllowedPrefixes to reject other prefixes. Fail flags stay off.
@gregjotau

Copy link
Copy Markdown
Contributor Author

Closing as superseded in part by #46. Exact dead-selector detection and exact runtime-class allowlisting shipped. Unknown-class/prefix enforcement is intentionally not included: consumer validation exposed legitimate generated/framework hook names and too many false positives for a strict default. That idea needs a semantic source-aware design before revival.

@gregjotau
gregjotau deleted the branch css-dead-check August 22, 2026 07:01
@gregjotau gregjotau closed this Aug 22, 2026
@gregjotau
gregjotau deleted the wt-thim-unknown-css-prefix branch August 22, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant