ast-grep 알듯 모를듯.. 아래같이 하면 innerHTML prop를 넘겨주고, 여닫는 사이에 내용은 없지만 self-closing 안 하는 케이스들을 잡을 수 있겠다.
id: innerhtml-not-self-closed
language: tsx
severity: error
rule:
all:
- kind: jsx_element
pattern: <$TAG $$$ARGS></$TAG>
all:
- has:
kind: jsx_opening_element
has:
kind: jsx_attribute
regex: innerHTML
- has:
kind: jsx_closing_element
fix: "<$TAG $$$ARGS />"