Skip to content

Run Husky pre-commit hooks with PNPM rather than NPM - #2548

Merged
rmunn merged 6 commits into
developfrom
chore/pnpx-husky
Aug 17, 2026
Merged

Run Husky pre-commit hooks with PNPM rather than NPM#2548
rmunn merged 6 commits into
developfrom
chore/pnpx-husky

Conversation

@rmunn

@rmunn rmunn commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Use PNPM first if it's there, fall back to NPM if PNPM not available.

Would make it slightly easier for me to create a minimal VM to run Claude Code: we use PNPM almost everywhere, but pre-commit hooks still require NPM. I'd rather not have NPM installed in my VM at all, and this would make that possible.

@rmunn rmunn self-assigned this Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2c90a85-db6f-47bc-95cb-7f463926876b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add pnpm-first command execution for Husky setup and lint-staged pre-commit checks. Each command falls back to an equivalent npx command when the pnpm command fails.

Changes

Package manager fallback commands

Layer / File(s) Summary
Husky setup fallback
Taskfile.yml
The setup task tries pnpm dlx husky first and falls back to npx --yes husky.
Pre-commit execution fallback
.husky/pre-commit
The hook tries pnpm exec lint-staged first and falls back to npx lint-staged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: myieye

Poem

A rabbit checks the setup run,
Pnpm hops ahead of npx in the sun.
If the first path cannot proceed,
A fallback follows at matching speed.
Husky and lint-staged spring along,
With reliable steps in their little song.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: using PNPM for Husky hooks while the changes preserve an NPM fallback.
Description check ✅ Passed The description accurately explains PNPM-first execution, NPM fallback, and the motivation for environments without NPM.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/pnpx-husky

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.husky/pre-commit:
- Line 1: Update the pre-commit command so the directory change is handled
separately and failure does not trigger the fallback. After entering
frontend/viewer, select pnpm exec lint-staged when pnpm is available, and use
npx lint-staged only when pnpm is unavailable; preserve the lint-staged exit
status.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4837cdc8-e140-4946-930b-2d928bc8b05d

📥 Commits

Reviewing files that changed from the base of the PR and between 8d27bbb and dfe91ce.

📒 Files selected for processing (2)
  • .husky/pre-commit
  • Taskfile.yml

Comment thread .husky/pre-commit Outdated

@myieye myieye left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say we just remove the fallbacks.

You can't develop Lexbox or fw lite without pnpm.

It was probably just an oversight on my part that we use npm/npx anywhere at all.

Keep the extension glob in the husky hook and only invoke lint-staged when a matching file is actually staged, so backend-only commits work without node_modules.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Aug 14, 2026
@hahn-kev

Copy link
Copy Markdown
Collaborator

ok it turns out lint-staged does something super useful, which is if you stage part of a file it only let linting run on that file. That's hard to do in bash. So now we have best of both worlds. The hook only runs when there's relevant files, it still uses lint-staged, but the config is inlined in the hook so it's obvious what's going on.

@hahn-kev
hahn-kev requested a review from myieye August 14, 2026 09:48
@argos-ci

argos-ci Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Aug 17, 2026, 4:05 AM
e2e (Inspect) ✅ No changes detected - Aug 17, 2026, 4:12 AM

myieye and others added 3 commits August 14, 2026 16:55
The hook needed frontend/viewer/node_modules to already exist, so a fresh
worktree had to run pnpm install before any commit touching a prettier-managed
file. Install it from the hook instead (gated on the same staged-file check, so
backend-only commits still skip Node). --frozen-lockfile keeps a commit from
rewriting pnpm-lock.yaml.

Also drop the npx fallback for husky: npm can't install this repo at all
(pnpm-workspace.yaml catalogs, pinned packageManager), so the fallback only
fires where nothing else works, and it hides real pnpm failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The check probes for the lint-staged binary, so an interrupted install (dir
present, binary absent) reported a missing directory that was right there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@myieye myieye left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I took it a slightly gutsy step further: the hook runs pnpm install if lint-staged is not yet available.
I feel like that'll mostly only ever happen when we want it to, so it seemed like an improvement.

The `set --` syntax pushes items into `$1`, `$2`, and so on, then the
`for` loop without an `in` clause loops over the script parameters. But
since these parameters aren't used elsewhere, it's simpler to just loop
over the list explicitly, and this avoids overwriting script parameters
if the pre-commit hook is ever changed to be called with params.

@rmunn rmunn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can't approve since GitHub considers me the author.

@rmunn
rmunn merged commit 61a34d9 into develop Aug 17, 2026
28 checks passed
@rmunn
rmunn deleted the chore/pnpx-husky branch August 17, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants