Skip to content

Commit

Permalink
feat: Support BinaryExpression (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedBaset authored Aug 6, 2024
2 parents 33c5235 + 7fb8f4f commit 869f772
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/quiet-toes-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-rtl-friendly": minor
---

feat: Support BinaryExpression `"..." + "..."`
6 changes: 6 additions & 0 deletions src/rules/no-phyisical-properties/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ tester.run("no-physical-properties", noPhysicalProperties, {
output: "<div className={`ps-1 extra-class me-2`} />",
errors: [{ messageId: NO_PHYSICAL_CLASSESS }],
},
{
name: `{"..." + "..."}`,
code: `<div className={"pl-2 " + "mr-1" + "text-left"} />`,
output: `<div className={"ps-2 " + "me-1" + "text-start"} />`,
errors: [{messageId: NO_PHYSICAL_CLASSESS}, {messageId: NO_PHYSICAL_CLASSESS}, {messageId: NO_PHYSICAL_CLASSESS}]
},
{
name: '{isCondition && "..."}',
code: `<div className={isCondition && "pl-1 text-right mr-2"} />`,
Expand Down
7 changes: 6 additions & 1 deletion src/utils/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@ function extractTokenFromExpression(
});
}

if (is(exp, "BinaryExpression")) {
const right = rerun(exp.right);
if (exp.left.type === "PrivateIdentifier") return right;
return [...right, ...rerun(exp.left)];
}

// if (
// is(exp, "BinaryExpression") ||
// is(exp, "Identifier") ||
// is(exp, "MemberExpression") ||
// is(exp, "TaggedTemplateExpression")
Expand Down

0 comments on commit 869f772

Please sign in to comment.