You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add smart pre-commit hooks to prevent CI failures (#1792)
* Testing skip hooks option
* Implement automatic Git hooks with Lefthook for code quality
- Replace manual hook installation with modular Lefthook configuration
- Check all changed files (staged + unstaged + untracked) for comprehensive coverage
- Add separate scripts in bin/lefthook/ for testability and maintainability
- Automatic installation via script/bootstrap and package.json postinstall
- Provide helpful error messages with fix commands and skip options
- Parallel execution of linting checks for performance
Prevents CI failures by catching linting issues locally before commits.
Copy file name to clipboardExpand all lines: CLAUDE.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
12
12
13
13
These requirements are non-negotiable. CI will fail if not followed.
14
14
15
+
**🚀 AUTOMATIC: Git hooks are installed automatically during setup**
16
+
17
+
Git hooks will automatically run linting on **all changed files (staged + unstaged + untracked)** before each commit - making it fast while preventing CI failures!
18
+
19
+
**Note:** Git hooks are for React on Rails gem developers only, not for users who install the gem.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@
7
7
## Prerequisites
8
8
9
9
-[Yalc](https://github.com/whitecolor/yalc) must be installed globally for most local development.
10
+
-**Git hooks setup** (automatic during normal setup):
11
+
12
+
Git hooks are installed automatically when you run the standard setup commands. They will run automatic linting on **all changed files (staged + unstaged + untracked)** - making commits fast while preventing CI failures.
13
+
10
14
- After updating code via Git, to prepare all examples:
11
15
12
16
```sh
@@ -457,7 +461,9 @@ This approach:
457
461
458
462
## Pre-Commit Requirements
459
463
460
-
**CRITICAL**: Before committing any changes, always run the following commands to ensure code quality:
464
+
**AUTOMATED**: If you've set up Lefthook (see Prerequisites), linting runs automatically on changed files before each commit.
465
+
466
+
**MANUAL OPTION**: If you need to run linting manually:
461
467
462
468
```bash
463
469
# Navigate to the main react_on_rails directory
@@ -476,14 +482,14 @@ rake lint:rubocop
476
482
rake lint
477
483
```
478
484
479
-
**Automated checks:**
485
+
**Git hooks automatically run:**
480
486
481
-
- Format all JavaScript/TypeScript files with Prettier
487
+
- Format JavaScript/TypeScript files with Prettier (on changed files only)
482
488
- Check and fix linting issues with ESLint
483
-
- Check and fix Ruby style issues with RuboCop
484
-
- Ensure all tests pass before pushing
489
+
- Check and fix Ruby style issues with RuboCop (on all changed files)
490
+
- Ensure trailing newlines on all files
485
491
486
-
**Tip**: Set up your IDE to run these automatically on save to catch issues early.
492
+
**Setup**: Automatic during normal development setup
0 commit comments