react_on_rails 14.2.1 → 16.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AI_AGENT_INSTRUCTIONS.md +63 -0
- data/CHANGELOG.md +564 -85
- data/CLAUDE.md +135 -0
- data/CODING_AGENTS.md +313 -0
- data/CONTRIBUTING.md +448 -37
- data/Gemfile.development_dependencies +6 -1
- data/Gemfile.lock +13 -4
- data/KUDOS.md +22 -1
- data/LICENSE.md +30 -4
- data/LICENSES/README.md +14 -0
- data/NEWS.md +48 -48
- data/PROJECTS.md +45 -40
- data/REACT-ON-RAILS-PRO-LICENSE.md +129 -0
- data/README.md +113 -42
- data/SUMMARY.md +62 -52
- data/TODO.md +135 -0
- data/bin/lefthook/check-trailing-newlines +38 -0
- data/bin/lefthook/get-changed-files +26 -0
- data/bin/lefthook/prettier-format +26 -0
- data/bin/lefthook/ruby-autofix +26 -0
- data/bin/lefthook/ruby-lint +27 -0
- data/eslint.config.ts +232 -0
- data/knip.ts +40 -6
- data/lib/generators/USAGE +4 -5
- data/lib/generators/react_on_rails/USAGE +65 -0
- data/lib/generators/react_on_rails/base_generator.rb +276 -62
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -0
- data/lib/generators/react_on_rails/generator_helper.rb +35 -1
- data/lib/generators/react_on_rails/generator_messages.rb +138 -17
- data/lib/generators/react_on_rails/install_generator.rb +474 -26
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +19 -6
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +110 -18
- data/lib/generators/react_on_rails/templates/.eslintrc +1 -1
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +5 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-prod-assets +8 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static-assets +2 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +0 -5
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +2 -2
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorldServer.js +1 -1
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.js +1 -8
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx +21 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.tsx +25 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css +4 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx +5 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.server.tsx +5 -0
- data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb +4 -2
- data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +5 -2
- data/lib/generators/react_on_rails/templates/base/base/bin/dev +34 -0
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +14 -5
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +76 -7
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +6 -10
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +2 -2
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +3 -2
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +2 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +0 -2
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/actions/helloWorldActionCreators.ts +18 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +0 -6
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +4 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +24 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/constants/helloWorldConstants.ts +6 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/containers/HelloWorldContainer.ts +20 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js +1 -1
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.ts +22 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.client.tsx +23 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.server.jsx +5 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.server.tsx +5 -0
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.ts +18 -0
- data/lib/react_on_rails/configuration.rb +141 -57
- data/lib/react_on_rails/controller.rb +6 -2
- data/lib/react_on_rails/dev/file_manager.rb +78 -0
- data/lib/react_on_rails/dev/pack_generator.rb +27 -0
- data/lib/react_on_rails/dev/process_manager.rb +61 -0
- data/lib/react_on_rails/dev/server_manager.rb +487 -0
- data/lib/react_on_rails/dev.rb +20 -0
- data/lib/react_on_rails/doctor.rb +1149 -0
- data/lib/react_on_rails/engine.rb +6 -0
- data/lib/react_on_rails/git_utils.rb +12 -2
- data/lib/react_on_rails/helper.rb +176 -74
- data/lib/react_on_rails/json_parse_error.rb +6 -1
- data/lib/react_on_rails/packer_utils.rb +61 -71
- data/lib/react_on_rails/packs_generator.rb +221 -19
- data/lib/react_on_rails/prerender_error.rb +4 -0
- data/lib/react_on_rails/pro/NOTICE +21 -0
- data/lib/react_on_rails/pro/helper.rb +122 -0
- data/lib/react_on_rails/pro/utils.rb +53 -0
- data/lib/react_on_rails/react_component/render_options.rb +38 -6
- data/lib/react_on_rails/server_rendering_js_code.rb +0 -1
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +12 -5
- data/lib/react_on_rails/system_checker.rb +659 -0
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +6 -4
- data/lib/react_on_rails/test_helper.rb +2 -3
- data/lib/react_on_rails/utils.rb +139 -43
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +14 -20
- data/lib/react_on_rails/version_syntax_converter.rb +1 -1
- data/lib/react_on_rails.rb +1 -0
- data/lib/tasks/assets.rake +1 -1
- data/lib/tasks/doctor.rake +48 -0
- data/lib/tasks/generate_packs.rake +158 -1
- data/react_on_rails.gemspec +1 -0
- data/tsconfig.eslint.json +6 -0
- data/tsconfig.json +5 -3
- metadata +63 -14
- data/REACT-ON-RAILS-PRO-LICENSE +0 -95
- data/lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb +0 -41
- data/lib/generators/react_on_rails/bin/dev +0 -30
- data/lib/generators/react_on_rails/bin/dev-static +0 -30
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt +0 -9
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -5
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/registration.js.tt +0 -8
- /data/lib/generators/react_on_rails/templates/base/base/config/webpack/{webpackConfig.js.tt → generateWebpackConfigs.js.tt} +0 -0
- /data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/{HelloWorldApp.jsx → HelloWorldApp.client.jsx} +0 -0
data/CLAUDE.md
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# CLAUDE.md
|
2
|
+
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
4
|
+
|
5
|
+
## ⚠️ CRITICAL REQUIREMENTS
|
6
|
+
|
7
|
+
**BEFORE EVERY COMMIT/PUSH:**
|
8
|
+
|
9
|
+
1. **ALWAYS run `bundle exec rubocop` and fix ALL violations**
|
10
|
+
2. **ALWAYS ensure files end with a newline character**
|
11
|
+
3. **NEVER push without running full lint check first**
|
12
|
+
4. **ALWAYS let Prettier and RuboCop handle ALL formatting - never manually format**
|
13
|
+
|
14
|
+
These requirements are non-negotiable. CI will fail if not followed.
|
15
|
+
|
16
|
+
**🚀 AUTOMATIC: Git hooks are installed automatically during setup**
|
17
|
+
|
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
|
+
|
20
|
+
**Note:** Git hooks are for React on Rails gem developers only, not for users who install the gem.
|
21
|
+
|
22
|
+
## Development Commands
|
23
|
+
|
24
|
+
### Essential Commands
|
25
|
+
|
26
|
+
- **Install dependencies**: `bundle && yarn`
|
27
|
+
- **Run tests**:
|
28
|
+
- Ruby tests: `rake run_rspec`
|
29
|
+
- JavaScript tests: `yarn run test` or `rake js_tests`
|
30
|
+
- All tests: `rake` (default task runs lint and all tests except examples)
|
31
|
+
- **Linting** (MANDATORY BEFORE EVERY COMMIT):
|
32
|
+
- **REQUIRED**: `bundle exec rubocop` - Must pass with zero offenses
|
33
|
+
- All linters: `rake lint` (runs ESLint and RuboCop)
|
34
|
+
- ESLint only: `yarn run lint` or `rake lint:eslint`
|
35
|
+
- RuboCop only: `rake lint:rubocop`
|
36
|
+
- **Code Formatting**:
|
37
|
+
- Format code with Prettier: `rake autofix`
|
38
|
+
- Check formatting without fixing: `yarn start format.listDifferent`
|
39
|
+
- **Build**: `yarn run build` (compiles TypeScript to JavaScript in node_package/lib)
|
40
|
+
- **Type checking**: `yarn run type-check`
|
41
|
+
- **⚠️ MANDATORY BEFORE GIT PUSH**: `bundle exec rubocop` and fix ALL violations + ensure trailing newlines
|
42
|
+
- Never run `npm` commands, only equivalent Yarn Classic ones
|
43
|
+
|
44
|
+
## ⚠️ FORMATTING RULES
|
45
|
+
|
46
|
+
**Prettier is the SOLE authority for formatting non-Ruby files, and RuboCop for formatting Ruby files. NEVER manually format code.**
|
47
|
+
|
48
|
+
### Standard Workflow
|
49
|
+
1. Make code changes
|
50
|
+
2. Run `rake autofix` or `yarn start format`
|
51
|
+
3. Commit changes
|
52
|
+
|
53
|
+
### Merge Conflict Resolution Workflow
|
54
|
+
**CRITICAL**: When resolving merge conflicts, follow this exact sequence:
|
55
|
+
|
56
|
+
1. **Resolve logical conflicts only** - don't worry about formatting
|
57
|
+
2. **Add resolved files**: `git add .` (or specific files)
|
58
|
+
3. **Auto-fix everything**: `rake autofix`
|
59
|
+
4. **Add any formatting changes**: `git add .`
|
60
|
+
5. **Continue rebase/merge**: `git rebase --continue` or `git commit`
|
61
|
+
|
62
|
+
**❌ NEVER manually format during conflict resolution** - this causes formatting wars between tools.
|
63
|
+
|
64
|
+
### Debugging Formatting Issues
|
65
|
+
- Check current formatting: `yarn start format.listDifferent`
|
66
|
+
- Fix all formatting: `rake autofix`
|
67
|
+
- If CI fails on formatting, always run automated fixes, never manual fixes
|
68
|
+
|
69
|
+
### Development Setup Commands
|
70
|
+
|
71
|
+
- **Initial setup**: `bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake`
|
72
|
+
- **Prepare examples**: `rake shakapacker_examples:gen_all`
|
73
|
+
- **Generate node package**: `rake node_package`
|
74
|
+
- **Run single test example**: `rake run_rspec:example_basic`
|
75
|
+
|
76
|
+
### Test Environment Commands
|
77
|
+
|
78
|
+
- **Dummy app tests**: `rake run_rspec:dummy`
|
79
|
+
- **Gem-only tests**: `rake run_rspec:gem`
|
80
|
+
- **All tests except examples**: `rake all_but_examples`
|
81
|
+
|
82
|
+
## Project Architecture
|
83
|
+
|
84
|
+
### Dual Package Structure
|
85
|
+
|
86
|
+
This project maintains both a Ruby gem and an NPM package:
|
87
|
+
|
88
|
+
- **Ruby gem**: Located in `lib/`, provides Rails integration and server-side rendering
|
89
|
+
- **NPM package**: Located in `node_package/src/`, provides client-side React integration
|
90
|
+
|
91
|
+
### Core Components
|
92
|
+
|
93
|
+
#### Ruby Side (`lib/react_on_rails/`)
|
94
|
+
|
95
|
+
- **`helper.rb`**: Rails view helpers for rendering React components
|
96
|
+
- **`server_rendering_pool.rb`**: Manages Node.js processes for server-side rendering
|
97
|
+
- **`configuration.rb`**: Global configuration management
|
98
|
+
- **`engine.rb`**: Rails engine integration
|
99
|
+
- **Generators**: Located in `lib/generators/react_on_rails/`
|
100
|
+
|
101
|
+
#### JavaScript/TypeScript Side (`node_package/src/`)
|
102
|
+
|
103
|
+
- **`ReactOnRails.ts`**: Main entry point for client-side functionality
|
104
|
+
- **`serverRenderReactComponent.ts`**: Server-side rendering logic
|
105
|
+
- **`ComponentRegistry.ts`**: Manages React component registration
|
106
|
+
- **`StoreRegistry.ts`**: Manages Redux store registration
|
107
|
+
|
108
|
+
### Build System
|
109
|
+
|
110
|
+
- **Ruby**: Standard gemspec-based build
|
111
|
+
- **JavaScript**: TypeScript compilation to `node_package/lib/`
|
112
|
+
- **Testing**: Jest for JS, RSpec for Ruby
|
113
|
+
- **Linting**: ESLint for JS/TS, RuboCop for Ruby
|
114
|
+
|
115
|
+
### Examples and Testing
|
116
|
+
|
117
|
+
- **Dummy app**: `spec/dummy/` - Rails app for testing integration
|
118
|
+
- **Examples**: Generated via rake tasks for different webpack configurations
|
119
|
+
- **Rake tasks**: Defined in `rakelib/` for various development operations
|
120
|
+
|
121
|
+
## Important Notes
|
122
|
+
|
123
|
+
- Use `yalc` for local development when testing with external apps
|
124
|
+
- Server-side rendering uses isolated Node.js processes
|
125
|
+
- React Server Components support available in Pro version
|
126
|
+
- Generated examples are in `gen-examples/` (ignored by git)
|
127
|
+
- Only use `yarn` as the JS package manager, never `npm`
|
128
|
+
|
129
|
+
## IDE Configuration
|
130
|
+
|
131
|
+
Exclude these directories to prevent IDE slowdowns:
|
132
|
+
|
133
|
+
- `/coverage`, `/tmp`, `/gen-examples`, `/node_package/lib`
|
134
|
+
- `/node_modules`, `/spec/dummy/node_modules`, `/spec/dummy/tmp`
|
135
|
+
- `/spec/dummy/app/assets/webpack`, `/spec/dummy/log`
|
data/CODING_AGENTS.md
ADDED
@@ -0,0 +1,313 @@
|
|
1
|
+
# 🤖 Coding Agents & AI Contributors Guide
|
2
|
+
|
3
|
+
This guide provides specific guidelines for AI coding agents (like Claude Code) contributing to React on Rails. It supplements the main [CONTRIBUTING.md](./CONTRIBUTING.md) with AI-specific workflows and patterns.
|
4
|
+
|
5
|
+
## Quick Reference Commands
|
6
|
+
|
7
|
+
### Essential Commands
|
8
|
+
|
9
|
+
```bash
|
10
|
+
# Install dependencies
|
11
|
+
bundle && yarn
|
12
|
+
|
13
|
+
# Run tests
|
14
|
+
bundle exec rspec # All tests (from project root)
|
15
|
+
cd spec/dummy && bundle exec rspec # Dummy app tests only
|
16
|
+
|
17
|
+
# Linting & Formatting
|
18
|
+
bundle exec rubocop # Ruby linting
|
19
|
+
bundle exec rubocop [file_path] # Lint specific file
|
20
|
+
# Note: yarn format requires local setup, format manually
|
21
|
+
|
22
|
+
# Development
|
23
|
+
cd spec/dummy && foreman start # Start dummy app with webpack
|
24
|
+
```
|
25
|
+
|
26
|
+
### CI Compliance Checklist
|
27
|
+
|
28
|
+
- [ ] `bundle exec rubocop` passes with no offenses
|
29
|
+
- [ ] All RSpec tests pass
|
30
|
+
- [ ] No trailing whitespace
|
31
|
+
- [ ] Line length ≤120 characters
|
32
|
+
- [ ] Security violations properly scoped with disable comments
|
33
|
+
- [ ] No `package-lock.json` or other non-Yarn lock files (except `Gemfile.lock`)
|
34
|
+
|
35
|
+
## Development Patterns for AI Contributors
|
36
|
+
|
37
|
+
### 1. Task Management
|
38
|
+
|
39
|
+
Always use TodoWrite tool for multi-step tasks to:
|
40
|
+
|
41
|
+
- Track progress transparently
|
42
|
+
- Show the user what's being worked on
|
43
|
+
- Ensure no steps are forgotten
|
44
|
+
- Mark tasks complete as you finish them
|
45
|
+
|
46
|
+
```markdown
|
47
|
+
Example workflow:
|
48
|
+
|
49
|
+
1. Analyze the problem
|
50
|
+
2. Create test cases
|
51
|
+
3. Implement the fix
|
52
|
+
4. Run tests
|
53
|
+
5. Fix linting issues
|
54
|
+
6. Update documentation
|
55
|
+
```
|
56
|
+
|
57
|
+
### 2. Test-Driven Development
|
58
|
+
|
59
|
+
When fixing bugs or adding features:
|
60
|
+
|
61
|
+
1. **Create failing tests first** that reproduce the issue
|
62
|
+
2. **Implement the minimal fix** to make tests pass
|
63
|
+
3. **Add comprehensive test coverage** for edge cases
|
64
|
+
4. **Verify all existing tests still pass**
|
65
|
+
|
66
|
+
### 3. File Processing Guidelines
|
67
|
+
|
68
|
+
When working with file generation or processing:
|
69
|
+
|
70
|
+
- **Filter by extension**: Only process relevant files (e.g., `.js/.jsx/.ts/.tsx` for React components)
|
71
|
+
- **Validate assumptions**: Don't assume all files in a directory are components
|
72
|
+
- **Handle edge cases**: CSS modules, config files, etc. should be excluded appropriately
|
73
|
+
|
74
|
+
Example from CSS module fix:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
COMPONENT_EXTENSIONS = /\.(jsx?|tsx?)$/
|
78
|
+
|
79
|
+
def filter_component_files(paths)
|
80
|
+
paths.grep(COMPONENT_EXTENSIONS)
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
## RuboCop Compliance Patterns
|
85
|
+
|
86
|
+
### Common Fixes
|
87
|
+
|
88
|
+
1. **Trailing Whitespace**
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# Bad
|
92
|
+
let(:value) { "test" }
|
93
|
+
|
94
|
+
# Good
|
95
|
+
let(:value) { "test" }
|
96
|
+
```
|
97
|
+
|
98
|
+
2. **Line Length (120 chars max)**
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# Bad
|
102
|
+
expect { eval(pack_content.gsub(/import.*from.*['"];/, "").gsub(/ReactOnRails\.register.*/, "")) }.not_to raise_error
|
103
|
+
|
104
|
+
# Good
|
105
|
+
sanitized_content = pack_content.gsub(/import.*from.*['"];/, "")
|
106
|
+
.gsub(/ReactOnRails\.register.*/, "")
|
107
|
+
expect { eval(sanitized_content) }.not_to raise_error
|
108
|
+
```
|
109
|
+
|
110
|
+
3. **Named Subjects (RSpec)**
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
# Bad
|
114
|
+
describe "#method_name" do
|
115
|
+
subject { instance.method_name(arg) }
|
116
|
+
|
117
|
+
it "does something" do
|
118
|
+
expect(subject).to eq "result"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Good
|
123
|
+
describe "#method_name" do
|
124
|
+
subject(:method_result) { instance.method_name(arg) }
|
125
|
+
|
126
|
+
it "does something" do
|
127
|
+
expect(method_result).to eq "result"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
4. **Security/Eval Violations**
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
# Bad
|
136
|
+
expect { eval(dangerous_code) }.not_to raise_error
|
137
|
+
|
138
|
+
# Good
|
139
|
+
# rubocop:disable Security/Eval
|
140
|
+
sanitized_content = dangerous_code.gsub(/harmful_pattern/, "")
|
141
|
+
expect { eval(sanitized_content) }.not_to raise_error
|
142
|
+
# rubocop:enable Security/Eval
|
143
|
+
```
|
144
|
+
|
145
|
+
### RuboCop Workflow
|
146
|
+
|
147
|
+
1. Run `bundle exec rubocop [file]` to see violations
|
148
|
+
2. Fix violations manually or with auto-correct where safe
|
149
|
+
3. Re-run to verify fixes
|
150
|
+
4. Use disable comments sparingly and with good reason
|
151
|
+
|
152
|
+
## Testing Best Practices
|
153
|
+
|
154
|
+
### Test Structure
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
describe "FeatureName" do
|
158
|
+
context "when condition A" do
|
159
|
+
let(:setup) { create_test_condition }
|
160
|
+
|
161
|
+
before do
|
162
|
+
# Setup code
|
163
|
+
end
|
164
|
+
|
165
|
+
it "does expected behavior" do
|
166
|
+
# Arrange, Act, Assert
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
### Test Fixtures
|
173
|
+
|
174
|
+
- Create realistic test data that represents edge cases
|
175
|
+
- Use descriptive names for fixtures and variables
|
176
|
+
- Clean up after tests (handled by RSpec automatically in most cases)
|
177
|
+
|
178
|
+
### CSS Module Testing Example
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
# Create test fixtures
|
182
|
+
Write.create("ComponentWithCSSModule.module.css", css_content)
|
183
|
+
Write.create("ComponentWithCSSModule.jsx", jsx_content)
|
184
|
+
|
185
|
+
# Test the behavior
|
186
|
+
it "ignores CSS module files during pack generation" do
|
187
|
+
generated_packs = PacksGenerator.instance.generate_packs_if_stale
|
188
|
+
expect(generated_packs).not_to include("ComponentWithCSSModule.module.js")
|
189
|
+
end
|
190
|
+
```
|
191
|
+
|
192
|
+
## Git & PR Workflow
|
193
|
+
|
194
|
+
### Branch Management
|
195
|
+
|
196
|
+
```bash
|
197
|
+
git checkout -b fix/descriptive-name
|
198
|
+
# Make changes
|
199
|
+
git add .
|
200
|
+
git commit -m "Descriptive commit message
|
201
|
+
|
202
|
+
- Bullet points for major changes
|
203
|
+
- Reference issue numbers
|
204
|
+
- Include 🤖 Generated with Claude Code signature"
|
205
|
+
|
206
|
+
git push -u origin fix/descriptive-name
|
207
|
+
```
|
208
|
+
|
209
|
+
### Commit Message Format
|
210
|
+
|
211
|
+
```
|
212
|
+
Brief description of the change
|
213
|
+
|
214
|
+
- Detailed bullet points of what changed
|
215
|
+
- Why the change was needed
|
216
|
+
- Any breaking changes or considerations
|
217
|
+
|
218
|
+
Fixes #issue_number
|
219
|
+
|
220
|
+
🤖 Generated with [Claude Code](https://claude.ai/code)
|
221
|
+
|
222
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
223
|
+
```
|
224
|
+
|
225
|
+
### PR Creation
|
226
|
+
|
227
|
+
Use `gh pr create` with:
|
228
|
+
|
229
|
+
- Clear title referencing the issue
|
230
|
+
- Comprehensive description with summary and test plan
|
231
|
+
- Link to the issue being fixed
|
232
|
+
- Include the Claude Code signature
|
233
|
+
|
234
|
+
## Common Pitfalls & Solutions
|
235
|
+
|
236
|
+
### 1. File Path Issues
|
237
|
+
|
238
|
+
- Always use absolute paths in tools
|
239
|
+
- Check current working directory with `pwd`
|
240
|
+
- Use proper path joining methods
|
241
|
+
|
242
|
+
### 2. Test Environment
|
243
|
+
|
244
|
+
- Run tests from correct directory (often project root)
|
245
|
+
- Understand the difference between gem tests vs dummy app tests
|
246
|
+
- Clean up test artifacts appropriately
|
247
|
+
|
248
|
+
### 3. Dependency Management
|
249
|
+
|
250
|
+
- Don't assume packages are installed globally
|
251
|
+
- Use `bundle exec` for Ruby commands
|
252
|
+
- Verify setup with `bundle && yarn` when needed
|
253
|
+
|
254
|
+
### 4. RuboCop Configuration
|
255
|
+
|
256
|
+
- Different rules may apply to different directories
|
257
|
+
- Use `bundle exec rubocop` (not global rubocop)
|
258
|
+
- Check `.rubocop.yml` files for project-specific rules
|
259
|
+
|
260
|
+
## Debugging Workflow
|
261
|
+
|
262
|
+
1. **Understand the Problem**
|
263
|
+
|
264
|
+
- Read the issue carefully
|
265
|
+
- Reproduce the bug if possible
|
266
|
+
- Identify root cause
|
267
|
+
|
268
|
+
2. **Create Minimal Test Case**
|
269
|
+
|
270
|
+
- Write failing test that demonstrates issue
|
271
|
+
- Keep it focused and minimal
|
272
|
+
|
273
|
+
3. **Implement Fix**
|
274
|
+
|
275
|
+
- Make smallest change possible
|
276
|
+
- Ensure fix doesn't break existing functionality
|
277
|
+
- Follow existing code patterns
|
278
|
+
|
279
|
+
4. **Verify Solution**
|
280
|
+
- All new tests pass
|
281
|
+
- All existing tests still pass
|
282
|
+
- RuboCop compliance maintained
|
283
|
+
- Manual testing if applicable
|
284
|
+
|
285
|
+
## IDE Configuration for AI Context
|
286
|
+
|
287
|
+
When analyzing codebases, ignore these directories to avoid confusion:
|
288
|
+
|
289
|
+
- `/coverage`, `/tmp`, `/gen-examples`
|
290
|
+
- `/node_package/lib`, `/node_modules`
|
291
|
+
- `/spec/dummy/app/assets/webpack`
|
292
|
+
- `/spec/dummy/log`, `/spec/dummy/node_modules`, `/spec/dummy/tmp`
|
293
|
+
- `/spec/react_on_rails/dummy-for-generators`
|
294
|
+
|
295
|
+
## Communication with Human Maintainers
|
296
|
+
|
297
|
+
- Be transparent about AI-generated changes
|
298
|
+
- Explain reasoning behind implementation choices
|
299
|
+
- Ask for clarification when requirements are ambiguous
|
300
|
+
- Provide comprehensive commit messages and PR descriptions
|
301
|
+
- Include test plans and verification steps
|
302
|
+
|
303
|
+
## Resources
|
304
|
+
|
305
|
+
- [Main Contributing Guide](./CONTRIBUTING.md)
|
306
|
+
- [Pull Request Guidelines](./docs/contributor-info/pull-requests.md)
|
307
|
+
- [Generator Testing](./docs/contributor-info/generator-testing.md)
|
308
|
+
- [RuboCop Documentation](https://docs.rubocop.org/)
|
309
|
+
- [RSpec Best Practices](https://rspec.info/)
|
310
|
+
|
311
|
+
---
|
312
|
+
|
313
|
+
This guide evolves based on AI contributor experiences. Suggest improvements via issues or PRs!
|