Communitygithub.com

Nuvraxis/nuvraxis-plugins

Biome 2.5 設定與規則,適用於 Nuvraxis 單一儲存庫(monorepo)— 包含根目錄 biome.json、格式化、lint 規則、遷移指南等。

nuvraxis-plugins 是什麼?

此技能為 Nuvraxis 單一儲存庫(monorepo)提供完整的 Biome 2.5 設定與規則。它會建立根目錄 `biome.json`,固定 `$schema` 版本,設定 VCS 忽略規則、格式化器(2 空格、寬度 100、LF、雙引號、分號、尾逗號)以及 lint 規則(使用 `recommended` 預設集,加上 `a11y` 設為 `error`,並啟用 `react` 和 `next` 領域)。它要求每個套件可透過 `"extends": "//"` 繼承根設定。在本地端,`biome check --write` 會在每次 Claude 編輯檔案後自動執行(透過外掛鉤子),而 CI 則使用 `biome ci` 來確保程式碼品質。該技能也涵蓋從 ESLint/Prettier 遷移的步驟、VS Code 設定(Biome 作為預設格式化器、儲存時自動修正),以及處理 Biome 不支援的檔案(如 SCSS 用 stylelint)。它支援 Claude Code、Cursor、Codex 等平台,適合需要一致程式碼風格的單一儲存庫專案。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Nuvraxis/nuvraxis-plugins/tree/HEAD/plugins/nuvraxis-frontend/skills/biome

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Biome

Biome 是 JS、TS、JSX、JSON 和 CSS 的唯一格式化與 lint 工具。SCSS 例外:Biome 2.5 不解析 SCSS,因此 .scss 由 stylelint 處理(請參閱 scss-bem)。不需要 ESLint,不需要 Prettier。

模板根目錄的 biome.json 是唯一真相來源。每當 Claude 編輯檔案,且該檔案上方存在 biome.json 時,一個外掛鉤子會執行 pnpm exec biome check --write <file>。

