From b134a6e2309f26b72fbd406269e79a8ff4b24a0c Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 14:53:42 +0100 Subject: [PATCH 1/7] style(json): format this repository's JSON with Biome Pin Biome, add a root biome.json and apply `biome format`. It leaves out config-sync/templates, whose own root biome.json Biome rejects as a second root config. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .mise.toml | 1 + biome.json | 39 +++++++++++++++++++ config-sync/files/dprint.json | 4 +- ...assign-issue-to-codeowners.properties.json | 6 +-- workflow-templates/autofix.properties.json | 8 ++-- .../config-sync.properties.json | 6 +-- workflow-templates/label-sync.properties.json | 6 +-- workflow-templates/labeler.properties.json | 6 +-- workflow-templates/lint.properties.json | 8 ++-- workflow-templates/pages.properties.json | 8 ++-- workflow-templates/release.properties.json | 6 +-- .../renovate-pr-cooldown.properties.json | 8 ++-- .../todo-to-issue.properties.json | 6 +-- 13 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 biome.json diff --git a/.mise.toml b/.mise.toml index 98df7a9c..61060d4a 100644 --- a/.mise.toml +++ b/.mise.toml @@ -3,6 +3,7 @@ min_version = "2026.10.19" [tools] actionlint = "1.7.12" +biome = "2.6.8" cocogitto = "7.0.0" dprint = "0.64.3" gitleaks = "8.30.1" diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..55a03fb7 --- /dev/null +++ b/biome.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.6.8/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "includes": [ + "**", + "!**/node_modules", + "!apm_modules", + "!.agents", + "!.claude", + "!.cursor", + "!.gemini", + "!.github/agents", + "!.github/chatmodes", + "!.github/instructions", + "!.github/prompts", + "!.github/skills", + "!.kiro", + "!.opencode", + "!.specify", + "!.venv*", + "!.windsurf" + ] + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 120 + }, + "linter": { + "rules": { + "preset": "recommended" + } + } +} diff --git a/config-sync/files/dprint.json b/config-sync/files/dprint.json index 92f65210..7925ef4a 100644 --- a/config-sync/files/dprint.json +++ b/config-sync/files/dprint.json @@ -21,7 +21,5 @@ ".specify/**", ".venv*/**" ], - "plugins": [ - "https://plugins.dprint.dev/markdown-0.21.1.wasm" - ] + "plugins": ["https://plugins.dprint.dev/markdown-0.21.1.wasm"] } diff --git a/workflow-templates/assign-issue-to-codeowners.properties.json b/workflow-templates/assign-issue-to-codeowners.properties.json index 994adc83..d199c035 100644 --- a/workflow-templates/assign-issue-to-codeowners.properties.json +++ b/workflow-templates/assign-issue-to-codeowners.properties.json @@ -1,5 +1,5 @@ { - "name": "Assign issue to CODEOWNERS", - "description": "Auto-assign newly opened issues to users listed in the CODEOWNERS file.", - "categories": ["Utilities"] + "name": "Assign issue to CODEOWNERS", + "description": "Auto-assign newly opened issues to users listed in the CODEOWNERS file.", + "categories": ["Utilities"] } diff --git a/workflow-templates/autofix.properties.json b/workflow-templates/autofix.properties.json index 13dc382e..2dbed444 100644 --- a/workflow-templates/autofix.properties.json +++ b/workflow-templates/autofix.properties.json @@ -1,6 +1,6 @@ { - "name": "Auto-fix formatting", - "description": "Manually triggered workflow that auto-fixes formatting issues using dprint fmt, yamlfmt, and shfmt --write, then commits and pushes the changes. Supports formatter configs from an optional config directory.", - "categories": ["Continuous integration"], - "filePatterns": ["\\.ya?ml$", "\\.sh$", "\\.md$"] + "name": "Auto-fix formatting", + "description": "Manually triggered workflow that auto-fixes formatting issues using dprint fmt, yamlfmt, and shfmt --write, then commits and pushes the changes. Supports formatter configs from an optional config directory.", + "categories": ["Continuous integration"], + "filePatterns": ["\\.ya?ml$", "\\.sh$", "\\.md$"] } diff --git a/workflow-templates/config-sync.properties.json b/workflow-templates/config-sync.properties.json index e831cf58..b0a0f5d5 100644 --- a/workflow-templates/config-sync.properties.json +++ b/workflow-templates/config-sync.properties.json @@ -1,5 +1,5 @@ { - "name": "Config Sync", - "description": "Pull-based config sync from the central DevSecNinja/.github repository. Opens PRs when config files have changed. No PAT required.", - "categories": ["Utilities"] + "name": "Config Sync", + "description": "Pull-based config sync from the central DevSecNinja/.github repository. Opens PRs when config files have changed. No PAT required.", + "categories": ["Utilities"] } diff --git a/workflow-templates/label-sync.properties.json b/workflow-templates/label-sync.properties.json index b67088e1..b6c39a8f 100644 --- a/workflow-templates/label-sync.properties.json +++ b/workflow-templates/label-sync.properties.json @@ -1,5 +1,5 @@ { - "name": "Label Sync", - "description": "Sync GitHub labels from a labels.yaml config file. Runs daily and on push.", - "categories": ["Utilities"] + "name": "Label Sync", + "description": "Sync GitHub labels from a labels.yaml config file. Runs daily and on push.", + "categories": ["Utilities"] } diff --git a/workflow-templates/labeler.properties.json b/workflow-templates/labeler.properties.json index 6a5321e8..aeb3ab34 100644 --- a/workflow-templates/labeler.properties.json +++ b/workflow-templates/labeler.properties.json @@ -1,5 +1,5 @@ { - "name": "Labeler", - "description": "Auto-label pull requests based on changed file paths and issues based on body content.", - "categories": ["Utilities"] + "name": "Labeler", + "description": "Auto-label pull requests based on changed file paths and issues based on body content.", + "categories": ["Utilities"] } diff --git a/workflow-templates/lint.properties.json b/workflow-templates/lint.properties.json index 4aaefabe..e5d8a40e 100644 --- a/workflow-templates/lint.properties.json +++ b/workflow-templates/lint.properties.json @@ -1,6 +1,6 @@ { - "name": "Lint", - "description": "Centralized linting workflow with config-directory support and toggles for dprint, yamlfmt, yamllint, actionlint, gitleaks, shellcheck, shfmt, checkov, trivy, zizmor, and config-drift checking.", - "categories": ["Continuous integration"], - "filePatterns": ["\\.ya?ml$", "\\.sh$", "\\.md$"] + "name": "Lint", + "description": "Centralized linting workflow with config-directory support and toggles for dprint, yamlfmt, yamllint, actionlint, gitleaks, shellcheck, shfmt, checkov, trivy, zizmor, and config-drift checking.", + "categories": ["Continuous integration"], + "filePatterns": ["\\.ya?ml$", "\\.sh$", "\\.md$"] } diff --git a/workflow-templates/pages.properties.json b/workflow-templates/pages.properties.json index 81592ab3..61709b95 100644 --- a/workflow-templates/pages.properties.json +++ b/workflow-templates/pages.properties.json @@ -1,6 +1,6 @@ { - "name": "Pages", - "description": "Deploy GitHub Pages on the default branch and Cloudflare Pages previews for pull requests.", - "categories": ["Deployment", "Continuous integration"], - "filePatterns": ["package.json", "index.html", "sitemap.xml"] + "name": "Pages", + "description": "Deploy GitHub Pages on the default branch and Cloudflare Pages previews for pull requests.", + "categories": ["Deployment", "Continuous integration"], + "filePatterns": ["package.json", "index.html", "sitemap.xml"] } diff --git a/workflow-templates/release.properties.json b/workflow-templates/release.properties.json index 9f462a34..b85a164c 100644 --- a/workflow-templates/release.properties.json +++ b/workflow-templates/release.properties.json @@ -1,5 +1,5 @@ { - "name": "Release", - "description": "Create a GitHub Release with git-cliff changelog when a version tag is pushed.", - "categories": ["Continuous integration"] + "name": "Release", + "description": "Create a GitHub Release with git-cliff changelog when a version tag is pushed.", + "categories": ["Continuous integration"] } diff --git a/workflow-templates/renovate-pr-cooldown.properties.json b/workflow-templates/renovate-pr-cooldown.properties.json index 4935f588..80696942 100644 --- a/workflow-templates/renovate-pr-cooldown.properties.json +++ b/workflow-templates/renovate-pr-cooldown.properties.json @@ -1,6 +1,6 @@ { - "name": "Renovate PR cooldown", - "description": "Enforces a 14-day PR-age soak for Renovate PRs from registries without a trusted release timestamp (ghcr.io/lscr.io/quay.io) via a required pr-cooldown status check, so they can auto-merge after soaking. Add pr-cooldown to the branch ruleset's required checks.", - "categories": ["Continuous integration", "Dependency management"], - "filePatterns": ["renovate\\.json5?$"] + "name": "Renovate PR cooldown", + "description": "Enforces a 14-day PR-age soak for Renovate PRs from registries without a trusted release timestamp (ghcr.io/lscr.io/quay.io) via a required pr-cooldown status check, so they can auto-merge after soaking. Add pr-cooldown to the branch ruleset's required checks.", + "categories": ["Continuous integration", "Dependency management"], + "filePatterns": ["renovate\\.json5?$"] } diff --git a/workflow-templates/todo-to-issue.properties.json b/workflow-templates/todo-to-issue.properties.json index 01eb3ad5..62d88524 100644 --- a/workflow-templates/todo-to-issue.properties.json +++ b/workflow-templates/todo-to-issue.properties.json @@ -1,5 +1,5 @@ { - "name": "TODO to Issue", - "description": "Automatically convert TODO comments in code to GitHub issues.", - "categories": ["Utilities"] + "name": "TODO to Issue", + "description": "Automatically convert TODO comments in code to GitHub issues.", + "categories": ["Utilities"] } From 4e04875bf9c8f40346a4840d70324a3c55d38626 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 14:53:51 +0100 Subject: [PATCH 2/7] feat(lint): run Biome when the repository has JavaScript, TypeScript, JSON or CSS files Add a lint-biome linter (default on, off in lint-include.yml) to both job modes. Like ruff, a first step lists the tracked *.js, *.mjs, *.cjs, *.jsx, *.ts, *.mts, *.cts, *.tsx, *.json, *.jsonc and *.css files, minus the shared excludes, and skips the mise install and Biome when there are none. Biome runs `biome ci` (read-only) with log diffs, PR annotations and, with upload-sarif, SARIF for code scanning. lint-biome-exclude skips more paths: this repository uses it for config-sync/templates. Add a create-only biome.json template, which config-sync doesn't add next to biome.jsonc, pin biome in the .mise.toml template, and let the shared Renovate config keep biome.json's $schema version in step (customManagers:biomeVersions). Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/lint-caller.yml | 4 ++ .github/workflows/lint-include.yml | 16 ++++- .github/workflows/lint.yml | 102 ++++++++++++++++++++++++++++- .renovate/customManagers.json5 | 2 + config-sync/templates/.mise.toml | 1 + config-sync/templates/README.md | 13 ++++ config-sync/templates/biome.json | 39 +++++++++++ docs/architecture.md | 17 ++++- scripts/config-sync/sync-files.sh | 11 +++- scripts/lint/biome.sh | 41 ++++++++++++ scripts/lint/language-files.sh | 5 ++ tests/config-sync-scripts.sh | 8 ++- tests/lint-job-modes-contract.sh | 2 +- tests/lint-scripts.sh | 32 ++++++++- tests/workflow-job-conditions.py | 2 + workflow-templates/lint.yml | 4 ++ 16 files changed, 290 insertions(+), 9 deletions(-) create mode 100644 config-sync/templates/biome.json create mode 100755 scripts/lint/biome.sh diff --git a/.github/workflows/lint-caller.yml b/.github/workflows/lint-caller.yml index a4e9e41a..4fee7390 100644 --- a/.github/workflows/lint-caller.yml +++ b/.github/workflows/lint-caller.yml @@ -28,6 +28,9 @@ jobs: # renovate: datasource=github-releases depName=golangci/golangci-lint # golangci-lint-version: "v2.12.2" lint-config-dir: config-sync/files + # config-sync/templates holds a root biome.json for other repositories, + # which Biome rejects as a second root config in this one. + lint-biome-exclude: config-sync/templates/* # This repository has no inline scripts (#537), so it keeps it that way. lint-inline-scripts-blocking: true @@ -46,6 +49,7 @@ jobs: # renovate: datasource=github-releases depName=jdx/mise mise-version: "2026.10.19" lint-config-dir: config-sync/files + lint-biome-exclude: config-sync/templates/* # See the job above. lint-job-mode: single lint-inline-scripts-blocking: true upload-sarif: false diff --git a/.github/workflows/lint-include.yml b/.github/workflows/lint-include.yml index 55ed377d..78c67363 100644 --- a/.github/workflows/lint-include.yml +++ b/.github/workflows/lint-include.yml @@ -106,6 +106,18 @@ on: required: false type: boolean default: false + lint-biome: + description: "Run Biome (JavaScript, TypeScript, JSON and CSS linting and formatting) when the repository has such + files — uploads SARIF" + required: false + type: boolean + default: false + lint-biome-exclude: + description: "Glob pattern for paths to exclude from Biome (a bash pattern on the repository-relative path; * also + matches /)" + required: false + type: string + default: "" lint-config-drift: description: "Check local config files match central DevSecNinja/.github repo" required: false @@ -122,7 +134,7 @@ on: type: boolean default: false upload-sarif: - description: "Upload checkov/trivy/zizmor/ruff results to GitHub code scanning (requires GitHub Advanced Security). + description: "Upload checkov/trivy/zizmor/ruff/biome results to GitHub code scanning (requires GitHub Advanced Security). Set false for private repos without GHAS to gate on exit codes with console output instead." required: false type: boolean @@ -171,6 +183,8 @@ jobs: lint-trivy: ${{ inputs.lint-trivy }} lint-zizmor: ${{ inputs.lint-zizmor }} lint-ruff: ${{ inputs.lint-ruff }} + lint-biome: ${{ inputs.lint-biome }} + lint-biome-exclude: ${{ inputs.lint-biome-exclude }} lint-config-drift: ${{ inputs.lint-config-drift }} lint-inline-scripts: ${{ inputs.lint-inline-scripts }} lint-inline-scripts-blocking: ${{ inputs.lint-inline-scripts-blocking }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 69012017..9902f3c0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -98,6 +98,18 @@ on: required: false type: boolean default: true + lint-biome: + description: "Run Biome (JavaScript, TypeScript, JSON and CSS linting and formatting) when the repository has such + files — uploads SARIF" + required: false + type: boolean + default: true + lint-biome-exclude: + description: "Glob pattern for paths to exclude from Biome (a bash pattern on the repository-relative path; * also + matches /)" + required: false + type: string + default: "" lint-config-drift: description: "Check local config files match central DevSecNinja/.github repo" required: false @@ -117,7 +129,7 @@ on: type: boolean default: false upload-sarif: - description: "Upload checkov/trivy/zizmor/ruff results to GitHub code scanning (requires GitHub Advanced Security). + description: "Upload checkov/trivy/zizmor/ruff/biome results to GitHub code scanning (requires GitHub Advanced Security). Set false for private repos without GHAS to gate on exit codes with console output instead." required: false type: boolean @@ -740,6 +752,68 @@ jobs: sarif_file: ${{ runner.temp }}/ruff.sarif category: ruff + biome: + name: biome + if: ${{ inputs.lint-biome && (inputs.lint-job-mode == 'parallel' || (inputs.lint-job-mode == 'auto' && !github.event.repository.private)) + }} + continue-on-error: ${{ ! inputs.lint-fail-on-error }} + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + security-events: write + steps: + - name: Checkout lint scripts + # The linter scripts ship with this reusable workflow: fetch them from + # the same commit of DevSecNinja/.github that the caller pinned. + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: .devsecninja-lint + sparse-checkout: |- + scripts/lint/ + scripts/lint-inline-scripts.py + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Move lint scripts out of the workspace + # Outside the workspace the caller's linters don't scan them, and the + # code checkout doesn't delete them. + run: mv .devsecninja-lint "${RUNNER_TEMP}/devsecninja-lint" + + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Find JavaScript, TypeScript, JSON and CSS files + # Repositories without them skip the mise install and Biome. + id: web-files + run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/detect-language.sh" web + + - name: Install mise + if: ${{ steps.web-files.outputs.found == 'true' }} + uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 + with: + install: true + version: ${{ inputs.mise-version }} + + - name: Run Biome + id: biome + if: ${{ steps.web-files.outputs.found == 'true' }} + env: + UPLOAD_SARIF: ${{ inputs.upload-sarif }} + EXCLUDE_PATTERN: ${{ inputs.lint-biome-exclude }} + run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/biome.sh" + + - name: Upload SARIF report + if: ${{ !cancelled() && steps.biome.outputs.sarif == 'true' }} + uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + with: + sarif_file: ${{ runner.temp }}/biome.sarif + category: biome + config-drift: name: config drift if: ${{ inputs.lint-config-drift && (inputs.lint-job-mode == 'parallel' || (inputs.lint-job-mode == 'auto' && !github.event.repository.private)) @@ -870,11 +944,17 @@ jobs: if: ${{ inputs.lint-ruff }} run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/detect-language.sh" python + - name: Find JavaScript, TypeScript, JSON and CSS files + # Repositories without them skip Biome (and its mise install). + id: web-files + if: ${{ inputs.lint-biome }} + run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/detect-language.sh" web + - name: Install mise if: >- ${{ inputs.lint-dprint || inputs.lint-yamlfmt || inputs.lint-yamllint || inputs.lint-actionlint || inputs.lint-gitleaks || inputs.lint-shellcheck || inputs.lint-shfmt || inputs.lint-checkov || inputs.lint-trivy || inputs.lint-zizmor - || steps.python-files.outputs.found == 'true' }} + || steps.python-files.outputs.found == 'true' || steps.web-files.outputs.found == 'true' }} uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 with: install: true @@ -1075,6 +1155,24 @@ jobs: sarif_file: ${{ runner.temp }}/ruff.sarif category: ruff + - name: Run Biome + id: biome + if: ${{ steps.web-files.outputs.found == 'true' }} + continue-on-error: true + env: + UPLOAD_SARIF: ${{ inputs.upload-sarif }} + EXCLUDE_PATTERN: ${{ inputs.lint-biome-exclude }} + run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/biome.sh" + + - name: Upload Biome SARIF report + id: biome-sarif + if: ${{ !cancelled() && steps.biome.outputs.sarif == 'true' }} + continue-on-error: true + uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + with: + sarif_file: ${{ runner.temp }}/biome.sarif + category: biome + - name: Check config drift against central repo id: config-drift if: ${{ inputs.lint-config-drift }} diff --git a/.renovate/customManagers.json5 b/.renovate/customManagers.json5 index 77f032d0..c6fc60f4 100644 --- a/.renovate/customManagers.json5 +++ b/.renovate/customManagers.json5 @@ -1,5 +1,7 @@ { $schema: "https://docs.renovatebot.com/renovate-schema.json", + // Keeps the $schema version of biome.json(c) in step with Biome updates. + extends: ["customManagers:biomeVersions"], customManagers: [ { customType: "regex", diff --git a/config-sync/templates/.mise.toml b/config-sync/templates/.mise.toml index 3c179e30..210bd257 100644 --- a/config-sync/templates/.mise.toml +++ b/config-sync/templates/.mise.toml @@ -4,6 +4,7 @@ min_version = "2026.10.19" [tools] actionlint = "1.7.12" +biome = "2.6.8" dprint = "0.64.3" gitleaks = "8.30.1" lefthook = "2.2.2" diff --git a/config-sync/templates/README.md b/config-sync/templates/README.md index 9f81df33..61856995 100644 --- a/config-sync/templates/README.md +++ b/config-sync/templates/README.md @@ -104,3 +104,16 @@ same generated and vendored paths as the shared `dprint.json`. Config-sync doesn't add it to a repo that configures ruff in `.ruff.toml` or in `[tool.ruff]` of `pyproject.toml`, where `ruff.toml` would take precedence and replace those settings. + +## biome.json + +Config for Biome, which the shared Lint workflow runs when the repo has +JavaScript, TypeScript, JSON or CSS files (`lint-biome`). It indents with two +spaces, wraps at 120 columns, enables the recommended lint rules, respects +`.gitignore` and skips the same generated and vendored paths as the shared +`dprint.json`. Biome's other defaults (double quotes, semicolons) apply; change +them in the repo's copy. JSON allows no comments, so this note replaces the +usual template header. Config-sync doesn't add it to a repo that has +`biome.jsonc`. The `customManagers:biomeVersions` Renovate preset, part of the +shared Renovate config, keeps its `$schema` version in step with the pinned +Biome. diff --git a/config-sync/templates/biome.json b/config-sync/templates/biome.json new file mode 100644 index 00000000..55a03fb7 --- /dev/null +++ b/config-sync/templates/biome.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.6.8/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "includes": [ + "**", + "!**/node_modules", + "!apm_modules", + "!.agents", + "!.claude", + "!.cursor", + "!.gemini", + "!.github/agents", + "!.github/chatmodes", + "!.github/instructions", + "!.github/prompts", + "!.github/skills", + "!.kiro", + "!.opencode", + "!.specify", + "!.venv*", + "!.windsurf" + ] + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 120 + }, + "linter": { + "rules": { + "preset": "recommended" + } + } +} diff --git a/docs/architecture.md b/docs/architecture.md index ac5f0245..a2b13557 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -74,7 +74,7 @@ workflow, so it calls `scripts/apm-materialize/` from its own checkout. ### Lint (`lint.yml`) -Runs up to fourteen linters. By default, linter failures are reported without +Runs up to fifteen linters. By default, linter failures are reported without failing the workflow; set `lint-fail-on-error` to `true` to make lint failures fail the workflow. Toggle individual linters on/off with boolean inputs; all linter toggles default to `true`. @@ -187,6 +187,17 @@ APM-deployed agent files, `node_modules`, `.venv*`). [`ruff.toml` template](../config-sync/templates/ruff.toml) is a starting point. Findings are annotated on the PR, and with `upload-sarif` they also go to code scanning (category `ruff`). +- **Biome** (`lint-biome`, JavaScript, TypeScript, JSON and CSS, after v4.5.0) + runs `biome ci`, which lints and checks formatting and import order without + writing, on the `*.js`, `*.mjs`, `*.cjs`, `*.jsx`, `*.ts`, `*.mts`, `*.cts`, + `*.tsx`, `*.json`, `*.jsonc` and `*.css` files. Pin `biome` in the + repository's mise config. Biome reads the repository's own `biome.json` or + `biome.jsonc`; config-sync's + [`biome.json` template](../config-sync/templates/biome.json) is a starting + point. Findings are annotated on the PR, and with `upload-sarif` they also go + to code scanning (category `biome`). `lint-biome-exclude` skips more paths, + such as a directory with another root Biome config, which Biome rejects. + dprint formats only Markdown. **Inline scripts.** Code in a `run:` block is out of reach of linters, formatters and tests, so a `run:` step may hold exactly one line with one @@ -229,7 +240,7 @@ runner's system Python, which ships PyYAML (`ubuntu-24.04`). | `lint-config-dir` | Optional linter config directory. Default: `""`. | | `lint-fail-on-error` | Fail when a linter fails. Default: `false`. | | `lint-job-mode` | `auto`, `single`, or `parallel` (see above). Default: `auto`. v3.3.0+. | -| `upload-sarif` | Upload SARIF (checkov, trivy, zizmor, ruff). Default: `true`. | +| `upload-sarif` | Upload SARIF (checkov, trivy, zizmor, ruff, biome). Default: `true`. | | `lint-dprint` | Markdown formatting (dprint). Default: `true`. | | `lint-yamlfmt` | YAML formatting (yamlfmt). Default: `true`. | | `lint-yamllint` | YAML linting (yamllint). Default: `true`. | @@ -242,6 +253,8 @@ runner's system Python, which ships PyYAML (`ubuntu-24.04`). | `lint-trivy` | Filesystem scan (trivy). Default: `true`. | | `lint-zizmor` | Actions security scan (zizmor). Default: `true`. | | `lint-ruff` | Python linting (ruff, see above). Default: `true`. After v4.5.0. | +| `lint-biome` | JS/TS/JSON/CSS linting (Biome). Default: `true`. After v4.5.0. | +| `lint-biome-exclude` | Bash pattern of paths Biome skips. Default: `""`. After v4.5.0. | | `lint-config-drift` | Config-drift check. Default: `false`. | | `lint-inline-scripts` | Inline-script check (see above). Default: `true`. After v4.4.0. | | `lint-inline-scripts-blocking` | Report inline scripts as errors. Default: `false`. After v4.4.0. | diff --git a/scripts/config-sync/sync-files.sh b/scripts/config-sync/sync-files.sh index a63a2ddf..636dd781 100644 --- a/scripts/config-sync/sync-files.sh +++ b/scripts/config-sync/sync-files.sh @@ -86,7 +86,8 @@ apm_owner() { # A template is not bootstrapped when the repository configures the tool in # another file already: ruff.toml would take precedence over [tool.ruff] in -# pyproject.toml and silently replace its settings. +# pyproject.toml and silently replace its settings, and biome.json would sit +# next to the repository's biome.jsonc. configured_elsewhere() { case "$1" in ruff.toml) @@ -99,6 +100,14 @@ configured_elsewhere() { return 0 fi ;; + biome.json) + for config in biome.jsonc .biome.json .biome.jsonc; do + if [ -e "${config}" ]; then + echo "${config}" + return 0 + fi + done + ;; *) ;; esac return 1 diff --git a/scripts/lint/biome.sh b/scripts/lint/biome.sh new file mode 100755 index 00000000..78a45c54 --- /dev/null +++ b/scripts/lint/biome.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Lints the repository's JavaScript, TypeScript, JSON and CSS files with Biome +# and checks their formatting (`biome ci`, which never writes to the files). +# A step of .github/workflows/lint.yml, run the same way in both lint modes. +# Biome reads the repository's own config (biome.json or biome.jsonc). +# Env: EXCLUDE_PATTERN (lint-biome-exclude): skip the paths matching this bash +# pattern. UPLOAD_SARIF: also write the findings as SARIF for code scanning, +# and sarif=true to GITHUB_OUTPUT. + +set -eo pipefail + +lint_dir="$(dirname "${BASH_SOURCE[0]}")" +bash "${lint_dir}/require-mise-tool.sh" biome +mapfile -d '' listed < <(bash "${lint_dir}/language-files.sh" web) +files=() +for file in "${listed[@]}"; do + # shellcheck disable=SC2053 # EXCLUDE_PATTERN is a pattern, not a string. + if [ -z "${EXCLUDE_PATTERN}" ] || [[ "${file}" != ${EXCLUDE_PATTERN} ]]; then + files+=("${file}") + fi +done +# Without file arguments Biome would check the whole directory. +if [ "${#files[@]}" -eq 0 ]; then + echo "::notice::No JavaScript, TypeScript, JSON or CSS files found; skipping Biome" + exit 0 +fi + +# The default reporter shows formatting diffs in the log, the github one +# annotates the PR. --no-errors-on-unmatched: the config may ignore every file. +reporters=(--reporter=default --reporter=github) +if [ "${UPLOAD_SARIF}" = "true" ]; then + reporters+=(--reporter=sarif "--reporter-file=${RUNNER_TEMP}/biome.sarif") +fi + +status=0 +mise exec -- biome ci --no-errors-on-unmatched "${reporters[@]}" -- "${files[@]}" || status=1 +if [ "${UPLOAD_SARIF}" = "true" ] && [ -f "${RUNNER_TEMP}/biome.sarif" ]; then + echo "sarif=true" >>"${GITHUB_OUTPUT}" +fi +exit "${status}" diff --git a/scripts/lint/language-files.sh b/scripts/lint/language-files.sh index ef7502f6..c28633d9 100755 --- a/scripts/lint/language-files.sh +++ b/scripts/lint/language-files.sh @@ -13,6 +13,11 @@ set -eo pipefail case "$1" in python) patterns=('**/*.py' '**/*.pyi') ;; +# JavaScript, TypeScript, JSON and CSS: what Biome checks. +web) + patterns=('**/*.js' '**/*.mjs' '**/*.cjs' '**/*.jsx' '**/*.ts' '**/*.mts' '**/*.cts' '**/*.tsx' + '**/*.json' '**/*.jsonc' '**/*.css') + ;; *) echo "::error::language-files.sh: unknown language '$1'" >&2 exit 2 diff --git a/tests/config-sync-scripts.sh b/tests/config-sync-scripts.sh index a128c7bb..1a7913e5 100644 --- a/tests/config-sync-scripts.sh +++ b/tests/config-sync-scripts.sh @@ -80,4 +80,10 @@ done sync_templates .ruff.toml "line-length = 100" [ ! -e "${consumer}/ruff.toml" ] || fail "ruff.toml must not be added next to .ruff.toml" -echo "✓ config-sync: sync-files.sh keeps the ruff.toml template out of repositories that configure ruff elsewhere." +[ -e "${consumer}/biome.json" ] || fail "a repository without Biome config must get the biome.json template" +sync_templates biome.jsonc "{}" +[ ! -e "${consumer}/biome.json" ] || fail "biome.json must not be added next to biome.jsonc" +grep -Fq "biome.json skipped: configured in biome.jsonc" "${tmp_dir}/log" || + fail "the skipped biome.json must be logged: $(cat "${tmp_dir}/log")" + +echo "✓ config-sync: sync-files.sh keeps the ruff.toml and biome.json templates out of repositories that configure them elsewhere." diff --git a/tests/lint-job-modes-contract.sh b/tests/lint-job-modes-contract.sh index 8093677a..ddbd5c32 100755 --- a/tests/lint-job-modes-contract.sh +++ b/tests/lint-job-modes-contract.sh @@ -14,7 +14,7 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" workflow="${repo_root}/.github/workflows/lint.yml" combined_job="all-linters" -linter_jobs=(dprint yamlfmt yamllint actionlint gitleaks go shellcheck shfmt checkov trivy zizmor ruff config-drift inline-scripts) +linter_jobs=(dprint yamlfmt yamllint actionlint gitleaks go shellcheck shfmt checkov trivy zizmor ruff biome config-drift inline-scripts) parallel_guard="(inputs.lint-job-mode == 'parallel' || (inputs.lint-job-mode == 'auto' && !github.event.repository.private))" fail() { diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index 56413a7a..f7821f01 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -31,6 +31,7 @@ which) [[ " ${FAKE_TOOLS} " == *" $2 "* ]] ;; exec) shift 2 printf '%s: %s\n' "${PWD}" "$*" >>"${MISE_LOG}" + [ -z "${FAKE_WRITES:-}" ] || touch "${FAKE_WRITES}" exit "${FAKE_EXIT:-0}" ;; *) exit 2 ;; @@ -120,7 +121,7 @@ expect_out "::error::'dprint' is not pinned in this repository's mise config." " [ -z "${log}" ] || fail "an unpinned tool must not run: ${log}" # Every linter that needs a pinned tool checks for it first. -for script in dprint yamlfmt yamllint shellcheck shfmt trivy ruff; do +for script in dprint yamlfmt yamllint shellcheck shfmt trivy ruff biome; do run "${script}" FAKE_TOOLS="" expect_status 1 "${script} without its tool" expect_out "::error::'${script}' is not pinned" "${script} without its tool" @@ -248,6 +249,35 @@ expect_status 0 "ruff without Python files" expect_out "::notice::No Python files found; skipping ruff" "ruff without Python files" [ -z "${log}" ] || fail "ruff must not run without Python files: ${log}" +# Biome checks the JavaScript, TypeScript, JSON and CSS files in one read-only +# `biome ci` run, which also writes SARIF when asked. +mkdir -p "${code}/.specify" +touch "${code}/a.json" "${code}/b.mjs" "${code}/sub/c.tsx" "${code}/sub/d.css" "${code}/e.md" "${code}/.specify/f.json" +git -C "${code}" add -f -- a.json b.mjs sub/c.tsx sub/d.css e.md .specify/f.json +listed="$(cd "${code}" && bash "${scripts}/language-files.sh" web | tr '\0' '\n')" +[ "${listed}" = $'a.json\nb.mjs\nsub/c.tsx\nsub/d.css' ] || + fail "language-files.sh web must list the JavaScript, TypeScript, JSON and CSS files; got: ${listed}" +export FAKE_TOOLS="${FAKE_TOOLS} biome" +biome_call="biome ci --no-errors-on-unmatched --reporter=default --reporter=github" +run_in "${code}" biome FAKE_WRITES="${RUNNER_TEMP}/biome.sarif" +expect_status 0 "Biome with SARIF" +expect_log "${biome_call} --reporter=sarif --reporter-file=${RUNNER_TEMP}/biome.sarif -- a.json b.mjs sub/c.tsx sub/d.css" \ + "Biome with SARIF" +[ "${outputs}" = sarif=true ] || fail "Biome must report its SARIF report; got: ${outputs}" +run_in "${code}" biome FAKE_EXIT=1 +expect_status 1 "a failing Biome" +[ -z "${outputs}" ] || fail "Biome must not report a SARIF report it didn't write: ${outputs}" +run_in "${code}" biome UPLOAD_SARIF=false +expect_status 0 "Biome without SARIF" +expect_log "${biome_call} -- a.json" "Biome without SARIF" +run_in "${code}" biome UPLOAD_SARIF=false EXCLUDE_PATTERN="sub/*" +[[ "${log}" == *"${biome_call} -- a.json b.mjs" ]] || fail "lint-biome-exclude must skip sub/: ${log}" +git -C "${code}" rm -q --cached a.json b.mjs sub/c.tsx sub/d.css +run_in "${code}" biome +expect_status 0 "Biome without its files" +expect_out "::notice::No JavaScript, TypeScript, JSON or CSS files found; skipping Biome" "Biome without its files" +[ -z "${log}" ] || fail "Biome must not run without its files: ${log}" + # The SARIF filter drops checkov's skipped checks (level none) and tolerates a # missing report. run checkov-sarif-filter diff --git a/tests/workflow-job-conditions.py b/tests/workflow-job-conditions.py index a604b4fa..e47c831d 100755 --- a/tests/workflow-job-conditions.py +++ b/tests/workflow-job-conditions.py @@ -421,6 +421,7 @@ def lint_context(*, mode="auto", private=False, has_repository=True, event_name= "trivy", "zizmor", "ruff", + "biome", "inline-scripts", ) } @@ -445,6 +446,7 @@ def lint_context(*, mode="auto", private=False, has_repository=True, event_name= "trivy", "zizmor", "ruff", + "biome", "inline-scripts", } SINGLE = {"all-linters"} diff --git a/workflow-templates/lint.yml b/workflow-templates/lint.yml index 60a9fcc3..bf16adce 100644 --- a/workflow-templates/lint.yml +++ b/workflow-templates/lint.yml @@ -65,6 +65,10 @@ jobs: # Optional: needs a lint.yml release after v4.5.0; runs only when the # repository has Python files. Pin ruff in your mise config. # lint-ruff: true + # Optional: needs a lint.yml release after v4.5.0; runs only when the + # repository has JavaScript, TypeScript, JSON or CSS files. Pin biome in + # your mise config. + # lint-biome: true # lint-config-drift: false # Optional: report inline scripts in run: steps. Needs a lint.yml release # after v4.4.0; bump the pin above before uncommenting. From 4b4916eb41033e760bcc1d1ef86f32a42a0e2130 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:08:25 +0100 Subject: [PATCH 3/7] fix(lint): limit Biome configs to the files the Lint workflow checks Biome 2.6 also formats Markdown and YAML, which dprint and yamlfmt own, so a local `biome ci .` with the template or this repository's config flagged those. Include only the JavaScript, TypeScript, JSON and CSS extensions, and force-ignore config-sync/templates in this repository's config so a whole-directory run doesn't find the template as a second root config. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- biome.json | 5 +++-- config-sync/templates/README.md | 3 ++- config-sync/templates/biome.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/biome.json b/biome.json index 55a03fb7..5775026c 100644 --- a/biome.json +++ b/biome.json @@ -7,7 +7,7 @@ }, "files": { "includes": [ - "**", + "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,json,jsonc,css}", "!**/node_modules", "!apm_modules", "!.agents", @@ -23,7 +23,8 @@ "!.opencode", "!.specify", "!.venv*", - "!.windsurf" + "!.windsurf", + "!!config-sync/templates" ] }, "formatter": { diff --git a/config-sync/templates/README.md b/config-sync/templates/README.md index 61856995..e597551b 100644 --- a/config-sync/templates/README.md +++ b/config-sync/templates/README.md @@ -108,7 +108,8 @@ replace those settings. ## biome.json Config for Biome, which the shared Lint workflow runs when the repo has -JavaScript, TypeScript, JSON or CSS files (`lint-biome`). It indents with two +JavaScript, TypeScript, JSON or CSS files (`lint-biome`). It limits Biome to +those files, leaving Markdown and YAML to dprint and yamlfmt, indents with two spaces, wraps at 120 columns, enables the recommended lint rules, respects `.gitignore` and skips the same generated and vendored paths as the shared `dprint.json`. Biome's other defaults (double quotes, semicolons) apply; change diff --git a/config-sync/templates/biome.json b/config-sync/templates/biome.json index 55a03fb7..9c8b33e2 100644 --- a/config-sync/templates/biome.json +++ b/config-sync/templates/biome.json @@ -7,7 +7,7 @@ }, "files": { "includes": [ - "**", + "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,json,jsonc,css}", "!**/node_modules", "!apm_modules", "!.agents", From 4e6a50223dfbc3e821389d819b864469cc08f477 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:24:37 +0100 Subject: [PATCH 4/7] fix(lint): let Biome step aside in repositories that configure ESLint Repositories with eslint.config.* or .eslintrc* lint JavaScript and TypeScript with ESLint and its plugins in their own CI. Biome would add a second linter there and, without a biome pin, a "not pinned" failure. Both job modes now skip Biome (and its mise install) when an ESLint config is tracked, as #539 proposes. A boolean input can't tell an explicit true from its default, so lint-biome-with-eslint opts such repositories in. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/lint-include.yml | 7 +++++++ .github/workflows/lint.yml | 10 ++++++++++ docs/architecture.md | 5 ++++- scripts/lint/detect-language.sh | 8 +++++++- scripts/lint/language-files.sh | 2 ++ tests/lint-include.py | 2 +- tests/lint-scripts.sh | 11 +++++++++++ workflow-templates/lint.yml | 4 ++-- 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint-include.yml b/.github/workflows/lint-include.yml index 78c67363..9b0a69b1 100644 --- a/.github/workflows/lint-include.yml +++ b/.github/workflows/lint-include.yml @@ -118,6 +118,12 @@ on: required: false type: string default: "" + lint-biome-with-eslint: + description: "Run Biome in repositories that configure ESLint too (eslint.config.* or .eslintrc*), where it steps + aside by default" + required: false + type: boolean + default: false lint-config-drift: description: "Check local config files match central DevSecNinja/.github repo" required: false @@ -185,6 +191,7 @@ jobs: lint-ruff: ${{ inputs.lint-ruff }} lint-biome: ${{ inputs.lint-biome }} lint-biome-exclude: ${{ inputs.lint-biome-exclude }} + lint-biome-with-eslint: ${{ inputs.lint-biome-with-eslint }} lint-config-drift: ${{ inputs.lint-config-drift }} lint-inline-scripts: ${{ inputs.lint-inline-scripts }} lint-inline-scripts-blocking: ${{ inputs.lint-inline-scripts-blocking }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9902f3c0..9a24123f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -110,6 +110,12 @@ on: required: false type: string default: "" + lint-biome-with-eslint: + description: "Run Biome in repositories that configure ESLint too (eslint.config.* or .eslintrc*), where it steps + aside by default" + required: false + type: boolean + default: false lint-config-drift: description: "Check local config files match central DevSecNinja/.github repo" required: false @@ -790,6 +796,8 @@ jobs: - name: Find JavaScript, TypeScript, JSON and CSS files # Repositories without them skip the mise install and Biome. id: web-files + env: + STEP_ASIDE_FOR: ${{ !inputs.lint-biome-with-eslint && 'eslint' || '' }} run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/detect-language.sh" web - name: Install mise @@ -948,6 +956,8 @@ jobs: # Repositories without them skip Biome (and its mise install). id: web-files if: ${{ inputs.lint-biome }} + env: + STEP_ASIDE_FOR: ${{ !inputs.lint-biome-with-eslint && 'eslint' || '' }} run: bash "${RUNNER_TEMP}/devsecninja-lint/scripts/lint/detect-language.sh" web - name: Install mise diff --git a/docs/architecture.md b/docs/architecture.md index a2b13557..b7c3cb0f 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -197,7 +197,9 @@ APM-deployed agent files, `node_modules`, `.venv*`). point. Findings are annotated on the PR, and with `upload-sarif` they also go to code scanning (category `biome`). `lint-biome-exclude` skips more paths, such as a directory with another root Biome config, which Biome rejects. - dprint formats only Markdown. + Biome steps aside in repositories that configure ESLint (`eslint.config.*`, + `.eslintrc*`), which lint in their own CI with their plugins; set + `lint-biome-with-eslint` to run both. dprint formats only Markdown. **Inline scripts.** Code in a `run:` block is out of reach of linters, formatters and tests, so a `run:` step may hold exactly one line with one @@ -255,6 +257,7 @@ runner's system Python, which ships PyYAML (`ubuntu-24.04`). | `lint-ruff` | Python linting (ruff, see above). Default: `true`. After v4.5.0. | | `lint-biome` | JS/TS/JSON/CSS linting (Biome). Default: `true`. After v4.5.0. | | `lint-biome-exclude` | Bash pattern of paths Biome skips. Default: `""`. After v4.5.0. | +| `lint-biome-with-eslint` | Run Biome next to ESLint. Default: `false`. After v4.5.0. | | `lint-config-drift` | Config-drift check. Default: `false`. | | `lint-inline-scripts` | Inline-script check (see above). Default: `true`. After v4.4.0. | | `lint-inline-scripts-blocking` | Report inline scripts as errors. Default: `false`. After v4.4.0. | diff --git a/scripts/lint/detect-language.sh b/scripts/lint/detect-language.sh index c7a048eb..f4fab2da 100755 --- a/scripts/lint/detect-language.sh +++ b/scripts/lint/detect-language.sh @@ -3,11 +3,17 @@ # Checks whether the repository has files of language $1, so its linter (and # the mise install it needs) runs only for repositories that have them. # A step of .github/workflows/lint.yml, run the same way in both lint modes. +# Env: STEP_ASIDE_FOR: another kind of language-files.sh, such as eslint; when +# the repository has those files too, the linter steps aside for that tool. # Writes found= to GITHUB_OUTPUT. set -eo pipefail -if [ -n "$(bash "$(dirname "${BASH_SOURCE[0]}")/language-files.sh" "$1" | head -c 1)" ]; then +files_sh="$(dirname "${BASH_SOURCE[0]}")/language-files.sh" +if [ -n "${STEP_ASIDE_FOR}" ] && [ -n "$(bash "${files_sh}" "${STEP_ASIDE_FOR}" | head -c 1)" ]; then + echo "::notice::The repository has ${STEP_ASIDE_FOR} config; skipping the $1 linter" + echo "found=false" >>"${GITHUB_OUTPUT}" +elif [ -n "$(bash "${files_sh}" "$1" | head -c 1)" ]; then echo "found=true" >>"${GITHUB_OUTPUT}" else echo "::notice::No $1 files found; skipping its linter" diff --git a/scripts/lint/language-files.sh b/scripts/lint/language-files.sh index c28633d9..dc6014cb 100755 --- a/scripts/lint/language-files.sh +++ b/scripts/lint/language-files.sh @@ -18,6 +18,8 @@ web) patterns=('**/*.js' '**/*.mjs' '**/*.cjs' '**/*.jsx' '**/*.ts' '**/*.mts' '**/*.cts' '**/*.tsx' '**/*.json' '**/*.jsonc' '**/*.css') ;; +# ESLint configs: Biome steps aside for repositories that lint with ESLint. +eslint) patterns=('**/eslint.config.*' '**/.eslintrc' '**/.eslintrc.*') ;; *) echo "::error::language-files.sh: unknown language '$1'" >&2 exit 2 diff --git a/tests/lint-include.py b/tests/lint-include.py index 287efc3e..71de8551 100755 --- a/tests/lint-include.py +++ b/tests/lint-include.py @@ -35,7 +35,7 @@ LINT_REF = "$/.github/workflows/lint.yml" # Boolean `lint-*` inputs of lint.yml that are options rather than linters. -NOT_LINTERS = {"lint-fail-on-error", "lint-inline-scripts-blocking"} +NOT_LINTERS = {"lint-fail-on-error", "lint-inline-scripts-blocking", "lint-biome-with-eslint"} LEVELS = {"none": 0, "read": 1, "write": 2} diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index f7821f01..e0fa4a08 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -257,6 +257,17 @@ git -C "${code}" add -f -- a.json b.mjs sub/c.tsx sub/d.css e.md .specify/f.json listed="$(cd "${code}" && bash "${scripts}/language-files.sh" web | tr '\0' '\n')" [ "${listed}" = $'a.json\nb.mjs\nsub/c.tsx\nsub/d.css' ] || fail "language-files.sh web must list the JavaScript, TypeScript, JSON and CSS files; got: ${listed}" +# Biome steps aside for ESLint, unless lint-biome-with-eslint clears STEP_ASIDE_FOR. +touch "${code}/sub/.eslintrc" +git -C "${code}" add -f -- sub/.eslintrc +run_in "${code}" "detect-language web" STEP_ASIDE_FOR=eslint +[ "${outputs}" = found=false ] || fail "Biome must step aside for ESLint; got: ${outputs}" +expect_out "::notice::The repository has eslint config; skipping the web linter" "a repository with ESLint" +run_in "${code}" "detect-language web" STEP_ASIDE_FOR= +[ "${outputs}" = found=true ] || fail "lint-biome-with-eslint must run Biome; got: ${outputs}" +git -C "${code}" rm -q --cached sub/.eslintrc +run_in "${code}" "detect-language web" STEP_ASIDE_FOR=eslint +[ "${outputs}" = found=true ] || fail "Biome must run without ESLint; got: ${outputs}" export FAKE_TOOLS="${FAKE_TOOLS} biome" biome_call="biome ci --no-errors-on-unmatched --reporter=default --reporter=github" run_in "${code}" biome FAKE_WRITES="${RUNNER_TEMP}/biome.sarif" diff --git a/workflow-templates/lint.yml b/workflow-templates/lint.yml index bf16adce..b815ee5e 100644 --- a/workflow-templates/lint.yml +++ b/workflow-templates/lint.yml @@ -66,8 +66,8 @@ jobs: # repository has Python files. Pin ruff in your mise config. # lint-ruff: true # Optional: needs a lint.yml release after v4.5.0; runs only when the - # repository has JavaScript, TypeScript, JSON or CSS files. Pin biome in - # your mise config. + # repository has JavaScript, TypeScript, JSON or CSS files and no ESLint + # config. Pin biome in your mise config. # lint-biome: true # lint-config-drift: false # Optional: report inline scripts in run: steps. Needs a lint.yml release From 6024ab0ed6cddc009b0c5b9707347879bdfd0757 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:35:52 +0100 Subject: [PATCH 5/7] fix(lint): skip Biome before its pin check when every file is excluded A repository whose files all match lint-biome-exclude needs no Biome pin, so check the pin after the empty-list guard. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- scripts/lint/biome.sh | 3 ++- tests/lint-scripts.sh | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/lint/biome.sh b/scripts/lint/biome.sh index 78a45c54..364663da 100755 --- a/scripts/lint/biome.sh +++ b/scripts/lint/biome.sh @@ -11,7 +11,6 @@ set -eo pipefail lint_dir="$(dirname "${BASH_SOURCE[0]}")" -bash "${lint_dir}/require-mise-tool.sh" biome mapfile -d '' listed < <(bash "${lint_dir}/language-files.sh" web) files=() for file in "${listed[@]}"; do @@ -25,6 +24,8 @@ if [ "${#files[@]}" -eq 0 ]; then echo "::notice::No JavaScript, TypeScript, JSON or CSS files found; skipping Biome" exit 0 fi +# After the guard: a repository whose files are all excluded needs no pin. +bash "${lint_dir}/require-mise-tool.sh" biome # The default reporter shows formatting diffs in the log, the github one # annotates the PR. --no-errors-on-unmatched: the config may ignore every file. diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index e0fa4a08..ad69d9da 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -121,7 +121,7 @@ expect_out "::error::'dprint' is not pinned in this repository's mise config." " [ -z "${log}" ] || fail "an unpinned tool must not run: ${log}" # Every linter that needs a pinned tool checks for it first. -for script in dprint yamlfmt yamllint shellcheck shfmt trivy ruff biome; do +for script in dprint yamlfmt yamllint shellcheck shfmt trivy ruff; do run "${script}" FAKE_TOOLS="" expect_status 1 "${script} without its tool" expect_out "::error::'${script}' is not pinned" "${script} without its tool" @@ -268,6 +268,13 @@ run_in "${code}" "detect-language web" STEP_ASIDE_FOR= git -C "${code}" rm -q --cached sub/.eslintrc run_in "${code}" "detect-language web" STEP_ASIDE_FOR=eslint [ "${outputs}" = found=true ] || fail "Biome must run without ESLint; got: ${outputs}" +run_in "${code}" biome FAKE_TOOLS="" +expect_status 1 "Biome without its tool" +expect_out "::error::'biome' is not pinned" "Biome without its tool" +# Excluding every file skips Biome before it needs a pin. +run_in "${code}" biome FAKE_TOOLS="" EXCLUDE_PATTERN="*" +expect_status 0 "Biome with every file excluded" +expect_out "::notice::No JavaScript, TypeScript, JSON or CSS files found; skipping Biome" "Biome with every file excluded" export FAKE_TOOLS="${FAKE_TOOLS} biome" biome_call="biome ci --no-errors-on-unmatched --reporter=default --reporter=github" run_in "${code}" biome FAKE_WRITES="${RUNNER_TEMP}/biome.sarif" From cc325c30ebbcb96e6d7c339e706eafba183e5841 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:07:53 +0100 Subject: [PATCH 6/7] fix(lint): warn and skip Biome when the repository doesn't pin it A repository with JavaScript, TypeScript, JSON or CSS files but no biome pin now gets a warning naming the fix (pin biome in .mise.toml, add a biome.json) and a skipped Biome run in both job modes, instead of a "not pinned" failure. Once biome is pinned, its findings fail as before. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- docs/architecture.md | 5 +++-- scripts/lint/biome.sh | 8 ++++++-- tests/lint-scripts.sh | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index b7c3cb0f..fdc8cdfc 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -190,8 +190,9 @@ APM-deployed agent files, `node_modules`, `.venv*`). - **Biome** (`lint-biome`, JavaScript, TypeScript, JSON and CSS, after v4.5.0) runs `biome ci`, which lints and checks formatting and import order without writing, on the `*.js`, `*.mjs`, `*.cjs`, `*.jsx`, `*.ts`, `*.mts`, `*.cts`, - `*.tsx`, `*.json`, `*.jsonc` and `*.css` files. Pin `biome` in the - repository's mise config. Biome reads the repository's own `biome.json` or + `*.tsx`, `*.json`, `*.jsonc` and `*.css` files. Biome runs once `biome` is + pinned in the repository's mise config; until then it warns how to opt in and + skips. Biome reads the repository's own `biome.json` or `biome.jsonc`; config-sync's [`biome.json` template](../config-sync/templates/biome.json) is a starting point. Findings are annotated on the PR, and with `upload-sarif` they also go diff --git a/scripts/lint/biome.sh b/scripts/lint/biome.sh index 364663da..de5be23e 100755 --- a/scripts/lint/biome.sh +++ b/scripts/lint/biome.sh @@ -24,8 +24,12 @@ if [ "${#files[@]}" -eq 0 ]; then echo "::notice::No JavaScript, TypeScript, JSON or CSS files found; skipping Biome" exit 0 fi -# After the guard: a repository whose files are all excluded needs no pin. -bash "${lint_dir}/require-mise-tool.sh" biome +# Biome is opt-in per repository: without a pin it warns and skips rather than +# failing. After the guard: a repository whose files are all excluded needs no pin. +if ! mise which biome >/dev/null 2>&1; then + echo "::warning::Skipping Biome: this repository has JavaScript, TypeScript, JSON or CSS files but doesn't pin biome. To lint them, pin it in .mise.toml (Renovate-managed, e.g. 'mise use biome@') and add a biome.json (config-sync's template is a starting point)." + exit 0 +fi # The default reporter shows formatting diffs in the log, the github one # annotates the PR. --no-errors-on-unmatched: the config may ignore every file. diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index ad69d9da..2044094d 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -268,9 +268,13 @@ run_in "${code}" "detect-language web" STEP_ASIDE_FOR= git -C "${code}" rm -q --cached sub/.eslintrc run_in "${code}" "detect-language web" STEP_ASIDE_FOR=eslint [ "${outputs}" = found=true ] || fail "Biome must run without ESLint; got: ${outputs}" +# Without a biome pin, Biome warns how to opt in and skips instead of failing. run_in "${code}" biome FAKE_TOOLS="" -expect_status 1 "Biome without its tool" -expect_out "::error::'biome' is not pinned" "Biome without its tool" +expect_status 0 "Biome without its tool" +expect_out "::warning::Skipping Biome: this repository has JavaScript, TypeScript, JSON or CSS files but doesn't pin biome." \ + "Biome without its tool" +expect_out "pin it in .mise.toml" "Biome without its tool" +[ -z "${log}${outputs}" ] || fail "Biome without its tool must not run: ${log} ${outputs}" # Excluding every file skips Biome before it needs a pin. run_in "${code}" biome FAKE_TOOLS="" EXCLUDE_PATTERN="*" expect_status 0 "Biome with every file excluded" From edf8d9fbfb0d1e8c99d1d72c4063647bdb7fedf0 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:50:37 +0100 Subject: [PATCH 7/7] fix(lint): warn and skip Biome older than 2.4.0 The Lint workflow runs Biome with several reporters and --reporter-file, which Biome 2.4.0 added. With an older pin, Biome now warns and asks for a newer pin instead of failing on the unknown options. Refs #539 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- docs/architecture.md | 6 +++--- scripts/lint/biome.sh | 7 +++++++ tests/lint-scripts.sh | 9 +++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index fdc8cdfc..77353210 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -190,9 +190,9 @@ APM-deployed agent files, `node_modules`, `.venv*`). - **Biome** (`lint-biome`, JavaScript, TypeScript, JSON and CSS, after v4.5.0) runs `biome ci`, which lints and checks formatting and import order without writing, on the `*.js`, `*.mjs`, `*.cjs`, `*.jsx`, `*.ts`, `*.mts`, `*.cts`, - `*.tsx`, `*.json`, `*.jsonc` and `*.css` files. Biome runs once `biome` is - pinned in the repository's mise config; until then it warns how to opt in and - skips. Biome reads the repository's own `biome.json` or + `*.tsx`, `*.json`, `*.jsonc` and `*.css` files. Biome runs once `biome` 2.4.0 or + later is pinned in the repository's mise config; until then it warns how to opt + in and skips. Biome reads the repository's own `biome.json` or `biome.jsonc`; config-sync's [`biome.json` template](../config-sync/templates/biome.json) is a starting point. Findings are annotated on the PR, and with `upload-sarif` they also go diff --git a/scripts/lint/biome.sh b/scripts/lint/biome.sh index de5be23e..277c198d 100755 --- a/scripts/lint/biome.sh +++ b/scripts/lint/biome.sh @@ -30,6 +30,13 @@ if ! mise which biome >/dev/null 2>&1; then echo "::warning::Skipping Biome: this repository has JavaScript, TypeScript, JSON or CSS files but doesn't pin biome. To lint them, pin it in .mise.toml (Renovate-managed, e.g. 'mise use biome@') and add a biome.json (config-sync's template is a starting point)." exit 0 fi +# Multiple reporters and --reporter-file need Biome 2.4.0 or later. +version="$(mise exec -- biome --version 2>/dev/null || true)" +version="${version##* }" +if [ -n "${version}" ] && [ "$(printf '%s\n' 2.4.0 "${version}" | sort -V | head -n 1)" != 2.4.0 ]; then + echo "::warning::Skipping Biome: the shared Lint workflow needs Biome 2.4.0 or later, and this repository pins ${version}. Update the biome pin in .mise.toml." + exit 0 +fi # The default reporter shows formatting diffs in the log, the github one # annotates the PR. --no-errors-on-unmatched: the config may ignore every file. diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index 2044094d..bcb05cd7 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -31,6 +31,7 @@ which) [[ " ${FAKE_TOOLS} " == *" $2 "* ]] ;; exec) shift 2 printf '%s: %s\n' "${PWD}" "$*" >>"${MISE_LOG}" + [ -z "${FAKE_STDOUT:-}" ] || echo "${FAKE_STDOUT}" [ -z "${FAKE_WRITES:-}" ] || touch "${FAKE_WRITES}" exit "${FAKE_EXIT:-0}" ;; @@ -289,6 +290,14 @@ expect_log "${biome_call} --reporter=sarif --reporter-file=${RUNNER_TEMP}/biome. run_in "${code}" biome FAKE_EXIT=1 expect_status 1 "a failing Biome" [ -z "${outputs}" ] || fail "Biome must not report a SARIF report it didn't write: ${outputs}" +# Biome before 2.4.0 lacks multiple reporters: it warns and skips. +run_in "${code}" biome FAKE_STDOUT="Version: 2.3.11" +expect_status 0 "Biome 2.3.11" +expect_out "::warning::Skipping Biome: the shared Lint workflow needs Biome 2.4.0 or later, and this repository pins 2.3.11." \ + "Biome 2.3.11" +[[ "${log}" != *"biome ci"* ]] || fail "Biome 2.3.11 must not run: ${log}" +run_in "${code}" biome FAKE_STDOUT="Version: 2.4.0" +expect_log "biome ci" "Biome 2.4.0" run_in "${code}" biome UPLOAD_SARIF=false expect_status 0 "Biome without SARIF" expect_log "${biome_call} -- a.json" "Biome without SARIF"