Problem
Prettier formatting drift on staged files goes undetected locally and only surfaces in the CI Format-Check step. This causes avoidable CI failures on otherwise-correct commits (most recently #755).
Proposed solution
Add a pre-commit hook that runs Prettier only on staged files using lint-staged + Husky.
This keeps the hook fast (ms per file, not seconds across the whole repo) and catches format issues before they ever reach CI.
Suggested implementation
npm install --save-dev husky lint-staged
npx husky init
.husky/pre-commit
package.json addition:
"lint-staged": {
"**/*.{scss,css,js,json,md}": "prettier --check"
}
Scope
- In scope: Prettier format-check on staged files only
- Out of scope: Running full
npm run lint (stylelint across all SCSS) or build:storybook in the pre-commit hook — both are too slow for interactive use
Acceptance criteria
Related
Problem
Prettier formatting drift on staged files goes undetected locally and only surfaces in the CI
Format-Checkstep. This causes avoidable CI failures on otherwise-correct commits (most recently #755).Proposed solution
Add a pre-commit hook that runs Prettier only on staged files using lint-staged + Husky.
This keeps the hook fast (ms per file, not seconds across the whole repo) and catches format issues before they ever reach CI.
Suggested implementation
.husky/pre-commitpackage.jsonaddition:Scope
npm run lint(stylelint across all SCSS) orbuild:storybookin the pre-commit hook — both are too slow for interactive useAcceptance criteria
huskyandlint-stagedadded as devDependenciesnpx husky initsets up.husky/pre-commitlint-stagedconfig inpackage.jsonrunsprettier --checkon staged.scss,.css,.js,.json, and.mdfilesnpm run lintandnpm run compile:checkstill passpreparescript added sonpm installauto-installs the hook for new contributorsRelated