Biomejs 插件的配置及使用

官网
Biome,Web 工具链
简介
Biome 是一个适用于 JavaScript、TypeScript、JSX 和 JSON 的快速格式化工具,与Prettier有高达 97% 的兼容覆盖率,能有效节约持续化集成和开发者的时间。
使用方式
安装
下载Biome的最快方法是使用npm或您偏好的包管理器。 这需要 Node.js v14.18 或更新版本。
要安装Biome,请在包含package.json文件的目录中运行以下命令。
npm install --save-dev --save-exact @biomejs/biome
配置
我们建议为每个项目创建一个biome.json配置文件。它可以避免每次运行命令时重复输入CLI选项,并确保Biome在编辑器中应用相同的配置。如果您对Biome的默认设置满意,则无需创建配置。
要创建配置,请在项目的根文件夹中运行init命令:
npx @biomejs/biome init
运行init命令后,您的目录中将出现一个新的biome.json文件:

{
  "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
  "organizeImports": {
    "enabled": false
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  }
}

linter.enabled: true启用了代码检查器,rules.recommended: true启用了推荐规则。

格式化已启用,因为配置中没有明确禁用formatter.enabled: false。

也可以在这个文件中进行扩展配置:

{
  "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
  "files": {
    "ignore": ["dist/*", "node_modules/*", ".vscode/*", "turbo/*"]
  },
  "organizeImports": {
    "enabled": true,
    "ignore": []
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": {
        "useKeyWithClickEvents": "off",
        "useKeyWithMouseEvents": "off"
      },
      "suspicious": {
        "noExplicitAny": "off"
      },
      "complexity": {
        "noForEach": "warn"
      },
      "style": {
        "noNonNullAssertion": "off",
        "noUselessElse": "warn"
      },
      "correctness": {
        "useExhaustiveDependencies": "warn"
      }
    },
    "ignore": []
  },
  "formatter": {
    "enabled": true,
    "ignore": [],
    "indentStyle": "space",
    "lineWidth": 120,
    "indentWidth": 2,
    "lineEnding": "lf"
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "jsxQuoteStyle": "single",
      "semicolons": "asNeeded",
      "trailingComma": "all",
      "arrowParentheses": "asNeeded",
      "bracketSpacing": true,
      "quoteProperties": "asNeeded"
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不在··

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值