Skip to content

chore: add husky and lint-staged for pre-commit linting and type-checking (closes #404)#479

Merged
PRODHOSH merged 1 commit into
PRODHOSH:mainfrom
SakethSumanBathini:chore/404-husky-lint-staged
Jul 18, 2026
Merged

chore: add husky and lint-staged for pre-commit linting and type-checking (closes #404)#479
PRODHOSH merged 1 commit into
PRODHOSH:mainfrom
SakethSumanBathini:chore/404-husky-lint-staged

Conversation

@SakethSumanBathini

@SakethSumanBathini SakethSumanBathini commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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:

  • ESLint instead of Prettier. The issue mentions prettier --write, but this project has no Prettier
    (no package, no config) — ESLint (flat config) is the linter/formatter here. I used eslint --fix
    rather 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.
  • tsc runs project-wide, not per-file. Passing staged filenames to tsc makes it ignore
    tsconfig.json — including the @/* path aliases this codebase uses everywhere — so a per-file check
    would 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 staged
    filenames. ESLint still runs only on staged files, so the lint step stays fast.

Related issue

Closes #404

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Chore / dependency update

Changes Made

  • Added husky and lint-staged to devDependencies, and a "prepare": "husky" script so the hooks
    install on npm install.
  • .husky/pre-commit runs npx lint-staged.
  • lint-staged.config.mjs: eslint --fix on staged {js,jsx,ts,tsx}; tsc --noEmit project-wide on
    staged {ts,tsx}.

AI Usage

  • I did not use AI for any part of the code in this PR
  • I used AI for coding (specify which tool below) and I fully understand every change I made

Used Claude. Side effects worth noting: the hook blocks a commit if ESLint can't auto-fix an issue or if
tsc finds a type error — that's the intent, but it means a commit with a type error anywhere in the
project (not just the staged file) will be blocked, because tsc is project-wide. --no-verify remains
available 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 --fix auto-fixes staged files.

Checklist

  • I was assigned to the issue before opening this PR
  • My branch is up to date with main
  • Code works locally and I have tested it
  • No console.log left in src/
  • If schema changed — both schema.sql and a new migration file are included
  • If this is a UI change — I read DESIGN.md and followed the design system
  • Docs updated if needed
  • PR title follows Conventional Commits format
  • This PR description is written in my own words

Summary by CodeRabbit

  • Chores
    • Added automated checks for staged JavaScript and TypeScript files before commits.
    • Enabled automatic ESLint fixes and project-wide TypeScript validation during the commit workflow.
    • Added setup scripts to initialize these checks automatically.

@github-actions

Copy link
Copy Markdown
Contributor

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:

  • Checked that your changes work locally and compile cleanly.
  • Followed the guidelines outlined in CONTRIBUTING.md.
  • Linked your PR to an open issue (e.g. Closes #ISSUE_NUMBER).

We will review your PR as soon as possible. Happy coding! 💻✨

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0adae79e-0c78-4988-a18d-a9159c6fac14

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9f7cb and 318c97f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .husky/pre-commit
  • lint-staged.config.mjs
  • package.json

📝 Walkthrough

Walkthrough

Husky 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.

Changes

Pre-commit tooling

Layer / File(s) Summary
Lint-staged configuration
package.json, lint-staged.config.mjs
Adds Husky and lint-staged, enables the Husky prepare script, and configures ESLint and tsc --noEmit for staged JavaScript and TypeScript files.
Pre-commit hook wiring
.husky/pre-commit
Runs npx lint-staged from the pre-commit hook.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

I’m a bunny with commits in flight,
Linting staged code till it’s right.
Husky hops before the gate,
TypeScript checks won’t have to wait.
Clean little changes, sealed up tight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds Husky, lint-staged, staged-file ESLint, and project-wide type-checking, but it omits the requested Prettier write step from #404. Add a Prettier-based staged-file formatting step, or update #404 if ESLint-only formatting is the intended approach.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s main change: adding Husky and lint-staged for pre-commit linting and type-checking.
Out of Scope Changes check ✅ Passed The changes stay focused on the pre-commit workflow, dependencies, and lint-staged configuration with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PRODHOSH
PRODHOSH self-requested a review July 18, 2026 05:18
@PRODHOSH PRODHOSH added ELUSOC ELUSOC project submission completed NEWBIE Beginner — 10 pts beginner Good for newcomers labels Jul 18, 2026
@PRODHOSH
PRODHOSH merged commit f7ed47a into PRODHOSH:main Jul 18, 2026
8 of 11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 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:

  • ⭐ If you haven't already, consider giving the repo a star — it helps us grow.
  • 📢 Share your contribution on LinkedIn, Twitter, or wherever you hang out. You shipped open source!
  • 🔍 Browse other open issues if you want to keep contributing.

We really appreciate you taking the time. See you in the next PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginner Good for newcomers completed ELUSOC ELUSOC project submission NEWBIE Beginner — 10 pts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] Add Husky and lint-staged for pre-commit hooks

2 participants