From 3950a8221d50480fa3e70bdf0630d46d7f53984f Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Thu, 10 Sep 2026 10:05:56 +0500 Subject: [PATCH] Fix: keep multiline JSX stripe-child matches (#394) A class-only line has no opening tag, so emptiness is unknown; still require a self-closing or empty tag when the tag is on this line. Prepared with AI assistance. Co-authored-by: Cursor --- crates/detect/src/regex_matchers.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/detect/src/regex_matchers.rs b/crates/detect/src/regex_matchers.rs index 1748f38db..fdbb80a29 100644 --- a/crates/detect/src/regex_matchers.rs +++ b/crates/detect/src/regex_matchers.rs @@ -191,17 +191,18 @@ fn is_self_closing_tag(tag: &str) -> bool { tag.trim_end_matches('>').trim_end().ends_with('/') } -/// Text path cannot see the DOM. Require an empty or self-closing tag so a -/// `w-1 bg-amber-500` wrapper with content is not reported as a stripe. +/// Text path cannot see the DOM. When this line holds a whole tag, require +/// it empty or self-closing. A class list with no `<` is a split JSX tag, +/// so emptiness is unknown and the other gates still apply. fn stripe_child_markup_empty(line: &str, index: usize) -> bool { let Some((start, end)) = markup_tag_span(line, index) else { - return false; + return true; }; if is_self_closing_tag(&line[start..end + 1]) { return true; } let rest = line.get(end + 1..).unwrap_or("").trim_start(); - rest.is_empty() || rest.starts_with("|"#).is_empty()); assert!(s(r#"
"#).is_empty()); + assert_eq!( + s(r#" className="w-1 shrink-0 rounded-l-lg bg-amber-500""#), + vec!["w-1 + bg-amber-500 stripe child"] + ); + assert!(s(r#"
"#).is_empty()); } #[test]