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 ESLint to pre-commit hooks to prevent CI failures
Previously, pre-commit hooks only ran RuboCop, Prettier, and trailing
newline checks, but did NOT run ESLint. This meant ESLint errors could
slip through and only be caught in CI.
Changes:
- Created bin/lefthook/eslint-lint hook script that auto-fixes ESLint issues
- Added ESLint hook to .lefthook.yml pre-commit configuration
- Updated CLAUDE.md to document:
- The complete list of pre-commit hooks that run
- The monorepo structure with separate Pro package linting
- Why CI lints both directories separately
The hook follows the same pattern as other hooks:
- Detects changed JS/TS files (staged + unstaged + untracked)
- Runs ESLint with --fix to auto-correct issues
- Re-stages fixed files automatically
This prevents the frustrating situation where local commits succeed but
CI fails on ESLint violations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,12 @@ These requirements are non-negotiable. CI will fail if not followed.
17
17
18
18
Git hooks will automatically run linting on **all changed files (staged + unstaged + untracked)** before each commit - making it fast while preventing CI failures!
19
19
20
+
Pre-commit hooks automatically run:
21
+
-**RuboCop** (auto-fix Ruby code style)
22
+
-**ESLint** (auto-fix JS/TS code style)
23
+
-**Prettier** (auto-format all supported files)
24
+
-**Trailing newline checks** (ensure all files end with newlines)
25
+
20
26
**Note:** Git hooks are for React on Rails gem developers only, not for users who install the gem.
21
27
22
28
## Development Commands
@@ -90,13 +96,17 @@ Git hooks will automatically run linting on **all changed files (staged + unstag
90
96
91
97
## Project Architecture
92
98
93
-
### Dual Package Structure
99
+
### Monorepo Structure
94
100
95
-
This project maintains both a Ruby gem and an NPM package:
101
+
This is a monorepo containing both the open-source package and the Pro package:
96
102
103
+
-**Open Source**: Root directory contains the main React on Rails gem and package
104
+
-**Pro Package**: `react_on_rails_pro/` contains the Pro features (separate linting/formatting config)
97
105
-**Ruby gem**: Located in `lib/`, provides Rails integration and server-side rendering
98
106
-**NPM package**: Located in `packages/react-on-rails/src/`, provides client-side React integration
99
107
108
+
**IMPORTANT**: The `react_on_rails_pro/` directory has its own Prettier/ESLint configuration. When CI runs, it lints both directories separately. The pre-commit hooks will catch issues in both directories.
0 commit comments