Skip to content

Commit b34643c

Browse files
justin808claude
andcommitted
Fix linting issues in doctor functionality
- Fix Rainbow fallback to use Kernel-level method instead of class - Fix method naming (remove has_ and get_ prefixes) - Fix shadowed exception handling in system_checker - Fix regex patterns for version detection - Auto-fix formatting and style issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ff34380 commit b34643c

File tree

9 files changed

+109
-85
lines changed

9 files changed

+109
-85
lines changed

docs/contributor-info/coding-agents-guide.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This guide provides structured instructions for AI coding agents working with Re
1616
### Version Compatibility Matrix
1717

1818
| react_on_rails | Shakapacker | Webpack | Node.js | Ruby |
19-
|----------------|-------------|---------|---------|------|
19+
| -------------- | ----------- | ------- | ------- | ---- |
2020
| v16.x | >= 6.0 | v5 | 20-22 | 3.2+ |
2121
| v14.x | >= 6.0 | v5 | 18-20 | 2.7+ |
2222
| v13.x | >= 6.0 | v5 | 16-18 | 2.7+ |
@@ -206,25 +206,29 @@ fix_webpack_cache() {
206206
#### 1. Missing Routes File (js-routes gem)
207207

208208
**Detection:**
209+
209210
```regex
210211
/Cannot read properties of undefined.*reading 'module'/
211212
/ProvidedDependencyTemplate\.apply/
212213
```
213214

214215
**Auto-fix:**
216+
215217
```bash
216218
bundle exec rails js:export
217219
```
218220

219221
#### 2. ProvidePlugin Module Missing
220222

221223
**Detection:**
224+
222225
```regex
223226
/Error: Can't resolve.*\$app/
224227
/Module not found.*utils\/routes/
225228
```
226229

227230
**Auto-fix:**
231+
228232
```bash
229233
# Check if file exists, generate if missing
230234
[ -f "app/javascript/utils/routes.js" ] || bundle exec rails js:export
@@ -236,12 +240,14 @@ grep -q "\$app" config/webpack/*.js || echo "⚠️ Missing webpack alias"
236240
#### 3. Version Incompatibility
237241

238242
**Detection:**
243+
239244
```regex
240245
/webpack.*incompatible/
241246
/peer dep.*react-on-rails/
242247
```
243248

244249
**Auto-fix:**
250+
245251
```bash
246252
# Update to compatible versions
247253
npm install react-on-rails@^16.0.0
@@ -370,18 +376,21 @@ After successful upgrades, suggest:
370376
### If Build Completely Breaks
371377

372378
1. **Rollback immediately:**
379+
373380
```bash
374381
git checkout HEAD~1 -- Gemfile package.json Gemfile.lock package-lock.json
375382
bundle install
376383
npm install
377384
```
378385

379386
2. **Identify the issue:**
387+
380388
```bash
381389
npm run build 2>&1 | tee build-error.log
382390
```
383391

384392
3. **Apply targeted fixes:**
393+
385394
- Missing routes: `rails js:export`
386395
- Cache issues: `rm -rf node_modules/.cache tmp/cache`
387396
- Dependencies: `bundle update && npm install`
@@ -391,6 +400,7 @@ After successful upgrades, suggest:
391400
### If Rails Environment Unavailable
392401

393402
Use minimal commands:
403+
394404
```bash
395405
# Skip database operations
396406
DATABASE_URL=sqlite3:tmp/minimal.db rails js:export
@@ -401,4 +411,4 @@ RAILS_ENV=test rails js:export
401411

402412
---
403413

404-
This guide ensures consistent, reliable React on Rails operations for coding agents while providing clear error recovery paths.
414+
This guide ensures consistent, reliable React on Rails operations for coding agents while providing clear error recovery paths.

docs/guides/upgrading-react-on-rails.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ rails generate react_on_rails:install
8888
**Symptoms:** Webpack cannot find modules referenced in your configuration
8989

9090
**Solutions:**
91+
9192
1. Clear webpack cache: `rm -rf node_modules/.cache`
9293
2. Verify all ProvidePlugin modules exist
9394
3. Check webpack alias configuration

docs/javascript/troubleshooting-build-errors.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,80 +15,96 @@ This guide covers common webpack build errors encountered when using react_on_ra
1515
**Note:** This error only occurs if you're using the optional `js-routes` gem to access Rails routes in JavaScript.
1616

1717
### Error Message
18+
1819
```
1920
Cannot read properties of undefined (reading 'module')
2021
TypeError: Cannot read properties of undefined (reading 'module')
2122
at ProvidedDependencyTemplate.apply
2223
```
2324

2425
### Root Cause
26+
2527
This error occurs when:
28+
2629
1. Your webpack config references Rails routes via ProvidePlugin
2730
2. The `js-routes` gem hasn't generated the JavaScript routes file
2831
3. You're using `js-routes` integration but missing the generated file
2932

3033
### When You Need js-routes
34+
3135
`js-routes` is **optional** and typically used when:
36+
3237
- Rails-heavy apps with React components that need to navigate to Rails routes
3338
- Server-side rendered apps mixing Rails and React routing
3439
- Legacy Rails apps migrating ERB views to React
3540
- Apps using Rails routing patterns for RESTful APIs
3641

3742
### When You DON'T Need js-routes
43+
3844
Most modern React apps use:
45+
3946
- Client-side routing (React Router) instead of Rails routes
4047
- Hardcoded API endpoints or environment variables
4148
- SPA (Single Page App) architecture with API-only Rails backend
4249

4350
### Solution (if using js-routes)
51+
4452
1. **Generate JavaScript routes file:**
53+
4554
```bash
4655
bundle exec rails js:export
4756
```
4857

4958
2. **Verify the routes file was created:**
59+
5060
```bash
5161
ls app/javascript/utils/routes.js
5262
```
5363

5464
3. **Check webpack configuration includes ProvidePlugin:**
5565
```javascript
5666
new webpack.ProvidePlugin({
57-
Routes: "$app/utils/routes"
58-
})
67+
Routes: '$app/utils/routes',
68+
});
5969
```
6070

6171
### Alternative Solution (if NOT using js-routes)
72+
6273
Remove the Routes ProvidePlugin from your webpack configuration:
74+
6375
```javascript
6476
// Remove this line if you don't use js-routes
6577
new webpack.ProvidePlugin({
66-
Routes: "$app/utils/routes" // ← Remove this
67-
})
78+
Routes: '$app/utils/routes', // ← Remove this
79+
});
6880
```
6981

7082
## ProvidePlugin Module Resolution Errors
7183

7284
### Common Error Patterns
85+
7386
- `Cannot read properties of undefined (reading 'module')`
7487
- `Module not found: Error: Can't resolve 'module_name'`
7588
- `ERROR in ./path/to/file.js: Cannot find name 'GlobalVariable'`
7689

