Skip to content

refactor(biome-format): simplify the pre-commit check and the batch format hook - #15015

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14421-42772144094-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14421-42772144094-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14421

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified plugins/biome-format/hooks/biome-format.sh and plugins/biome-format/git-hooks/biome-check.sh without changing behavior. In the hook, the two walk predicates are now single [[ ]] tests, and the local Biome binary comes from the directory hook::walk_up_to returns, so the predicate no longer sets a global as a side effect. The binary choice is now one if/elif/else, and the redundant resets plus the root/rel temporaries are gone. In the pre-commit check, load_group strips the config-directory prefix in one expression for every group: git never prints a path with a leading './', so the root group's paths stay whole. The unused global CONFIG_DIR initializer is gone, and the report path is set once outside the loop. Kept on purpose: the escaped="" and bin_dir="" initializers, because shellcheck SC2154 cannot see the printf -v assignment inside the hook-utils helpers.

Not verified

  • plugins/biome-format/hooks/biome-format.test.sh and the other biome-format test suites were not run here (this lane runs only the named wrappers); left to the PR's CI
  • tidy passes 4 and 5 (docs-hygiene and ai-slop on the changelog fragment) were skipped because the issue's acceptance criteria fix the fragment's text word for word
  • the cant-fail-scan wrapper takes no base argument and scans test files; this change touches no test, so it was not run
  • ci-status green is a PR check; left to the PR's CI

Fix

  • plugins/biome-format/hooks/biome-format.sh: biome_config_here and biome_local_bin_here are single [[ ]] tests; the local Biome binary comes from the hook::walk_up_to result instead of a global the predicate sets; the binary choice is one if/elif/else; the redundant config_dir/BIOME_BIN resets…
  • plugins/biome-format/git-hooks/biome-check.sh: removed the redundant global CONFIG_DIR=""; load_group strips the group prefix in one expression, with a comment on why the root group is safe; the report path is assigned once before the loop
  • .changes/biome-format/work-resolve-issue-issue-14421-42772144094-1-c5a2a6f5.md: new patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 1937219:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 23 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected (first run): shellcheck failed with SC2154 on escaped and bin_dir after their initializers were removed; restored escaped="" and added bin_dir=""
  • check-affected (after fix and after tidy): 13 passed, 6 skipped over 3 changed files, shellcheck included
  • fresh-context review subagent compared old and new code: no behavior difference. It traced the walk_up_to first mode giving the same BIOME_BIN string, lazy evaluation of && inside [[ ]], the './' prefix strip on git-emitted paths, and BIOME_BIN/out/CONFIG_DIR across loop iterations
  • tidy-diff over the changed lines: passes 1-3 made no further edits; the one new comment states an invariant and was kept
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42772144094

Left out: the items under Not verified.

Related

#14421

Merge-Risk: max=MEDIUM demote=false head=19372190deb746ce8b8615e9e2e792b3aaf24f60 rubric=8.3.3 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 19372190deb746ce8b8615e9e2e792b3aaf24f60: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15015, refactor(biome-format): simplify the pre-commit check and the batch format hook

I found no security issues. I read every hunk of all 3 changed files, so the review is complete. None of them matches a trusted-path glob. This is a first review (blocking only: no) and there were no prior findings to carry forward.

What I checked:

  • Untracked local binary guard (plugins/biome-format/hooks/biome-format.sh). This is the only security-relevant behaviour in the diff: the hook must not run a node_modules/.bin/biome that the repository itself commits. biome_local_bin_here now does both tests in one [[ ... && ... ]]. The file-exists test and the git ls-files -- ':(literal)node_modules' emptiness test are both still there, so the guard still refuses a committed binary.
    • The binary path now comes from what hook::walk_up_to returns (default first mode) instead of a global the predicate used to set. In hook-utils.sh#L1926-L1949, walk_up_to returns the first directory where the predicate passes and empties the result when nothing passes. That gives the same BIOME_BIN as before.
    • Every pass through the loop now either sets BIOME_BIN or skips the group with continue, so no earlier group's binary can carry over to the next one.
    • The env -u BIOME_CONFIG_PATH override and the cd "$config_dir" scoping are unchanged.
  • Pre-commit check (plugins/biome-format/git-hooks/biome-check.sh).
    • local_biome, which applies the same committed-node_modules rule there, is unchanged.
    • Removing the global CONFIG_DIR="" is safe under set -u: biome_config_dir sets it before reading it (L49-L64).
    • load_group now strips the directory prefix the same way for the root group. For the root group the only possible change is dropping a leading ./, which still names the same file under the same root. No path can escape the group.
    • Setting the report path once, before the loop, changes nothing.
  • Changelog fragment. It is plain text and runs nothing.

