Prototype unknown and allowed CSS prefix checks - #35
Closed
gregjotau wants to merge 1 commit into
Closed
Conversation
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
classalso makes the check small enough to fail later.Stacked on #34.
What
cssClassPrefixes(defaultr-,thim-): HTMLclass/th:classtokens with these prefixes must exist in first-party CSS, or they are reported as unknowncssAllowedPrefixes(default empty / off): if set, any other class token is disallowedfailOnUnknownCss/failOnDisallowedCssPrefixdefault off--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.