Skip to content

chore: Add husky pre-commit hook to enable lint-staged and strip resolved fields from package lock#2789

Merged
cschetan77 merged 4 commits into
masterfrom
chore/fix-package-lock
Apr 30, 2026
Merged

chore: Add husky pre-commit hook to enable lint-staged and strip resolved fields from package lock#2789
cschetan77 merged 4 commits into
masterfrom
chore/fix-package-lock

Conversation

@cschetan77
Copy link
Copy Markdown
Contributor

@cschetan77 cschetan77 commented Apr 28, 2026

Changes

package.json

  • Added prepare script to auto-initialise husky on npm install
  • Added package-lock.json to the lint-staged config to run the strip script whenever the lock file is staged

scripts/strip-lock-resolved.js — Reads package-lock.json and removes every resolved field across all packages. Supports lockfile v1, v2, and v3 formats.

.husky/pre-commit — Git hook that runs lint-staged on every commit. lint-staged handles running the correct scripts only for staged files and automatically re-stages modified files, so the strip only runs when package-lock.json is actually part of the commit, and ESLint/Prettier run only on staged JS/JSX files.

Note: lint-staged was already configured in package.json with ESLint and Prettier rules but was never being invoked by any hook. This PR wires it up for the first time, activating all three rules together.

@cschetan77 cschetan77 requested a review from a team as a code owner April 28, 2026 03:20
Comment thread scripts/strip-lock-resolved.js Fixed
Comment thread scripts/strip-lock-resolved.js Fixed
@cschetan77 cschetan77 changed the title chore: Add husky pre-commit hook to strip resolved fields from package lock chore: Add husky pre-commit hook to enable lint-staged and strip resolved fields from package lock Apr 30, 2026
@cschetan77 cschetan77 merged commit 12aaf5c into master Apr 30, 2026
5 checks passed
@cschetan77 cschetan77 deleted the chore/fix-package-lock branch April 30, 2026 10:39
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.

3 participants