Chore/setup husky lint staged - #409
Conversation
…g and pre-push type-checking
|
@A-one-tech please fix the CI. Thanks. |
|
Hey @A-one-tech, great initiative setting up Husky and lint-staged — this will definitely keep the codebase cleaner over time. CI is failing on the bundle-analysis check (the quality check passes fine). The issue is the same pattern that comes up when Husky is first introduced: the root A common fix is to make the prepare script CI-aware: // package.json
"prepare": "is-ci || husky"Or the simpler no-extra-dependency version: "prepare": "husky || true"Also worth noting: the CI runner is currently on Node 20, but one of the new dependencies ( Small tweaks, but once addressed this is ready to land! |
#Closes
#385
Summary
Configures Husky v9 and lint-staged v17 to run ESLint and Prettier on staged files before every commit, and
tsc --noEmitacross all backend/SDK packages before every push. This closes the feedback-loop gap where formatting and lint violations were only caught after a full CI run.Closes #
Problem
There was no pre-commit hook in the repository. Formatting violations and lint errors accumulated locally and were only surfaced after a 5-minute CI run, creating slow feedback loops and noisy PR diffs.
Changes
package.json"prepare": "husky"— auto-installs hooks when any contributor runsnpm installat the root.husky@9.1.7andlint-staged@17.0.8todevDependencies..lintstagedrc.json(new)Defines which tools run on which staged file types:
*.{ts,tsx,js,jsx,mjs,cjs}eslint --max-warnings=0 --no-warn-ignored, thenprettier --write*.{json,md,yml,yaml,css}prettier --write.husky/pre-commit(new)Runs
npx lint-stagedon everygit commit. Only staged files are checked — clean and fast..husky/pre-push(new)Runs
tsc --noEmitin parallel acrossapi/,xstreamroll-sdk/, andxstreamroll-processing/on everygit push. Theapp/Next.js package is intentionally excluded — its TypeScript is validated by the Next.js build pipeline.CONTRIBUTING.mdAdded a new Pre-commit Hooks section covering:
npm run prepare)--no-verify).lintstagedrc.jsonTesting
Pre-commit hook (lint-staged)
The hook fired automatically on the commit for this PR and ran successfully:
Pre-push hook (tsc --noEmit)
The hook fired on
git pushand all three packages passed type-checking:First-time install
npm run preparerunshuskycleanly with exit code 0 and sets up the.husky/_/husky.shshim.Checklist
huskyandlint-stagedconfigured at the roottsc --noEmiton affected packages (api,sdk,processing)CONTRIBUTING.mdupdated withnpm run preparesetup instructions