Skip to content

Code Quality Automation

biomeprettierprismaeditorconfiglefthookrenovate

Code Quality

This template primarily utilizes Biome, with Prettier also playing a complementary role. Actually, both library the same purpose, but Biome cannot format Markdown and YAML files, which is why both are used.

Git Pre-commit

Lefthook deploys shell scripts to the .githooks directory during the postinstall phase when running pnpm i or pnpm rebuild.

yml
pre-commit:
  parallel: true
  commands:
    biome:
      glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
      run: |
        npx biome check --write --no-errors-on-unmatched {staged_files}
      stage_fixed: true
    prettier:
      glob: "*.{md,yml}"
      run: |
        npx prettier --write {staged_files}
      stage_fixed: true
    prisma:
      glob: "*.prisma"
      run: |
        npx prisma format {staged_files}
      stage_fixed: true

Tool Configuration Overview

Biome

json
{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "organizeImports": {
    "enabled": true
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "lineWidth": 80
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "files": {
    "ignoreUnknown": true,
    "ignore": [".next", "dist", "cache"]
  }
}

Prettier

No Configuration File.

EditorConfig

editorconfig
root = true

[*]
charset = utf-8
indent_size = 2
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

Prisma

No Configuration File.

Renovate

json
{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "config:recommended",
    ":semanticCommitTypeAll(chore)",
    ":enableVulnerabilityAlerts",
    ":separateMajorReleases",
    "group:definitelyTyped",
    "group:monorepos",
    "group:test"
  ],
  "rangeStrategy": "pin",
  "labels": ["deps"],
  "packageRules": [
    {
      "matchManagers": ["npm"],
      "matchUpdateTypes": ["patch"],
      "matchDepTypes": ["dependencies", "devDependencies", "peerDependencies"],
      "groupName": "npm patch dependencies",
      "automerge": true,
      "matchPackageNames": ["*"]
    },
    {
      "matchManagers": ["npm"],
      "matchUpdateTypes": ["minor"],
      "matchDepTypes": ["dependencies", "devDependencies", "peerDependencies"],
      "groupName": "npm minor dependencies",
      "matchPackageNames": ["*"]
    },
    {
      "matchManagers": ["npm"],
      "automerge": true,
      "groupName": "npm @types",
      "major": {
        "automerge": false
      },
      "matchPackageNames": ["@types/{/,}**"]
    },
    {
      "matchManagers": ["npm"],
      "groupName": "linter deps",
      "extends": ["packages:linters"],
      "automerge": true,
      "major": {
        "automerge": false
      },
      "matchPackageNames": ["/^@biomejs/", "/^prettier/"]
    }
  ],
  "ignoreDeps": []
}