Skip to content

Commit

Permalink
fix(jsx-curly-braces): ignore values that require escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Feb 21, 2025
1 parent 7e361b3 commit 7b8c6e1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rules/jsx_curly_braces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ impl Handler for JSXCurlyBracesHandler {

if let JSXElementChild::JSXExprContainer(child_expr) = child {
if let JSXExpr::Expr(Expr::Lit(Lit::Str(lit_str))) = child_expr.expr {
// Ignore entities which would require escaping.
if lit_str.inner.value.contains('>')
|| lit_str.inner.value.contains('}')
{
continue;
}

// Allowed if this node is at the end of a line
// <div>{" "}
// </div>
Expand Down Expand Up @@ -174,6 +181,8 @@ mod tests {
foo{" "}
<span />
</div>"#,
r#"<div>foo{">"}</div>"#,
r#"<div>foo{"}"}</div>"#,
};
}

Expand Down

0 comments on commit 7b8c6e1

Please sign in to comment.