chore: add husky and lint-staged for pre-commit linting and type-checking (closes #404)#479
Conversation
Welcome to OSSfolio, @SakethSumanBathini! 🎉Thank you for opening this pull request and contributing to the open-source community! 🚀 To ensure a smooth review process, please make sure you have:
We will review your PR as soon as possible. Happy coding! 💻✨ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughHusky setup and a lint-staged configuration were added. The pre-commit hook now runs ESLint autofixes and project-wide TypeScript checks for relevant staged files. ChangesPre-commit tooling
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🎉 Your PR just got merged, @SakethSumanBathini — thank you for contributing to OSSfolio! Your work is now part of the project. Here's what to do next:
We really appreciate you taking the time. See you in the next PR! 🚀 |
Summary
Adds Husky + lint-staged so type errors and lint issues are caught locally before a commit lands,
instead of failing CI later (#404). On commit, staged JS/TS is auto-fixed with ESLint and the project is
type-checked with
tsc --noEmit; a failure blocks the commit.Two notes on how this maps to the issue, both deliberate:
prettier --write, but this project has no Prettier(no package, no config) — ESLint (flat config) is the linter/formatter here. I used
eslint --fixrather than introduce Prettier from scratch, which would be a larger change and could reformat the
codebase against existing conventions. Happy to add Prettier in a follow-up if you'd prefer it.
tscruns project-wide, not per-file. Passing staged filenames totscmakes it ignoretsconfig.json— including the@/*path aliases this codebase uses everywhere — so a per-file checkwould fail on almost every commit with false "Cannot find module" errors. The lint-staged config uses
the function form (
() => "tsc --noEmit") to run one project-wide type-check and ignore the stagedfilenames. ESLint still runs only on staged files, so the lint step stays fast.
Related issue
Closes #404
Type of Change
Changes Made
huskyandlint-stagedto devDependencies, and a"prepare": "husky"script so the hooksinstall on
npm install..husky/pre-commitrunsnpx lint-staged.lint-staged.config.mjs:eslint --fixon staged{js,jsx,ts,tsx};tsc --noEmitproject-wide onstaged
{ts,tsx}.AI Usage
Used Claude. Side effects worth noting: the hook blocks a commit if ESLint can't auto-fix an issue or if
tscfinds a type error — that's the intent, but it means a commit with a type error anywhere in theproject (not just the staged file) will be blocked, because
tscis project-wide.--no-verifyremainsavailable for intentional bypasses.
Screenshots (if UI change)
N/A — tooling only. Verified locally: committing a file with a type error is blocked by the hook;
committing clean files passes;
eslint --fixauto-fixes staged files.Checklist
mainconsole.logleft insrc/schema.sqland a new migration file are includedDESIGN.mdand followed the design systemSummary by CodeRabbit