Biome | Web项目整合工具链
Biome是一个现代化的工具链,支持 JavaScript、TypeScript、JSON 和 CSS 等主流 Web 开发语言,可以在几分之一秒内格式化和 lint 代码,旨在最终取代 Babel、ESLint、webpack、Prettier、Jest 等。
安装
npm install --save-dev --save-exact @biomejs/biomeBiome支持安装到本地电脑,支持Windows,Mac,Linux
初始化配置
npx @biomejs/biome initWelcome to Biome! Let's get you started...
Files created ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  - biome.json: Your project configuration. Documentation: https://biomejs.dev/reference/configuration
Next Steps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  1. Setup an editor extension
     Get live errors as you type and format when you save. Learn more: https://biomejs.dev/guides/getting-started#editor-setup
  2. Try a command
     biome ci checks for lint errors and verifies formatting. Run biome --help for a full list of commands and options.
  3. Read the documentation
     Our website serves as a comprehensive source of guides and documentation: https://biomejs.dev
  4. Get involved in the community
     Ask questions, get support, or contribute by participating on GitHub (https://github.com/biomejs/biome),
     or join our community Discord (https://discord.gg/BypW39g6Yc)默认会创建biome.json文件,内容如下
{
    "$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
    "organizeImports": {
        "enabled": true
    },
    "linter": {
        "enabled": true,
        "rules": {
            "recommended": true
        }
    }
}格式化配置
从 Visual Studio Marketplace 安装官方 Biome VS Code 扩展。编辑器右键使用...格式化文档可以选择Biome,可以修改biome.json调整格式化方案,默认格式化方案如下
{
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "tab",
    "indentSize": 2,
    "lineWidth": 80,
    "ignore": []
  }
}Lint
使用以下命令运行 CLI 以检查可能的错误
npx @biomejs/biome lint ./src    当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »