Skip to content

Commit 6be29a0

Browse files
committed
chore: refine rtl semgrep, add space-x/ divide-x checks
1 parent e5fd49c commit 6be29a0

1 file changed

Lines changed: 39 additions & 15 deletions

File tree

.github/semgrep/tailwind-rtl.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
1-
# Local run: semgrep scan --config .github/semgrep/tailwind-rtl.yml --metrics off .
1+
# Local run: semgrep scan --config .github/semgrep/tailwind-rtl.yml
22
rules:
33
- id: tailwind-physical-class
44
message: |
55
RTL: replace physical Tailwind class with logical equivalent.
66
languages: [generic]
77
severity: WARNING
88
paths: { include: ["*.vue"] }
9-
pattern-regex: |
10-
(?x)
11-
(?:^|[\s'"`{(\[,]) !?(?:[a-z][a-z0-9-]*:)*-?
12-
(?:
13-
(?:scroll-)?[mp][lr]-(?:auto|px|full|\d+(?:[./]\d+)?|\[[^\]]+\])
14-
| (?:left|right)-(?:auto|px|full|\d+(?:[./]\d+)?|\[[^\]]+\])
15-
| text-(?:left|right)
16-
| float-(?:left|right)
17-
| clear-(?:left|right)
18-
| (?:border|rounded)-[lr](?:-[A-Za-z0-9\[\]./#%_-]+)?
19-
| rounded-(?:tl|tr|bl|br)(?:-[A-Za-z0-9\[\]./#%_-]+)?
20-
| space-x-(?:auto|px|reverse|\d+(?:[./]\d+)?|\[[^\]]+\])
21-
)
22-
!? (?=$|[\s'"`})\],>;])
9+
patterns:
10+
- pattern-either:
11+
- pattern-regex: |
12+
(?x)
13+
(?:^|[\s"'`(\[{,])
14+
!?
15+
(?:[^\s"':]+:)*
16+
-?
17+
(?:
18+
(?:scroll-)?[mp][lr]-(?:auto|px|full|\d+(?:[./]\d+)?|\[[^\]]+\])
19+
| (?:left|right)-(?:auto|px|full|\d+(?:[./]\d+)?|\[[^\]]+\])
20+
| (?:text|float|clear)-(?:left|right)
21+
| (?:border|rounded)-[lr](?:-[A-Za-z0-9\[\]./#%_-]+)?
22+
| rounded-(?:tl|tr|bl|br)(?:-[A-Za-z0-9\[\]./#%_-]+)?
23+
)
24+
!?
25+
(?=$|[\s'"`})\],>;])
26+
- pattern-not-regex: '\b(?:rtl|ltr):'
27+
28+
- id: tailwind-space-x-needs-reverse-or-gap
29+
message: |
30+
RTL: `space-x-*` does not flip in RTL. add `rtl:space-x-reverse` or `gap-x-* ms-*`
31+
languages: [generic]
32+
severity: WARNING
33+
paths: { include: ["*.vue"] }
34+
patterns:
35+
- pattern-regex: 'class\s*[:=]\s*"[^"]*\bspace-x-\S+[^"]*"'
36+
- pattern-not-regex: '\brtl:space-x-reverse\b'
37+
38+
- id: tailwind-divide-x-needs-reverse
39+
message: |
40+
RTL: `divide-x-*` does not flip in RTL, sdd `rtl:divide-x-reverse`.
41+
languages: [generic]
42+
severity: WARNING
43+
paths: { include: ["*.vue"] }
44+
patterns:
45+
- pattern-regex: 'class\s*[:=]\s*"[^"]*\bdivide-x(?:-\S+)?[^"]*"'
46+
- pattern-not-regex: '\brtl:divide-x-reverse\b'

0 commit comments

Comments
 (0)