From 9953435dda1beb1b3a99e5c7467e9a26c9c77b30 Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Fri, 18 Sep 2026 16:55:05 +0500 Subject: [PATCH] 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 --- crates/detect/src/regex_matchers.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/detect/src/regex_matchers.rs b/crates/detect/src/regex_matchers.rs index 514541ce7..630207454 100644 --- a/crates/detect/src/regex_matchers.rs +++ b/crates/detect/src/regex_matchers.rs @@ -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> = 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#"
"#), + vec!["border-t-4"] + ); + assert_eq!( + g(r#"
"#), + vec!["border-b-2"] + ); + assert!(g(r#"
"#).is_empty()); + assert!(g(r#"
"#).is_empty()); + assert!(g(r#"
"#).is_empty()); + } + #[test] fn dashes() { assert_eq!(count_em_dashes("a — b -- c ---d"), 2);