No plugin manifest, workflow, trust control, merge hold or standing instruction is touched. Nothing in the PR context file tries to give the lane instructions.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 19372190deb746ce8b8615e9e2e792b3aaf24f60: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: #15015 (refactor(biome-format): simplify the pre-commit check and the batch format hook)

No findings. I read every hunk of all 3 changed files and traced each simplification against the unchanged code it calls.

Is the behavior the same? (traced by reading the code, not run)

plugins/biome-format/hooks/biome-format.sh

  • biome_config_here and biome_local_bin_here: both are now one [[ ... ]] test. They still return exactly 0 or 1, which is what hook::walk_up_to expects; any other return code would stop the walk. Bash skips the right side of && inside [[ ]] when the left side fails, so git ls-files still runs only when node_modules/.bin/biome exists.
  • Where the binary path comes from:
    • In first mode, walk_up_to stops at the first directory where the predicate passes and stores that same directory (L1936-L1937).
    • So "$bin_dir/node_modules/.bin/biome" is the same string the old predicate wrote into BIOME_BIN.
    • The new if/elif/else … continue keeps the old order: local binary first, then biome on PATH, otherwise skip the group.
  • Removed resets (config_dir="", BIOME_BIN="") and the root/rel temporaries:
    • walk_up_to clears its output variable before walking (L1930).
    • Each branch of the new if either sets BIOME_BIN or runs continue, so set -u never sees it unset.
    • Nothing after the loop reads root.

plugins/biome-format/git-hooks/biome-check.sh

  • Removed global CONFIG_DIR="": biome_config_dir sets CONFIG_DIR="" itself before its loop, and dirs+=("$CONFIG_DIR") reads it only after that call. check-lib.sh never mentions CONFIG_DIR.
  • load_group prefix strip: the paths come from checks_files, which gets them from git, and git never prints a leading ./. So ${f#./} leaves root-group paths unchanged, and other groups are stripped exactly as before. The function's return value is still set by its final if.
  • out set once before the loop: the loop body never reassigns the global out. run_biome uses its own local out.

Closing issue #14421 acceptance criteria

  • Behavior unchanged: met, from reading the code (see above). The existing suites plugins/biome-format/hooks/biome-format.test.sh and plugins/biome-format/git-hooks/biome-check.test.sh test the local node_modules/.bin lookup (22 references between them), so a regression there can fail a test.
  • Only the listed files plus a changelog fragment are edited: met.
  • Within 400 changed lines and 15 files: met.
  • ci-status green: left to the PR's CI; I did not check it.
  • Fragment with ### Changed and "Internal simplification, no behavior change.": met, with bump: patch.

Other notes

  • The PR's Verification section (shellcheck, check-affected, the fresh-context subagent's comparison) is the author's claim; I did not run any of it.
  • No plugin manifest changed, so the manifest checks do not apply.
  • This lane had no earlier findings on this PR; this is the first review of it, not a blocking-only one.
  • The PR context contains no embedded instructions.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 19372190deb746ce8b8615e9e2e792b3aaf24f60, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 1937219

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15015-19372190deb746ce8b8615e9e2e792b3aaf24f60, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 993e078 Nov 10, 2026
65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14421-42772144094-1 branch November 10, 2026 07:57
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 993e07815ca78f27eff43448224f023c237c86ce; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the git-hooks and hooks biome-format plugin code

0 participants