Skip to content

fix(infra): guard lint-staged in pre-commit hook (#1077) - #1593

Open
emarkees wants to merge 1 commit into
LabsCrypt:mainfrom
emarkees:fix/husky-pre-commit-1077
Open

emarkees wants to merge 1 commit into
LabsCrypt:mainfrom
emarkees:fix/husky-pre-commit-1077

Conversation

@emarkees

@emarkees emarkees commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Title

[Infra] Guard lint-staged in .husky/pre-commit with fallback message (#1077)

Closes #1077

PR Description

📝 Summary

Updates .husky/pre-commit to include a local binary guard check for lint-staged. If lint-staged is not installed or executable in node_modules, it prints a user-friendly error message pointing to npm install and exits cleanly with status 1.

❓ Why this matters

Fixes issue #1077. Previously, .husky/pre-commit ran npx lint-staged directly without local installation checks. When a contributor's environment was offline or missing node_modules, npx failed with a cryptic error instead of instructing the developer to run npm install.

🛠 Changes

  • Updated .husky/pre-commit with a sh shebang, guard comment, and executable check [ ! -x ./node_modules/.bin/lint-staged ].
  • Prints clear error message to stderr on failure.
  • Bypasses npx lookup latency by invoking local ./node_modules/.bin/lint-staged directly.

🧪 Verification

  • Verified hook failure output when lint-staged is missing (lint-staged is not installed locally. Run 'npm install' before committing.).
  • Verified execution of lint-staged when local dependencies are installed.

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.

[Infra] .husky/pre-commit only runs lint-staged with no fallback message when npx is unavailable

1 participant