Fix: skip border-accent-on-rounded on Tailwind spinners (#837)

The Tailwind matcher treated border-b-2 + rounded-full as a card accent, so the hook flagged the canonical animate-spin spinner. Exempt lines with animate-spin.

Written with AI assistance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-09-18 16:55:05 +05:00
co-authored by Cursor
parent f2c7051853
commit 9953435dda
+18 -1
View File
@@ -495,6 +495,7 @@ re!(
format!("border(?:Left|Right){WS}*[:=]{WS}*[\"'`]({D}+)px{WS}+solid")
);
re!(BORDER_ACCENT_TW_RE, format!("{B}border-[tb]-({D}+){B}"));
re!(ANIMATE_SPIN_RE, format!("{B}animate-spin{B}"));
re!(
BORDER_ACCENT_CSS_RE,
format!(
@@ -867,7 +868,7 @@ pub static REGEX_MATCHERS: Lazy<Vec<Matcher>> = Lazy::new(|| {
Matcher {
id: "border-accent-on-rounded",
find_all: |l| all(&BORDER_ACCENT_TW_RE, l),
test: |m, line| has_rounded(line) && num(m.g(1)) >= 1.0,
test: |m, line| has_rounded(line) && num(m.g(1)) >= 1.0 && !ANIMATE_SPIN_RE.is_match(line),
fmt: |m, _| m.whole().to_string(),
},
Matcher {
@@ -1457,6 +1458,22 @@ mod tests {
);
}
#[test]
fn border_accent_skips_tailwind_spinner() {
let g = |line: &str| run("border-accent-on-rounded", line);
assert_eq!(
g(r#"<div className="rounded-lg border-t-4 border-blue-500" />"#),
vec!["border-t-4"]
);
assert_eq!(
g(r#"<div className="rounded-full border-b-2" />"#),
vec!["border-b-2"]
);
assert!(g(r#"<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-accent" />"#).is_empty());
assert!(g(r#"<div className="sm:animate-spin rounded-full h-8 w-8 border-t-2" />"#).is_empty());
assert!(g(r#"<div className="motion-safe:animate-spin rounded-full border-b-2" />"#).is_empty());
}
#[test]
fn dashes() {
assert_eq!(count_em_dashes("a — b -- c ---d"), 2);