Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/assist/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ First, you need to setup your editor for apply all fixes on save. The configurat

<EditorAction action="source.fixAll.biome" />

Then, you can add the code of each action. For example, the action [`useSortedKeys`](/assist/actions/use-sorted-keys) has a code action called `source.action.useSortedKeys.biome`. If you use VSCode, you can copy this code and place it in the `editor.codeActionsOnSave` section, and Biome will apply it when you save a document:
Then, you can add the code of each action. For example, the action [`useSortedKeys`](/assist/actions/use-sorted-keys) has a code action called `source.action.useSortedKeys.biome`. If you use VS Code, you can copy this code and place it in the `editor.codeActionsOnSave` section, and Biome will apply it when you save a document:

<EditorAction includeFixAll action="source.action.useSortedKeys.biome" />

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/guides/configure-biome.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,6 @@ The following files are parsed as `JSON` files with the options `json.parser.all
- `tsconfig.json`
- `typedoc.json`
- `typescript.json`
- All `.json` files under the `$PROJECT/.vscode/*` folder and under the [user VSCode settings folder](https://code.visualstudio.com/docs/configure/settings#_user-settingsjson-location)
- All `.json` files under the `$PROJECT/.vscode/*` folder and under the [user VS Code settings folder](https://code.visualstudio.com/docs/configure/settings#_user-settingsjson-location)
- All `.json` files under the `$PROJECT/.zed/*` folder and under the [user Zed settings folder](https://zed.dev/docs/configuring-zed#user-settings-file)
- All `.json` files under the `$PROJECT/.cursor/*` folder and under the user Cursor settings folder
4 changes: 2 additions & 2 deletions src/content/docs/internals/language-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Legend:
| [Markdown](https://github.com/biomejs/biome/issues/3718) | <span aria-label="In Progress" role="img">⌛️</span> | <span aria-label="In Progress" role="img">⌛️</span> | <span aria-label="Not in Progress" role="img">🚫</span> | <span aria-label="Not in Progress" role="img">🚫</span> |
| GritQL | <span aria-label="Supported" role="img">✅️</span> | <span aria-label="Supported" role="img">✅️</span> | <span aria-label="Not in Progress" role="img">🚫</span> | <span aria-label="Not in Progress" role="img">🚫</span> |

*\* currently requires [explicit opt-in](https://biomejs.dev/reference/configuration/#html)*
*\* currently requires [explicit opt-in](/reference/configuration/#html)*

## JavaScript support

Expand Down Expand Up @@ -56,7 +56,7 @@ This feature is still experimental and disabled by default. To enable this featu

## TypeScript support

Biome supports TypeScript version 5.6.
Biome supports TypeScript version 5.9.

## JSONC support

Expand Down
63 changes: 47 additions & 16 deletions src/content/docs/ja/assist/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,67 @@ description: Biomeのアシストについて

import NumberOfRules from "@/components/generated/assist/NumberOfRules.astro";
import PackageManagerBiomeCommand from "@/components/PackageManagerBiomeCommand.astro";
import EditorAction from "@/components/EditorAction.astro";

Biomeのアシストはユーザのコード品質とDXを向上するためのアクション(またはルール)を提供します
Biome Assistはコード品質と開発者体験を向上させるための一連のアクションを提供します

リンタのルールとは違い、アシストのアクションはエディタやIDE向けであり、プロパティおよびフィールドのソートや二項式の単純化といったものを含みます。アシストには **<NumberOfRules />つのアクション** があります.
リンターのルールとは異なり、アシストのアクションは常にコード修正を提供します。プロパティやフィールドのソート、二項式の単純化、リファクタリングなどを実行します。アシストのアクションはバグを検出したり、特定のコーディングスタイルを強制したりすることを目的としていません。現在 **<NumberOfRules />個のアシストアクション** が利用可能です。

アシストのアクションは [LSPのコードアクション](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) とよく似たセマンティクスを持ちます
アシストのコード修正は一般的に安全に適用できます。もしアシストの修正がコードを壊した場合、それはバグと見なされますので、バグ報告をお願いします

Biomeのアシストはデフォルトで有効になっています。以下の例では、アシストを有効にした上でアクション `useSortKeys` を有効にしています:
アシストはエディタやIDEで最も効果を発揮します。ただし、CLIでもアシストアクションの使用を強制することが可能です。アシストアクションはセマンティクスにおいて[LSPコードアクション](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind)に非常に近く、[グループ](#グループ)に分けられています。

Biomeのアシストはデフォルトで有効になっており、いくつかのルールは推奨ルールセットに含まれています。以下の例は `useSortedKeys` アクションを有効にする方法を示しています:

```json title="biome.json"
{
"assist": {
"enabled": true,
"actions": {
"source": {
"useSortedKeys": "on"
}
}
"assist": {
"enabled": true,
"actions": {
"source": {
"useSortedKeys": "on"
}
}
}
}
```

アシストのアクションはエディタに診断結果を表示 **しません**。しかし、以下の方法があります:
## IDEでアシストアクションを使用する

LSP互換のIDEを使用している場合、保存時に特定のアクションを実行するようにBiomeを設定できます。各アシストアクションには「コードアクション」と呼ばれる特定のコードがあります。大部分の名前は同じパターンに従っていますが、いくつかの例外があります(例:`organizeImports`)ので、コードを知るには各アクションのドキュメントページを参照してください。

まず、保存時にすべての修正を適用するようにエディタを設定する必要があります。設定はエディタによって異なります。コードアクション名は `source.fixAll.biome` です:

<EditorAction action="source.fixAll.biome" />

## CLIでアシストのアクションを強制する
次に、各アクションのコードを追加できます。たとえば、アクション [`useSortedKeys`](/assist/actions/use-sorted-keys) には `source.action.useSortedKeys.biome` というコードアクションがあります。VS Codeを使用している場合、このコードをコピーして `editor.codeActionsOnSave` セクションに配置すると、ドキュメントを保存したときにBiomeがアクションを適用します:

アシストのアクションはCLIの `check` コマンドで強制できます:
<EditorAction includeFixAll action="source.action.useSortedKeys.biome" />

## CLIでアシストアクションを強制する

アシストアクションは `check` コマンドを介してCLI経由で強制できます:

<PackageManagerBiomeCommand command="check" />

しかし、`check` は複数のツールを一度に実行するためのものであり、アシストのアクションのみを確認したい場合は以下を実行するべきです:
ただし、`check` は複数のツールを一度に実行するためのものなので、アシストアクションのみをチェックしたい場合は、次のように実行する必要があります:

<PackageManagerBiomeCommand command="check --formatter-enabled=false --linter-enabled=false" />

### アシストを強制しない

デフォルトでは、Biomeは `check` コマンドを実行するときにアシストを強制します。*アシストを強制したくない*場合は、`--enforce-assist` CLIフラグを `false` に使用できます。こうすることで、一部のアクションが適用されていない場合でもBiomeは診断エラーを出力しません:

```shell
biome check --enforce-assist=false
```

## アシストアクションの抑制

[抑制のページ](/ja/analyzer/suppressions)を参照してください。

## グループ

### Source

<PackageManagerBiomeCommand command="check --formatter-enabled=false --linter-enabled=false --organize-imports-enabled=false" />
このグループは、保存時にドキュメントに安全に適用できるアクションを表します。これらのアクションは一般的にすべて安全であり、通常はプログラムの機能を変更しません。
99 changes: 72 additions & 27 deletions src/content/docs/ja/formatter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,48 @@ description: Biomeのフォーマッタの使い方

import PackageManagerBiomeCommand from "@/components/PackageManagerBiomeCommand.astro";

Biomeは、スタイル関する議論に終止符を打つことを目的とした「opinionated」なフォーマッタです
[Prettierと近い哲学](https://prettier.io/docs/en/option-philosophy.html)を持ち
Biomeは[複数の言語をサポートする](/ja/internals/language-support)、opinionatedなフォーマッタです
[Prettierと近い哲学](https://prettier.io/docs/en/option-philosophy.html)に従い
スタイルに関する議論がBiomeのオプションに関する議論に発展するのを避けるために、いくつかのオプションのみをサポートしています。
チーム内での[些細な議論](https://ja.wikipedia.org/wiki/パーキンソンの凡俗法則)を防ぎ、本当に重要なことに集中できるようにするために、[新しいオプションを意図的に追加しない](https://github.com/prettier/prettier/issues/40)ようにしています。

## オプション
## CLI

Biomeがサポートする、言語に依存しないオプションは以下の通りです。
次のコマンドは、`src` ディレクトリ内のファイルのフォーマットをチェックします。
フォーマットされていないコードが見つかった場合、テキストの差分を出力します。

- インデントスタイル(デフォルト: `tab`):インデントにはスペースまたはタブを使用します
- タブ幅(デフォルト:`2`):インデントレベルごとのスペースの数です。
- 行幅(デフォルト:`80`):Biomeがコードを折り返す列幅です。
<PackageManagerBiomeCommand command="format ./src" />

特定の言語に対する他のフォーマットオプションも利用可能です。詳しくは[設定オプション](/reference/configuration)をご覧ください。
新しいフォーマットを**適用**する場合は、`--write` オプションを渡してください:

## CLI
<PackageManagerBiomeCommand command="format --write ./src" />

デフォルトでは、フォーマッタはコードを**チェック**し、差分がある場合はそれを報告します
このコマンドは、ファイルとディレクトリのリストを受け入れます

<PackageManagerBiomeCommand command="format ./src" />
:::caution
パラメータとしてglobを渡すと、シェルによって展開されます。
展開の結果は、使用しているシェルによって異なります。
例えば、一部のシェルは次のコマンドの再帰的glob `**` や代替 `{}` をサポートしていません:

新しいフォーマットを**適用**する場合は、`--write`オプションを使用してください。
```shell
biome format ./src/**/*.test.{js,ts}
```

<PackageManagerBiomeCommand command="format --write ./src" />
シェルの展開にはパフォーマンスコストがあり、コマンドに渡せるファイル数にも制限があります。
:::

利用可能なオプションを知りたい場合は、`--help`フラグを使用してください
利用可能なすべてのオプションの詳細については、[CLIリファレンス](/reference/cli#biome-format)を確認してください

<PackageManagerBiomeCommand command="format --help" />
## オプション

その他については、[CLIのリファレンス](/reference/cli#biome-format)を確認してください。
Biomeは、フォーマッタの動作を調整するためのいくつかのオプションを提供しています。
他のツールとは異なり、Biomeは言語に依存しないオプションと言語固有のオプションを分離しています。

## 設定
フォーマッタオプションは、[CLI](/reference/cli/#biome-format)または[Biome設定ファイル](/ja/guides/configure-biome)で設定できます。
v1.9以降、Biomeは `.editorconfig` ファイルの読み込みをサポートしています。

`biome.json`を使用して、[フォーマッターを設定](/reference/configuration/#formatter)することができます。以下はデフォルトの設定です。
[Biome設定ファイル](/ja/guides/configure-biome)を使用して、Biome CLIとBiome LSPの両方に同じオプションが適用されるようにすることをお勧めします。
以下のデフォルト設定が適用されます:

```json title="biome.json"
{
Expand All @@ -49,8 +57,8 @@ Biomeがサポートする、言語に依存しないオプションは以下の
"attributePosition": "auto",
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80
"lineWidth": 80,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
Expand All @@ -71,21 +79,58 @@ Biomeがサポートする、言語に依存しないオプションは以下の
}
```

他のツールと違って、Biomeは言語ごとに関するオプションを設定することができます。
Biomeフォーマッタがサポートする、言語に依存しない主なオプションは次のとおりです:

- インデントスタイル(デフォルト:`tab`):インデントにスペースまたはタブを使用します。
- インデント幅(デフォルト:`2`):インデントレベルごとのスペースの数です。
- 行幅(デフォルト:`80`):Biomeがコードを折り返す列幅です。

## コードのフォーマットを無効にする
詳細については、[設定リファレンス](/ja/reference/configuration#formatter)を参照してください。

## コードを無視する

フォーマットされたコードが理想的でない場合があります。

そのような場合は、フォーマットを抑制するコメントが使用できます。
### ファイル全体を無視する

ファイル全体に対してフォーマッタを抑制(無視)するには、**ファイルの先頭**に `biome-ignore-all format: reason` コメントを使用します:

例えば、JavaScriptの場合:

```js title="example.js"
// biome-ignore-all format: generated file

const expr1 =
[
(2 * n) / (r - l),
0,
(r + l) / (r - l),
-1,
0,
];


const expr2 =
[
(2 * n) / (r - l),
0,
(r + l) / (r - l),
-1,
0,
];
```

### ノードを無視する

コードの一部(ノード)だけを抑制したい場合は、抑制コメント `biome-ignore format: reason` を使用します

```js
// biome-ignore format: <説明文>
```js title="example.js"
// biome-ignore format: reason
```

Example:
例:

```js
```js title="example.js"
const expr =
// biome-ignore format: この配列はフォーマットさせない。
[
Expand Down
Loading
Loading