Biomeの推奨ルールを確認する方法

Biomeの推奨ルールを確認する方法

2025.07.28

はじめに

こんにちは。アノテーションの及川です。
Biomeのリンター(linter)の推奨ルールの設定方法と該当ルールが推奨ルールかどうかをコマンドから確認する方法について調べる機会があったので記載します。

Biome について

JavaScript、TypeScript、JSX、JSON、CSS、GraphQL に対応し、コードのフォーマットとリントを高速かつ統合的に提供するツールです。

詳細については、以下の公式ドキュメントをご参照ください。

https://biomejs.dev/ja/

推奨ルールについて

推奨ルールは、ベストプラクティスに基づいて選定された基本的なルールセットです。

https://biomejs.dev/ja/linter/

推奨ルールの設定方法

以下の Biome 公式サイトの「はじめる」より、linter.enabled: true によりリンターを有効にし、rules.recommended: true で推奨ルールを有効にします。

https://biomejs.dev/ja/guides/getting-started/

linter.enabled: true はリンタを有効にし、 rules.recommended: true は推奨ルールを有効にします。 これはデフォルトの設定と対応しています。

推奨ルールであるかをコマンドから確認する方法

以下の GitHub の Discussions や Biome 公式ドキュメントによると、biome explain <name_of_the_rule> コマンドで推奨ルールであるかどうかを確認することができます。

https://github.com/biomejs/biome/discussions/6178

The configuration_schema.json file that ships with Biome has tons of info on there for each rule. However, it doesn't include wether the rule is recommended or not. Is there some alternate source of truth for this as opposed to the web docs?

---

Use biome explain <name_of_the_rule>

https://biomejs.dev/reference/cli/#biome-explain

biome explain noDebugger

試してみた

下記のように出力結果の Summary セクションに This rule is recommended という行があることで、そのルールが推奨されていることが分かります。
(Summary と Description だけ抜粋して記載します。フルで確認されたい場合は、以下のコマンドを実行してお確かめください。)

推奨ルールである場合の出力例
% npx biome explain noUnusedVariables
Summary

- Name: noUnusedVariables
- Fix: unsafe
- Default severity: warn
- Available from version: 1.0.0
- Diagnostic category: lint/correctness/noUnusedVariables
- This rule is recommended

Description

 Disallow unused variables.

 There is an exception to this rule: variables that start with underscore, e.g. `let _something;`.

 The pattern of having an underscore as a prefix of a variable is a very diffuse
 pattern among programmers, and Biome follows it.

 This rule won't report unused imports.
 If you want to report unused imports,
 enable [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports/).

逆に推奨ルールでない場合は、下記の出力例のようになります。

推奨ルールでない場合の出力例
% npx biome explain noVar
Summary

- Name: noVar
- Fix: unsafe
- Default severity: warn
- Available from version: 1.0.0
- Diagnostic category: lint/suspicious/noVar

Description

 Disallow the use of `var`

 ECMAScript 6 allows programmers to create variables with block scope instead of function scope using the let and const keywords.

 Block scope is common in many other programming languages and helps programmers avoid mistakes.

まとめ

Biome のリンターの推奨設定であるかはこちらのように個別で調査すれば確認可能です。

一方で、コマンドの出力結果を活用すれば、Claude Code などの AI エージェント機能と組み合わせることで、
自分が記載した biome.json ファイルの設定を確認し、自動的に推奨かそうでないかを判別して、より必要最小限なルールに整理してくれそうだなと感じました。

この記事が誰かのお役に立てば幸いです。

アノテーション株式会社について

アノテーション株式会社はクラスメソッドグループのオペレーション専門特化企業です。サポート・運用・開発保守・情シス・バックオフィスの専門チームが、最新 IT テクノロジー、高い技術力、蓄積されたノウハウをフル活用し、お客様の課題解決を行っています。当社は様々な職種でメンバーを募集しています。「オペレーション・エクセレンス」と「らしく働く、らしく生きる」を共に実現するカルチャー・しくみ・働き方にご興味がある方は、アノテーション株式会社 採用サイトをぜひご覧ください。

参考資料

この記事をシェアする

facebookのロゴhatenaのロゴtwitterのロゴ

© Classmethod, Inc. All rights reserved.