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를 쓰고 있습니다."
          )
        }
      }
    }
  }
}
Biome에 커스텀 룰을 적용한 모습
1

❤️

1 person reacted.

Hi, I'm who's behind Fedify, Hollo, BotKit, and this website, Hackers' Pub! My main account is at @hongminhee洪 民憙 (Hong Minhee) :nonbinary:.

Fedify, Hollo, BotKit, 그리고 보고 계신 이 사이트 Hackers' Pub을 만들고 있습니다. 제 메인 계정은: @hongminhee洪 民憙 (Hong Minhee) :nonbinary:.

FedifyHolloBotKit、そしてこのサイト、Hackers' Pubを作っています。私のメインアカウントは「@hongminhee洪 民憙 (Hong Minhee) :nonbinary:」に。