## 事象
[[未使用import文をファイル保存時に自動削除 (Biome)|未使用import文をファイル保存時に自動削除]]する設定を入れているが、削除されない。
```console
bunx biome check --write
```
### 環境
| 対象 | バージョン |
| --------- | ----- |
| [[Biome]] | 2.3.0 |
`biome.json`
```json
{
"$schema": "https://biomejs.dev/schemas/2.3.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": { "noUnusedImports": "warn" }
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"html": {
"formatter": {
"enabled": true
},
"experimentalFullSupportEnabled": true
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
```
### 環境
## 原因
[v2.0.0](https://biomejs.dev/internals/changelog/3/#2-0-0) で [[noUnusedImports (Biome)|noUnusedImports]] が unsafe fix になったから。
> Downgraded some code fixes to unsafe which were previously safe.
>
> The following rules have now a unsafe fix:
>
> - [`noFlatMapIdentity`](https://biomejs.dev/linter/rules/no-flat-map-identity)
> - [`noUnusedImports`](https://biomejs.dev/linter/rules/no-unused-imports)
>
> *[Version History](https://biomejs.dev/internals/changelog/3/#2-0-0) *
## 解決方法
`--unsafe` フラグを指定して実行する。
```console
bunx biome check --write --unsafe
```
もしくは、設定で safe fix として動作させる。
```diff
"linter": {
"enabled": true,
"rules": {
"recommended": true,
- "correctness": { "noUnusedImports": "warn" }
+ "correctness": { "noUnusedImports": { "level": "warn", "fix": "safe" } }
}
},
```