mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-19 01:26:29 +03:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user