pub fn check_classes(program: &Program, diags: &mut Diagnostics)Expand description
Warn about a class that is one slip away from a utility.
docs/104 §104.4: “a
misspelling is a diagnostic. rounded-ful gets a B0… with a did-you-mean, because
Levenshtein over a known table is what the compiler already does for field names. This is the
whole difference between Tailwind and a language that absorbed it.”
§Why it is a warning and not an error
The class vocabulary is open, which is what makes this different from B0217 and B0218
one file over: every attribute must be an HTML attribute, and every event must be one the
client listens for, so an unknown one is wrong. An unknown class is not wrong — it is the
program’s own name, and this tree has eight of them. So the compiler cannot say “this is a
mistake”; it can only say “this is one edit from something that would have had a rule”, which
is a warning with a suggestion in it.
§The threshold, and the margin it has
Distance 1 always, and distance 2 from eight characters up. rounded-ful, bg-emerald-550,
text-4xxl, flexx, font-mediumm and justify-arround are all one edit from a real utility
and items-centre is two, so the misspellings are inside it. The other population is further
away than the rule needs: the nearest utility to any class this tree’s own programs write is
three edits — card to grid, here to h-px, mine to inline — so the rule has a
margin of one rather than sitting on the boundary.
style.rs::a_misspelled_utility_is_a_diagnostic asserts the margin rather than the
outcome, which is the difference between a gate that can fail and one that cannot: a family
added to the table that lands two edits from somebody’s own class name turns it red before
anybody’s build starts warning about a name they chose.