Files
langflow/.github/workflows/lint-js.yml
Eric Hare d6d1692b70 fix(ci): make release Biome lint green — NUL-delimit file list + clear pre-existing lint errors (#13550)
The Lint Frontend job runs against `main` as the base. In a release
(workflow_dispatch) run it diffs the entire release branch (~915 files) and
re-lints nearly the whole frontend, exposing two issues that per-PR linting
never hits together:

1. xargs split starter-project spec paths containing spaces (e.g.
   "News Aggregator.spec.ts" -> "News" + "Aggregator.spec.ts"), producing
   `internalError/io: No such file or directory`. NUL-delimit the file list
   so spaces are preserved. (supersedes #13381)

2. The whole-branch diff surfaced 30 pre-existing Biome errors: 22
   noExplicitAny + 8 organizeImports. Resolved with real types where safe
   (freezeObject generic, ColDef defaults, messagesSorter field shape,
   VertexBuildTypeAPI, Record<string,string>, DragEvent<HTMLElement>,
   unknown for narrowed values) and justified biome-ignore for genuinely
   loose cases (polymorphic display values, test global stubs, captured
   unexported StreamCallbacks). Imports auto-sorted via biome.

Verified locally: biome check on the full release-vs-main file set is now 0
errors (was 30); tsc unchanged at its 303-error baseline (no new type errors).
2026-06-10 14:05:58 -07:00

106 lines
3.5 KiB
YAML

name: Lint Frontend
on:
workflow_call:
inputs:
allow-failure:
description: "When true, Biome errors are reported but job exits 0 (non-blocking)."
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
branch:
description: "(Optional) Branch to checkout"
required: false
type: string
env:
NODE_VERSION: "22"
jobs:
run-linters:
name: Run Biome
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch || github.ref }}
# Need full history so biome can diff against the PR base
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
id: setup-node
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js dependencies
uses: actions/cache@v5
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node.js dependencies
run: |
cd src/frontend
npm install
if: ${{ steps.setup-node.outputs.cache-hit != 'true' }}
- name: Run Biome on PR-changed files
run: |
# Determine the branch this PR targets (falls back to `main` for
# workflow_dispatch / non-PR contexts).
BASE_REF="${{ github.base_ref || 'main' }}"
echo "=== Debug ==="
echo "HEAD: $(git rev-parse HEAD)"
echo "BASE_REF: $BASE_REF"
echo "origin/$BASE_REF: $(git rev-parse "origin/$BASE_REF" 2>/dev/null || echo NOT_FOUND)"
# Merge-base = the commit where this branch forked off its target.
# Diffing against it yields ONLY the files this PR introduced,
# ignoring unrelated upstream changes merged into the base since.
MERGE_BASE=$(git merge-base HEAD "origin/$BASE_REF")
echo "MERGE_BASE: $MERGE_BASE"
# Collect frontend files modified in this PR. Filter to file types
# biome can process (ts/tsx/js/jsx/json/jsonc and the like).
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR \
"$MERGE_BASE"...HEAD -- 'src/frontend/' \
| grep -E '\.(tsx?|jsx?|c(js|ts)|m(js|ts)|jsonc?)$' \
|| true)
if [ -z "$CHANGED_FILES" ]; then
echo "No frontend files changed in this PR — skipping biome."
exit 0
fi
echo "=== Files to lint ==="
echo "$CHANGED_FILES"
# Biome runs from src/frontend; strip that prefix from paths.
RELATIVE_FILES=$(echo "$CHANGED_FILES" | sed 's|^src/frontend/||')
cd src/frontend
# NUL-delimit so paths containing spaces (e.g. starter-project
# specs like "Basic Prompting.spec.ts") aren't split by xargs.
if ${{ inputs.allow-failure || 'false' }}; then
printf '%s\n' "$RELATIVE_FILES" | tr '\n' '\0' \
| xargs -0 npx @biomejs/biome check \
--files-ignore-unknown=true \
--diagnostic-level=error || echo "Biome found errors (non-blocking for this run)."
else
printf '%s\n' "$RELATIVE_FILES" | tr '\n' '\0' \
| xargs -0 npx @biomejs/biome check \
--files-ignore-unknown=true \
--diagnostic-level=error
fi