生物我最小化配置
一个最小化的Biome配置 我在我的项目中使用 相当严格的衬线和格式化规则, 作为替代ESLint和Pretier.
安装
# using bun
bun add --dev --exact @c14l/biome-config @biomejs/biome
使用量
安装后,创建一个 biome.json 在工程根中的文件并扩展此配置 :
{
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
"extends": ["@c14l/biome-config"]
}
也可以覆盖特定设置:
{
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
"extends": ["@c14l/biome-config"],
"formatter": {
"indentStyle": "tab"
}
}
编辑器集成
VS 代码/ 光标
对于 VS 代码或光标中的最佳体验,请将这些设置添加到您的 settings.json数字 :
{
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.action.useSortedAttributes.biome": "explicit", // sorts imports on save
"source.action.useSortedKeys.biome": "explicit", // sorts object keys on save
"source.fixAll.biome": "explicit", // fixes all errors on save
"source.organizeImports.biome": "explicit" // sorts imports on save
}
}
确保安装 生物延展 vS代码.
,也可以启用保存格式:
{
"editor.formatOnSave": true
}