BiomeのnoDuplicateObjectKeysはJSとJson両方見てくれる
- publishedAt:
- 2024/12/24
- updatedAt:
- 2024/12/24
2024年 ユウトの一人アドベントカレンダーの24日目の記事です。
Intro
Details
BiomeのRecommend Ruleを眺めていたところ、noDuplicateObjectKeys
の項目が二つ存在していることに気づきました。

これを見た瞬間は、記載ミスかなと思い、修正PRを出そうとしていました。
ちなみにbiomeのドキュメントサイトは本体ではなく、biomejs/websiteというリポジトリになっています。
そして面白いのが、ルールに関しては実際のコードベースから自動生成されて作られているようです。
# Don't modify this file manually. This file is auto generated from source,
and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.
さて、本題に戻ると、noDuplicateObjectKeysが二つ存在するのは仕様です。 これは、JSとJsonの両方でduplicate keyを見てくれるからだそうです。
// invalid
const obj = {
a: 1,
a: 2,
}
// invalid
{
"title": "New title",
"title": "Second title"
}
まとめ
初見で見るとミスだと思ってしまう可能性結構高そうな内容でした。 ルール自体はめっちゃ便利なので好きです。
BiomeのnoDuplicateObjectKeysはJSとJson両方見てくれる
- publishedAt:
- 2024/12/24
- updatedAt:
- 2024/12/24
0