Skip to content

Enabled lint-staged pre-commit hook on all branches#26792

Merged
cmraible merged 1 commit intomainfrom
cmraible/lint-staged-hook
Mar 12, 2026
Merged

Enabled lint-staged pre-commit hook on all branches#26792
cmraible merged 1 commit intomainfrom
cmraible/lint-staged-hook

Conversation

@cmraible
Copy link
Copy Markdown
Collaborator

@cmraible cmraible commented Mar 11, 2026

TL;DR

This adds a pre-commit hook that will run eslint on any JS/TS files staged for commit, and prevent the commit from completing if there are any errors.

Motivation

There's nothing more annoying than raising a PR only to see the lint job fail and having to follow up with a "fixed linter" commit. Especially as we are not always typing out the code ourselves in our IDEs anymore, I've been encountering these little annoyances more frequently.

Summary

  • Removed the main-branch-only guard from the pre-commit hook so lint-staged runs on every commit, regardless of branch
  • Expanded lint-staged file pattern from *.js to *.{js,ts,tsx,jsx,cjs} to cover TypeScript and CJS files
  • Verified lint-staged catches errors across all 16 monorepo packages (apps/, ghost/, e2e)

The pre-commit hook only ran lint-staged on the main branch, meaning
developers got no linting feedback on feature branches until merge.
Removed the branch guard so lint-staged runs on every commit, and
expanded the file pattern to include ts, tsx, jsx, and cjs files
alongside js.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2026

Walkthrough

This pull request modifies the pre-commit hook and linting configuration. The .github/hooks/pre-commit script removes a branch-specific condition that previously restricted lint-staged execution to the main branch, allowing it to run on all branches. The control flow is simplified with linting status now assigned immediately after execution. Additionally, package.json updates the lint-staged configuration to apply ESLint across a broader range of file types, extending from JavaScript only to include TypeScript and JSX variants.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: enabling the lint-staged pre-commit hook on all branches instead of just the main branch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly explains the motivation, changes, and scope—removing the branch guard, expanding file patterns to cover TS/JSX/CJS, and verifying across the monorepo.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cmraible/lint-staged-hook

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.19%. Comparing base (e7505d9) to head (2264e7f).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26792      +/-   ##
==========================================
- Coverage   73.20%   73.19%   -0.01%     
==========================================
  Files        1534     1534              
  Lines      121034   121048      +14     
  Branches    14635    14636       +1     
==========================================
+ Hits        88598    88605       +7     
- Misses      31405    31413       +8     
+ Partials     1031     1030       -1     
Flag Coverage Δ
admin-tests 54.34% <ø> (+0.02%) ⬆️
e2e-tests 73.19% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cmraible cmraible marked this pull request as ready for review March 11, 2026 21:21
@cmraible cmraible merged commit e0ed2e7 into main Mar 12, 2026
33 checks passed
@cmraible cmraible deleted the cmraible/lint-staged-hook branch March 12, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant