name: precommit-check description: "Run pre-commit checks by formatting changed files with Prettier, then running typecheck and build. Use when preparing to commit in git-based JS/TS repos with npm scripts."
Precommit Check
Overview
Format changed files, then run typecheck and build. Treat warnings as non-blocking unless a command exits nonzero.
Workflow
Confirm you are in the repo root and git is available.
Format changed files with Prettier:
affected=$(git diff --name-only --diff-filter=ACM) if [ -n "$affected" ]; then git diff --name-only --diff-filter=ACM -z | xargs -0 npx prettier --write --ignore-unknown --log-level warn -- fiRun typecheck:
npm run typecheck.Run build:
npm run build.Report results:
- Fail on any nonzero exit code.
- Ignore warnings that do not affect logic, but mention them if they appear in output.