規則

  1. 只有一個根 biome.json,Schema 固定在已安裝的版本。 "$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",且 @biomejs/biome 在工作區目錄中固定在相同版本。Schema 不符時,編輯器中會隱藏未知或已重新命名的選項。升級時,請執行 pnpm exec biome migrate --write 並同時更新兩者。

  2. 讓 git 決定忽略什麼:vcs.useIgnoreFile: true。 然後使用 !! 在 files.includes 中強制忽略建置輸出(!!**/.next、!!**/.turbo、!!**/dist、!!**/coverage),這也會阻止 Biome 掃描那些資料夾。單一的 ! 表示排除處理但仍在索引中。files.ignoreUnknown: true 可避免 Biome 回報不支援的檔案(如 .scss)。

  3. 格式化器:2 空格、寬度 100、LF、雙引號、分號、尾逗號。 這些設定對每個儲存庫都是固定的,這樣就不會在差異比較中爭論樣式。不要為個別套件新增格式化器覆寫。

  4. Lint:preset: "recommended"、a11y: "error"、領域 react 和 next 設為 recommended。 rules.recommended: true 是舊寫法,已棄用:請改用 rules.preset。a11y 設為 error,因為 nuvui 處理其自身元件的可及性,剩下的(alt、標籤、按鈕類型等你自己的標記)必須正確。next 領域新增了 noImgElement 等規則;react 則新增了 hooks 規則。

  5. Nursery 規則保持關閉。 Nursery 規則會在修補程式版本之間變動,並可能在升級 Biome 時中斷 CI。若故意要啟用某個規則,請按名稱啟用,並附上原因註解,然後在每次升級時重新檢查。

  6. noConsole 發出警告,但允許 error 和 warn。 結構化的錯誤日誌(instrumentation.ts)使用 console.error;而額外的 console.log 則會被捕捉。

  7. 使用輔助功能排序匯入,不要手動排序。 assist.actions.source.organizeImports: "on"。biome check --write 會套用此設定;biome ci 則會因未排序的匯入而失敗。

  8. 根據 glob 設定覆寫,例如測試檔案。 範本僅對 *.test.ts(x) / *.test-d.ts 啟用 test 領域。其他檔案型別的差異也應放在此處,而非放在單獨的設定檔中。

  9. 巢狀設定僅用於真正有差異的套件,且它們需繼承根設定。

    // packages/legacy-widget/biome.json
    { "extends": "//", "linter": { "rules": { "style": { "noNonNullAssertion": "off" } } } }
    

    "extends": "//" 代表「根設定」,並隱含 "root": false。任何其他巢狀設定必須設定 "root": false。我們不使用共享的 @repo/biome-config 套件:根檔案加上 // 就可以涵蓋,無需建置或依賴。

  10. 本地端使用 biome check --write;CI 中使用 biome ci。 pnpm lint 執行 biome check .(不寫入);pnpm lint:fix 執行 biome check --write .。CI 執行 pnpm exec biome ci --reporter=github .,永不寫入,在格式化、lint 和匯入順序不符時失敗,並在 PR 上添加註解。僅在全量執行變慢時才加入 --changed --since=origin/main;目前只需毫秒。

  11. 單行抑制,並附上原因。

    // biome-ignore lint/suspicious/noExplicitAny: 第三方回呼型別已由上游定義為 any
    

    永遠不要為了讓某個檔案通過而全儲存庫地停用規則。如果某個規則對整個儲存庫來說是錯的,請在它自己的 commit 中修改 biome.json,並附上原因。

  12. 修正常見問題,不要只是靜音。

    • useImportType:執行修正;這是由 verbatimModuleSyntax 要求的。
    • noExplicitAny:改用 unknown 並解析(請參閱 typescript-production)。
    • useButtonType、noSvgWithoutTitle、useAltText:真正的可及性錯誤。
    • noImgElement:改用 next/image。
    • useExhaustiveDependencies:修正相依性列表,或將值移出元件之外。
  13. VS Code:Biome 是預設格式化器,儲存時自動修正。 範本的 .vscode/settings.json 設定 editor.defaultFormatter: "biomejs.biome"、source.fixAll.biome 和 source.organizeImports.biome 在儲存時執行,以及 biome.requireConfiguration: true 讓擴充功能在沒有 Biome 的儲存庫中保持安靜。SCSS 使用 stylelint 擴充功能。在 .vscode/extensions.json 中推薦兩者。

  14. 從 ESLint/Prettier 遷移:先遷移,然後刪除。 請參閱 references/migration.md。最終狀態:沒有 eslint*、prettier* 或 @typescript-eslint/* 套件,沒有 .eslintrc*、eslint.config.*、.prettierrc*、.prettierignore。

Biome 不涵蓋的內容

檔案工具
.scssstylelint(scss-bem)
.yaml(工作流程、Helm)工作流程使用 actionlint;圖表使用 helm lint + kubeconform
.md無強制檢查
型別錯誤tsc --noEmit(pnpm typecheck)

驗證

pnpm lint                               # biome check . && stylelint
pnpm exec biome ci --reporter=github .  # CI 執行的內容
pnpm exec biome rage                    # 印出解析後的設定(如有內容看似被忽略)

來源

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

Nuvraxis/nuvraxis-plugins

>- Dockerfile rules for Next.js standalone apps in a pnpm + Turborepo monorepo — multi-stage build (turbo prune → pnpm fetch/offline install → turbo build → minimal runner), pinned Node 26 Alpine by digest, checksum-verified pnpm binary, non-root uid 1001, read-only root filesystem with a writable .next/cache, HEALTHCHECK on /api/health, build args only for NEXT_PUBLIC_* values, BuildKit secrets and cache mounts, multi-arch, OCI labels and .dockerignore. Use when the repo has a Dockerfile, .dockerignore, compose file, or next.config with output "standalone", or when asked to containerise, shrink, harden or debug an image.

Nuvraxis/nuvraxis-plugins

>- GitHub Actions conventions for Nuvraxis Next.js apps — exactly three workflows: pr.yaml (every PR to any branch: Biome, stylelint, typecheck/test/build with turbo --affected, Docker build + health check, helm lint + kubeconform; publishes nothing), main.yaml (push to main: one multi-arch image to GHCR tagged sha-SHORTSHA and main, provenance + SBOM, gha cache), release.yaml (tag vX.Y.Z: verify on main, retag the existing image without rebuilding, package and push the Helm chart to OCI, GitHub Release with chart, digest and SBOM). Minimal permissions per job, GITHUB_TOKEN only, pinned action majors. Use when editing .github/workflows/*, adding a CI step, or debugging a failed run or release.

Nuvraxis/nuvraxis-plugins

>- Helm chart rules for Nuvraxis Next.js apps — one chart per app in charts/ (named after the app), published to oci://ghcr.io/nuvraxis/charts and synced by Argo CD; Chart.yaml version/appVersion set only by release.yaml; Deployment with startup/liveness/readiness probes on /api/health, non-root read-only security context, emptyDir for .next/cache, ConfigMap + existing Secret via envFrom, Service, Ingress with cert-manager, HPA, PDB, ServiceAccount, topology spread; no Helm hooks; helm lint --strict + kubeconform. Use when the repo has charts/, Chart.yaml, values*.yaml, templates/*.yaml with Helm syntax, or an Argo CD Application, or when asked to deploy, scale, expose or configure the app on Kubernetes.

Nuvraxis/nuvraxis-plugins

>- Production rules for Next.js 16 App Router apps at Nuvraxis — Server/Client Component boundaries, Cache Components ("use cache", cacheLife, cacheTag, updateTag), Server Actions, route handlers, env handling, instrumentation, output standalone and the /api/health route. Use when the project has "next" in package.json, an app/ or src/app/ directory, next.config.ts, proxy.ts, instrumentation.ts, or files named page.tsx, layout.tsx, route.ts, loading.tsx, error.tsx.

相關技能