TIL: Biome은 자체적으로 만든 AST 쿼리 언어인 GritQL을 통해 Plugin 시스템을 제공한다. [문서]
language js
// 4개 이상의 서로 다른 useState를 사용하는 경우
or {
`function $name($args) { $body }`,
`$name = ($args) => { $body }`,
`$name = forwardRef(($args) => { $body })`,
`$name = React.forwardRef(($args) => { $body })`,
`$name = forwardRef(function($args) { $body })`,
`$name = React.forwardRef(function($args) { $body })`,
`$name = memo(($args) => { $body })`,
`$name = React.memo(($args) => { $body })`,
`$name = memo(function $name($args) { $body })`,
`$name = React.memo(function $name($args) { $body })`
} where {
$body <: contains `$t1 = useState($a1)` as $b1 where {
$body <: contains `$t2 = useState($a2)` as $b2 where {
or { not $a2 <: $a1, not $t2 <: $t1 },
$body <: contains `$t3 = useState($a3)` as $b3 where {
or { not $a3 <: $a1, not $t3 <: $t1 },
or { not $a3 <: $a2, not $t3 <: $t2 },
$body <: contains `$t4 = useState($a4)` as $b4 where {
or { not $a4 <: $a1, not $t4 <: $t1 },
or { not $a4 <: $a2, not $t4 <: $t2 },
or { not $a4 <: $a3, not $t4 <: $t3 },
register_diagnostic(
span = $name,
message = "컴포넌트 안에서 너무 많은 useState를 쓰고 있습니다."
)
}
}
}
}
}

