Commit 74b9038
fix: Address code review issues in JS dependency manager
This commit addresses all code review feedback:
1. Improved instance variable initialization pattern
- Changed from @added_dependencies_to_package_json ||= false
- To: @added_dependencies_to_package_json = false unless defined?(@added_dependencies_to_package_json)
- Added clear documentation explaining the initialization is done by the module
2. Made error messages more specific
- All raise statements now include which packages failed
- Added context that failure indicates shakapacker may not be properly installed
- Error messages now help users understand what went wrong
3. Documented add_js_dependency method usage
- Added YARD-style documentation
- Clarified it's used for single package with version (react-on-rails@VERSION)
- Explained add_js_dependencies_batch is for batch operations
- Both methods now have clear @param and @return documentation
4. Fixed TypeScript dependency installation inconsistency
- Removed manual instance variable setting
- Now uses consistent pattern with shared module approach
- Raises specific error instead of just warning if installation fails
- Matches the error handling pattern of other dependency methods
5. Fixed RuboCop violations
- Removed redundant begin block in install_js_dependencies
- All files now pass bundle exec rubocop with zero offenses
All tests pass successfully (6 examples, 0 failures).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent fd56259 commit 74b9038
File tree
2 files changed
+45
-38
lines changed- lib/generators/react_on_rails
2 files changed
+45
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
388 | 382 | | |
389 | 383 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 384 | + | |
397 | 385 | | |
398 | 386 | | |
399 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| |||
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | | - | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
98 | | - | |
| 102 | + | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
109 | | - | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| |||
131 | 145 | | |
132 | 146 | | |
133 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
134 | 155 | | |
135 | 156 | | |
136 | 157 | | |
137 | 158 | | |
138 | 159 | | |
139 | 160 | | |
140 | 161 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
156 | 175 | | |
157 | 176 | | |
158 | 177 | | |
| |||
0 commit comments