7790
### Debugging Steps
7891

7992
1. **Check file existence:**
93+
8094
```bash
8195
find app/javascript -name "routes.*" -type f
8296
find app/javascript -name "*global*" -type f
8397
```
8498

8599
2. **Verify webpack aliases:**
100+
86101
```javascript
87102
// In your webpack config
88103
console.log('Webpack aliases:', config.resolve.alias);
89104
```
90105

91106
3. **Test module resolution:**
107+
92108
```bash
93109
# Run webpack with debug output
94110
bin/shakapacker --debug-shakapacker
@@ -109,6 +125,7 @@ new webpack.ProvidePlugin({
109125
## Environment Setup Dependencies
110126

111127
### Rails Environment Required
128+
112129
Some operations require a working Rails environment:
113130

114131
- `rails js:export` (generates routes - **only needed if using js-routes gem**)
@@ -118,17 +135,20 @@ Some operations require a working Rails environment:
118135
### Common Issues
119136

120137
1. **Database Connection Errors:**
138+
121139
```
122140
MONGODB | Error checking localhost:27017: Connection refused
123141
```
124142

125143
**Solution:** These are usually warnings and don't prevent operation. To silence:
144+
126145
```bash
127146
# Run with minimal environment
128147
RAILS_ENV=development bundle exec rails js:export
129148
```
130149

131150
2. **Missing Dependencies:**
151+
132152
```
133153
sidekiq-pro is not installed
134154
```
@@ -138,6 +158,7 @@ Some operations require a working Rails environment:
138158
### Workarounds
139159

140160
1. **Skip database initialization:**
161+
141162
```bash
142163
DATABASE_URL=sqlite3:tmp/db.sqlite3 rails js:export
143164
```
@@ -152,14 +173,15 @@ Some operations require a working Rails environment:
152173
### Version Compatibility Matrix
153174

154175
| react_on_rails | Shakapacker | Webpack | Node.js |
155-
|----------------|-------------|---------|---------|
176+
| -------------- | ----------- | ------- | ------- |
156177
| v16.x | >= 6.0 | v5 | 20-22 |
157178
| v14.x | >= 6.0 | v5 | 18-20 |
158179
| v13.x | >= 6.0 | v5 | 16-18 |
159180

160181
### Common Upgrade Issues
161182

162183
1. **Webpacker to Shakapacker migration incomplete:**
184+
163185
```bash
164186
# Remove webpacker references
165187
grep -r "webpacker" config/
@@ -172,6 +194,7 @@ Some operations require a working Rails environment:
172194
```
173195

174196
### Migration Steps
197+
175198
1. Follow the [Shakapacker upgrade guide](https://github.com/shakacode/shakapacker/blob/main/docs/v6_upgrade.md)
176199
2. Update webpack configurations
177200
3. Regenerate configurations with `rails generate react_on_rails:install`
@@ -254,4 +277,4 @@ fi
254277

255278
- Check the [general troubleshooting guide](./troubleshooting-when-using-shakapacker.md)
256279
- Review [webpack configuration docs](./webpack.md)
257-
- Contact [[email protected]](mailto:[email protected]) for professional support
280+
- Contact [[email protected]](mailto:[email protected]) for professional support

0 commit comments

Comments
 (0)