hackforla / hackforla/VRMS

Add pre-commit hook to reject lock files from non-project package managers

Open
#2,139 0 comments 0 reactions 0 assignees View on GitHub
complexity: small Dependency - Icebox feature: Package Update role: devops size: 1pt
Dominant language
JavaScript
Stars
61
Forks
101
PR merge metrics
No merged PRs in 30d

Description

### Overview
PRs occasionally include lock files from package managers the project doesn't use (e.g. `package-lock.json` when the project uses Yarn). This causes confusion and bloats diffs. A pre-commit hook should reject these artifacts automatically.

### Action Items
- [ ] Add a pre-commit hook (e.g. via Husky) that checks for `package-lock.json` and `pnpm-lock.yaml` in staged files
- [ ] If detected, reject the commit with a message explaining the project uses Yarn and to run `yarn install` instead
- [ ] Add the hook setup to the project's dev dependencies if Husky is not already configured
- [ ] Consider adding `package-lock.json` and `pnpm-lock.yaml` to `.gitignore` as a secondary safeguard

### Resources/Instructions
- [Husky - Git hooks](https://typicode.github.io/husky/)
- [lint-staged](https://github.com/lint-staged/lint-staged) for running checks on staged files
- Motivated by PR #2134 where `package-lock.json` was accidentally introduced during the ESM migration

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.