react_on_rails 15.0.0.rc.2 → 16.0.0

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -36
  3. data/CLAUDE.md +90 -0
  4. data/CODING_AGENTS.md +312 -0
  5. data/CONTRIBUTING.md +378 -3
  6. data/Gemfile.lock +2 -1
  7. data/LICENSE.md +16 -4
  8. data/LICENSES/README.md +14 -0
  9. data/REACT-ON-RAILS-PRO-LICENSE.md +129 -0
  10. data/README.md +2 -2
  11. data/TODO.md +135 -0
  12. data/eslint.config.ts +2 -0
  13. data/lib/generators/USAGE +4 -5
  14. data/lib/generators/react_on_rails/base_generator.rb +263 -57
  15. data/lib/generators/react_on_rails/bin/dev +38 -22
  16. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -0
  17. data/lib/generators/react_on_rails/generator_helper.rb +31 -1
  18. data/lib/generators/react_on_rails/generator_messages.rb +138 -17
  19. data/lib/generators/react_on_rails/install_generator.rb +222 -20
  20. data/lib/generators/react_on_rails/react_no_redux_generator.rb +6 -5
  21. data/lib/generators/react_on_rails/react_with_redux_generator.rb +37 -13
  22. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +5 -0
  23. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-prod-assets +8 -0
  24. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static-assets +2 -0
  25. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +0 -5
  26. data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.js +1 -8
  27. data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx +21 -0
  28. data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css +4 -0
  29. data/lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx +5 -0
  30. data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +1 -1
  31. data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb +4 -2
  32. data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +5 -2
  33. data/lib/generators/react_on_rails/templates/base/base/bin/dev +46 -0
  34. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +3 -3
  35. data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +76 -7
  36. data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +1 -1
  37. data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +8 -8
  38. data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +2 -2
  39. data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +2 -2
  40. data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +0 -2
  41. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +0 -6
  42. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +4 -0
  43. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.server.jsx +5 -0
  44. data/lib/react_on_rails/configuration.rb +5 -5
  45. data/lib/react_on_rails/controller.rb +5 -3
  46. data/lib/react_on_rails/dev/file_manager.rb +78 -0
  47. data/lib/react_on_rails/dev/pack_generator.rb +27 -0
  48. data/lib/react_on_rails/dev/process_manager.rb +61 -0
  49. data/lib/react_on_rails/dev/server_manager.rb +330 -0
  50. data/lib/react_on_rails/dev.rb +20 -0
  51. data/lib/react_on_rails/engine.rb +6 -0
  52. data/lib/react_on_rails/git_utils.rb +12 -2
  53. data/lib/react_on_rails/helper.rb +61 -17
  54. data/lib/react_on_rails/packer_utils.rb +4 -18
  55. data/lib/react_on_rails/packs_generator.rb +134 -8
  56. data/lib/react_on_rails/react_component/render_options.rb +2 -2
  57. data/lib/react_on_rails/server_rendering_js_code.rb +0 -1
  58. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +1 -0
  59. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +1 -0
  60. data/lib/react_on_rails/utils.rb +16 -1
  61. data/lib/react_on_rails/version.rb +1 -1
  62. data/lib/react_on_rails/version_syntax_converter.rb +1 -1
  63. data/lib/react_on_rails.rb +1 -0
  64. data/lib/tasks/generate_packs.rake +20 -0
  65. data/react_on_rails.gemspec +1 -0
  66. metadata +40 -11
  67. data/REACT-ON-RAILS-PRO-LICENSE +0 -95
  68. data/lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb +0 -41
  69. data/lib/generators/react_on_rails/bin/dev-static +0 -30
  70. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt +0 -9
  71. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -5
  72. data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/registration.js.tt +0 -8
  73. /data/lib/generators/react_on_rails/templates/base/base/config/webpack/{webpackConfig.js.tt → generateWebpackConfigs.js.tt} +0 -0
  74. /data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/startup/{HelloWorldApp.jsx → HelloWorldApp.client.jsx} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ca168413057bb25fbd6ca60307bb48baceabcef86cbbd4a8141bb5913e9ca5
4
- data.tar.gz: 6cf924cd26ae04b10d303e0c761daf19af7bd3d15417421e56c6492b6e4264ee
3
+ metadata.gz: ae77f76930b3765219ace75c93ac15ba789730f9d7fd98690db212e74489936d
4
+ data.tar.gz: a81127c42c27640473994129251b9f18ea7c609837c0b414eaa83a4edc30442d
5
5
  SHA512:
6
- metadata.gz: 3485bf92e659aa921d0352ee43e3cd56b836818c17a6d643332a5e5fecaac0da696e2ab1723215d069d25201cf1da41bfadea2546bf435bfea01924ba4010096
7
- data.tar.gz: a7e120190894dd8b34637274a6fb8407c8ab6b7a7e6608b744244868d661ba8e11e3d1925a7eaa86d27905cc2db2c870453f6a7af8c795c504d1dd988f0d7130
6
+ metadata.gz: a0d4a4ece7bf8bd4a90dd7f3e11249f0d8de7d1dd1425a9f4654caeef3758722aaad5d2b6654e50f5526d32f6cddb65847ff3e0e865203017c331d283a01f12f
7
+ data.tar.gz: 6ec4ef830ab5712e467de1a98d54ccfb6d174079f78d2f9aeb5e84f26eb71038200ad2b0b4f3c4ef03a8ded5b1def16869482afffbaf5c17bd861df10364d3f9
data/CHANGELOG.md CHANGED
@@ -23,63 +23,92 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
23
23
 
24
24
  Changes since the last non-beta release.
25
25
 
26
+ ### [16.0.0] - 2025-01-XX
27
+
28
+ #### Removed (Breaking Changes)
29
+
30
+ - **Webpacker support completely removed**. Shakapacker >= 6.0 is now required.
31
+ - Migration:
32
+ - Remove any `webpacker` gem references from your Gemfile
33
+ - Ensure `shakapacker` gem version 6.0 or higher is installed (8.0+ recommended)
34
+ - Replace any `bin/webpacker` commands with `bin/shakapacker`
35
+ - Update any webpacker configuration files to shakapacker equivalents
36
+ - Removed files: `rakelib/webpacker_examples.rake`, `lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb`
37
+ - All webpacker compatibility code and tests have been removed
38
+ - **CI/Development runtime requirements updated**:
39
+ - _Note, this is just what CI tests_. You can use older versions of Ruby and Node.js, but you may run into issues.\*
40
+ - Minimum Ruby version: 3.2 (was 3.0)
41
+ - Maximum Ruby version: 3.4 (was 3.3)
42
+ - Minimum Node.js version: 20 (was 16)
43
+ - Maximum Node.js version: 22 (was 20)
44
+ - Migration: Upgrade your Ruby and Node.js versions to supported ranges
45
+ - **Install generator now validates prerequisites**:
46
+ - Generator now requires at least one JavaScript package manager (npm, pnpm, yarn, or bun)
47
+ - Generator uses `Thor::Error` exceptions instead of `exit(1)` for better error handling
48
+ - Migration: Ensure you have a JavaScript package manager installed before running the generator
49
+
50
+ #### Enhanced
51
+
52
+ - Simplified CI matrix configuration with clear dependency level naming (`minimum`/`latest` instead of `oldest`/`newest`)
53
+ - Improved error messages in install generator with clearer troubleshooting steps
54
+ - Enhanced package manager detection with multi-strategy validation
55
+
56
+ ### [15.0.0] - 2025-08-28
57
+
58
+ See [Release Notes](docs/release-notes/16.0.0.md) for full details.
59
+
60
+ ### Removed (Breaking Changes)
61
+
62
+ - Deprecated `defer_generated_component_packs` configuration option. You should use `generated_component_packs_loading_strategy` instead.
63
+ - Migration:
64
+ - `defer_generated_component_packs: true` → `generated_component_packs_loading_strategy: :defer`
65
+ - `defer_generated_component_packs: false` → `generated_component_packs_loading_strategy: :sync`
66
+ - For best performance, use `generated_component_packs_loading_strategy: :async`
67
+ - [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
68
+ - The package is ESM-only now. Migration:
69
+ - If using `require('react-on-rails')`, upgrade to Node v20.19.0+ or change to `import`.
70
+ - For TypeScript errors, upgrade to TypeScript 5.8+ and set `module` to `nodenext`.
71
+ - `ReactOnRails.reactOnRailsPageLoaded` is now an async function. Migration:
72
+ - Add `await` when calling this function: `await ReactOnRails.reactOnRailsPageLoaded()`.
73
+ - **RENAMED**: `force_load` configuration renamed to `immediate_hydration` for better API clarity.
74
+ - `immediate_hydration` now defaults to `false` and requires React on Rails Pro license.
75
+ - Migration:
76
+ - `config.force_load = true` → `config.immediate_hydration = true`
77
+ - `react_component(force_load: true)` → `react_component(immediate_hydration: true)`
78
+ - `redux_store(force_load: true)` → `redux_store(immediate_hydration: true)`
79
+
80
+ For detailed migration instructions, see the [16.0.0 Release Notes](docs/release-notes/16.0.0.md).
81
+
26
82
  #### Fixed
27
83
 
28
84
  - Enable support for ReactRefreshWebpackPlugin v0.6.0 by adding conditional logic regarding configuration. [PR 1748](https://github.com/shakacode/react_on_rails/pull/1748) by [judahmeek](https://github.com/judahmeek).
29
-
30
85
  - Replace RenderOptions.renderRequestId and use local trackers instead. This change should only be relevant to ReactOnRails Pro users. [PR 1745](https://github.com/shakacode/react_on_rails/pull/1745) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
31
-
32
86
  - Fixed invalid warnings about non-exact versions when using a pre-release version of React on Rails, as well as missing warnings when using different pre-release versions of the gem and the Node package. [PR 1742](https://github.com/shakacode/react_on_rails/pull/1742) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
33
87
 
34
- ### [15.0.0-rc.1] - 2025-06-18
35
-
36
88
  #### Improved
37
89
 
38
90
  - Ensured that the RSC payload is injected after the component's HTML markup to improve the performance of the RSC payload injection. [PR 1738](https://github.com/shakacode/react_on_rails/pull/1738) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
39
-
40
- ### [15.0.0-rc.0] - 2025-06-16
41
-
42
- #### Improved
43
-
44
91
  - Improved RSC rendering flow by eliminating double rendering of server components and reducing the number of HTTP requests.
45
92
  - Updated communication protocol between Node Renderer and Rails to version 2.0.0 which supports the ability to upload multiple bundles at once.
46
- - Added `RSCRoute` component to enable seamless server-side rendering of React Server Components. This component automatically handles RSC payload injection and hydration, allowing server components to be rendered directly within client components while maintaining optimal performance.
47
-
48
- [PR 1696](https://github.com/shakacode/react_on_rails/pull/1696) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
49
-
50
- #### Added
51
-
52
- - Configuration option `generated_component_packs_loading_strategy` to control how generated component packs are loaded. It supports `sync`, `async`, and `defer` strategies. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
53
-
54
- - Support for returning React component from async render-function. [PR 1720](https://github.com/shakacode/react_on_rails/pull/1720) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
55
-
56
- ### Removed (Breaking Changes)
57
-
58
- - Deprecated `defer_generated_component_packs` configuration option. You should use `generated_component_packs_loading_strategy` instead. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
59
-
60
- ### Changed
61
-
62
- - **Breaking change**: The package is ESM-only now. Please see [Release Notes](docs/release-notes/15.0.0.md#esm-only-package) for more details.
93
+ - Added `RSCRoute` component to enable seamless server-side rendering of React Server Components. This component automatically handles RSC payload injection and hydration, allowing server components to be rendered directly within client components while maintaining optimal performance. [PR 1696](https://github.com/shakacode/react_on_rails/pull/1696) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
63
94
  - The global context is now accessed using `globalThis`. [PR 1727](https://github.com/shakacode/react_on_rails/pull/1727) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
64
95
  - Generated client packs now import from `react-on-rails/client` instead of `react-on-rails`. [PR 1706](https://github.com/shakacode/react_on_rails/pull/1706) by [alexeyr-ci](https://github.com/alexeyr-ci).
65
96
  - The "optimization opportunity" message when importing the server-side `react-on-rails` instead of `react-on-rails/client` in browsers is now a warning for two reasons:
66
97
  - Make it more prominent
67
98
  - Include a stack trace when clicked
68
99
 
69
- ### [15.0.0-alpha.2] - 2025-03-07
70
-
71
- See [Release Notes](docs/release-notes/15.0.0.md) for full details.
72
-
73
100
  #### Added
74
101
 
102
+ - Configuration option `generated_component_packs_loading_strategy` to control how generated component packs are loaded. It supports `sync`, `async`, and `defer` strategies. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
103
+ - Support for returning React component from async render-function. [PR 1720](https://github.com/shakacode/react_on_rails/pull/1720) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
75
104
  - React Server Components Support (Pro Feature) [PR 1644](https://github.com/shakacode/react_on_rails/pull/1644) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
76
105
  - Improved component and store hydration performance [PR 1656](https://github.com/shakacode/react_on_rails/pull/1656) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
77
106
 
78
- #### Breaking Changes
107
+ ### [15.0.0] - 2025-08-28 - RETRACTED
108
+
109
+ **⚠️ This version has been retracted due to API design issues. Please upgrade directly to v16.0.0.**
79
110
 
80
- - `ReactOnRails.reactOnRailsPageLoaded` is now an async function
81
- - `force_load` configuration now defaults to `true`
82
- - `defer_generated_component_packs` configuration now defaults to `false`
111
+ The `force_load` feature was incorrectly available without a Pro license and has been renamed to `immediate_hydration` for better clarity. All features from v15 are available in v16 with the corrected API.
83
112
 
84
113
  ### [14.2.0] - 2025-03-03
85
114
 
@@ -1577,8 +1606,8 @@ such as:
1577
1606
 
1578
1607
  - Fix several generator-related issues.
1579
1608
 
1580
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/15.0.0-alpha.2...master
1581
- [15.0.0-alpha.2]: https://github.com/shakacode/react_on_rails/compare/14.2.0...15.0.0-alpha.2
1609
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/15.0.0...master
1610
+ [15.0.0]: https://github.com/shakacode/react_on_rails/compare/14.2.0...15.0.0
1582
1611
  [14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0
1583
1612
  [14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
1584
1613
  [14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0
data/CLAUDE.md ADDED
@@ -0,0 +1,90 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Development Commands
6
+
7
+ ### Essential Commands
8
+
9
+ - **Install dependencies**: `bundle && yarn`
10
+ - **Run tests**:
11
+ - Ruby tests: `rake run_rspec`
12
+ - JavaScript tests: `yarn run test` or `rake js_tests`
13
+ - All tests: `rake` (default task runs lint and all tests except examples)
14
+ - **Linting**:
15
+ - All linters: `rake lint` (runs ESLint and RuboCop)
16
+ - ESLint only: `yarn run lint` or `rake lint:eslint`
17
+ - RuboCop only: `rake lint:rubocop`
18
+ - **Code Formatting**:
19
+ - Format code with Prettier: `yarn start format`
20
+ - Check formatting without fixing: `yarn start format.listDifferent`
21
+ - **Build**: `yarn run build` (compiles TypeScript to JavaScript in node_package/lib)
22
+ - **Type checking**: `yarn run type-check`
23
+
24
+ ### Development Setup Commands
25
+
26
+ - **Initial setup**: `bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake`
27
+ - **Prepare examples**: `rake shakapacker_examples:gen_all`
28
+ - **Generate node package**: `rake node_package`
29
+ - **Run single test example**: `rake run_rspec:example_basic`
30
+
31
+ ### Test Environment Commands
32
+
33
+ - **Dummy app tests**: `rake run_rspec:dummy`
34
+ - **Gem-only tests**: `rake run_rspec:gem`
35
+ - **All tests except examples**: `rake all_but_examples`
36
+
37
+ ## Project Architecture
38
+
39
+ ### Dual Package Structure
40
+
41
+ This project maintains both a Ruby gem and an NPM package:
42
+
43
+ - **Ruby gem**: Located in `lib/`, provides Rails integration and server-side rendering
44
+ - **NPM package**: Located in `node_package/src/`, provides client-side React integration
45
+
46
+ ### Core Components
47
+
48
+ #### Ruby Side (`lib/react_on_rails/`)
49
+
50
+ - **`helper.rb`**: Rails view helpers for rendering React components
51
+ - **`server_rendering_pool.rb`**: Manages Node.js processes for server-side rendering
52
+ - **`configuration.rb`**: Global configuration management
53
+ - **`engine.rb`**: Rails engine integration
54
+ - **Generators**: Located in `lib/generators/react_on_rails/`
55
+
56
+ #### JavaScript/TypeScript Side (`node_package/src/`)
57
+
58
+ - **`ReactOnRails.ts`**: Main entry point for client-side functionality
59
+ - **`serverRenderReactComponent.ts`**: Server-side rendering logic
60
+ - **`ComponentRegistry.ts`**: Manages React component registration
61
+ - **`StoreRegistry.ts`**: Manages Redux store registration
62
+
63
+ ### Build System
64
+
65
+ - **Ruby**: Standard gemspec-based build
66
+ - **JavaScript**: TypeScript compilation to `node_package/lib/`
67
+ - **Testing**: Jest for JS, RSpec for Ruby
68
+ - **Linting**: ESLint for JS/TS, RuboCop for Ruby
69
+
70
+ ### Examples and Testing
71
+
72
+ - **Dummy app**: `spec/dummy/` - Rails app for testing integration
73
+ - **Examples**: Generated via rake tasks for different webpack configurations
74
+ - **Rake tasks**: Defined in `rakelib/` for various development operations
75
+
76
+ ## Important Notes
77
+
78
+ - Use `yalc` for local development when testing with external apps
79
+ - The project supports both Webpacker and Shakapacker
80
+ - Server-side rendering uses isolated Node.js processes
81
+ - React Server Components support available in Pro version
82
+ - Generated examples are in `gen-examples/` (ignored by git)
83
+
84
+ ## IDE Configuration
85
+
86
+ Exclude these directories to prevent IDE slowdowns:
87
+
88
+ - `/coverage`, `/tmp`, `/gen-examples`, `/node_package/lib`
89
+ - `/node_modules`, `/spec/dummy/node_modules`, `/spec/dummy/tmp`
90
+ - `/spec/dummy/app/assets/webpack`, `/spec/dummy/log`
data/CODING_AGENTS.md ADDED
@@ -0,0 +1,312 @@
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
+
34
+ ## Development Patterns for AI Contributors
35
+
36
+ ### 1. Task Management
37
+
38
+ Always use TodoWrite tool for multi-step tasks to:
39
+
40
+ - Track progress transparently
41
+ - Show the user what's being worked on
42
+ - Ensure no steps are forgotten
43
+ - Mark tasks complete as you finish them
44
+
45
+ ```markdown
46
+ Example workflow:
47
+
48
+ 1. Analyze the problem
49
+ 2. Create test cases
50
+ 3. Implement the fix
51
+ 4. Run tests
52
+ 5. Fix linting issues
53
+ 6. Update documentation
54
+ ```
55
+
56
+ ### 2. Test-Driven Development
57
+
58
+ When fixing bugs or adding features:
59
+
60
+ 1. **Create failing tests first** that reproduce the issue
61
+ 2. **Implement the minimal fix** to make tests pass
62
+ 3. **Add comprehensive test coverage** for edge cases
63
+ 4. **Verify all existing tests still pass**
64
+
65
+ ### 3. File Processing Guidelines
66
+
67
+ When working with file generation or processing:
68
+
69
+ - **Filter by extension**: Only process relevant files (e.g., `.js/.jsx/.ts/.tsx` for React components)
70
+ - **Validate assumptions**: Don't assume all files in a directory are components
71
+ - **Handle edge cases**: CSS modules, config files, etc. should be excluded appropriately
72
+
73
+ Example from CSS module fix:
74
+
75
+ ```ruby
76
+ COMPONENT_EXTENSIONS = /\.(jsx?|tsx?)$/
77
+
78
+ def filter_component_files(paths)
79
+ paths.grep(COMPONENT_EXTENSIONS)
80
+ end
81
+ ```
82
+
83
+ ## RuboCop Compliance Patterns
84
+
85
+ ### Common Fixes
86
+
87
+ 1. **Trailing Whitespace**
88
+
89
+ ```ruby
90
+ # Bad
91
+ let(:value) { "test" }
92
+
93
+ # Good
94
+ let(:value) { "test" }
95
+ ```
96
+
97
+ 2. **Line Length (120 chars max)**
98
+
99
+ ```ruby
100
+ # Bad
101
+ expect { eval(pack_content.gsub(/import.*from.*['"];/, "").gsub(/ReactOnRails\.register.*/, "")) }.not_to raise_error
102
+
103
+ # Good
104
+ sanitized_content = pack_content.gsub(/import.*from.*['"];/, "")
105
+ .gsub(/ReactOnRails\.register.*/, "")
106
+ expect { eval(sanitized_content) }.not_to raise_error
107
+ ```
108
+
109
+ 3. **Named Subjects (RSpec)**
110
+
111
+ ```ruby
112
+ # Bad
113
+ describe "#method_name" do
114
+ subject { instance.method_name(arg) }
115
+
116
+ it "does something" do
117
+ expect(subject).to eq "result"
118
+ end
119
+ end
120
+
121
+ # Good
122
+ describe "#method_name" do
123
+ subject(:method_result) { instance.method_name(arg) }
124
+
125
+ it "does something" do
126
+ expect(method_result).to eq "result"
127
+ end
128
+ end
129
+ ```
130
+
131
+ 4. **Security/Eval Violations**
132
+
133
+ ```ruby
134
+ # Bad
135
+ expect { eval(dangerous_code) }.not_to raise_error
136
+
137
+ # Good
138
+ # rubocop:disable Security/Eval
139
+ sanitized_content = dangerous_code.gsub(/harmful_pattern/, "")
140
+ expect { eval(sanitized_content) }.not_to raise_error
141
+ # rubocop:enable Security/Eval
142
+ ```
143
+
144
+ ### RuboCop Workflow
145
+
146
+ 1. Run `bundle exec rubocop [file]` to see violations
147
+ 2. Fix violations manually or with auto-correct where safe
148
+ 3. Re-run to verify fixes
149
+ 4. Use disable comments sparingly and with good reason
150
+
151
+ ## Testing Best Practices
152
+
153
+ ### Test Structure
154
+
155
+ ```ruby
156
+ describe "FeatureName" do
157
+ context "when condition A" do
158
+ let(:setup) { create_test_condition }
159
+
160
+ before do
161
+ # Setup code
162
+ end
163
+
164
+ it "does expected behavior" do
165
+ # Arrange, Act, Assert
166
+ end
167
+ end
168
+ end
169
+ ```
170
+
171
+ ### Test Fixtures
172
+
173
+ - Create realistic test data that represents edge cases
174
+ - Use descriptive names for fixtures and variables
175
+ - Clean up after tests (handled by RSpec automatically in most cases)
176
+
177
+ ### CSS Module Testing Example
178
+
179
+ ```ruby
180
+ # Create test fixtures
181
+ Write.create("ComponentWithCSSModule.module.css", css_content)
182
+ Write.create("ComponentWithCSSModule.jsx", jsx_content)
183
+
184
+ # Test the behavior
185
+ it "ignores CSS module files during pack generation" do
186
+ generated_packs = PacksGenerator.instance.generate_packs_if_stale
187
+ expect(generated_packs).not_to include("ComponentWithCSSModule.module.js")
188
+ end
189
+ ```
190
+
191
+ ## Git & PR Workflow
192
+
193
+ ### Branch Management
194
+
195
+ ```bash
196
+ git checkout -b fix/descriptive-name
197
+ # Make changes
198
+ git add .
199
+ git commit -m "Descriptive commit message
200
+
201
+ - Bullet points for major changes
202
+ - Reference issue numbers
203
+ - Include 🤖 Generated with Claude Code signature"
204
+
205
+ git push -u origin fix/descriptive-name
206
+ ```
207
+
208
+ ### Commit Message Format
209
+
210
+ ```
211
+ Brief description of the change
212
+
213
+ - Detailed bullet points of what changed
214
+ - Why the change was needed
215
+ - Any breaking changes or considerations
216
+
217
+ Fixes #issue_number
218
+
219
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
220
+
221
+ Co-Authored-By: Claude <noreply@anthropic.com>
222
+ ```
223
+
224
+ ### PR Creation
225
+
226
+ Use `gh pr create` with:
227
+
228
+ - Clear title referencing the issue
229
+ - Comprehensive description with summary and test plan
230
+ - Link to the issue being fixed
231
+ - Include the Claude Code signature
232
+
233
+ ## Common Pitfalls & Solutions
234
+
235
+ ### 1. File Path Issues
236
+
237
+ - Always use absolute paths in tools
238
+ - Check current working directory with `pwd`
239
+ - Use proper path joining methods
240
+
241
+ ### 2. Test Environment
242
+
243
+ - Run tests from correct directory (often project root)
244
+ - Understand the difference between gem tests vs dummy app tests
245
+ - Clean up test artifacts appropriately
246
+
247
+ ### 3. Dependency Management
248
+
249
+ - Don't assume packages are installed globally
250
+ - Use `bundle exec` for Ruby commands
251
+ - Verify setup with `bundle && yarn` when needed
252
+
253
+ ### 4. RuboCop Configuration
254
+
255
+ - Different rules may apply to different directories
256
+ - Use `bundle exec rubocop` (not global rubocop)
257
+ - Check `.rubocop.yml` files for project-specific rules
258
+
259
+ ## Debugging Workflow
260
+
261
+ 1. **Understand the Problem**
262
+
263
+ - Read the issue carefully
264
+ - Reproduce the bug if possible
265
+ - Identify root cause
266
+
267
+ 2. **Create Minimal Test Case**
268
+
269
+ - Write failing test that demonstrates issue
270
+ - Keep it focused and minimal
271
+
272
+ 3. **Implement Fix**
273
+
274
+ - Make smallest change possible
275
+ - Ensure fix doesn't break existing functionality
276
+ - Follow existing code patterns
277
+
278
+ 4. **Verify Solution**
279
+ - All new tests pass
280
+ - All existing tests still pass
281
+ - RuboCop compliance maintained
282
+ - Manual testing if applicable
283
+
284
+ ## IDE Configuration for AI Context
285
+
286
+ When analyzing codebases, ignore these directories to avoid confusion:
287
+
288
+ - `/coverage`, `/tmp`, `/gen-examples`
289
+ - `/node_package/lib`, `/node_modules`
290
+ - `/spec/dummy/app/assets/webpack`
291
+ - `/spec/dummy/log`, `/spec/dummy/node_modules`, `/spec/dummy/tmp`
292
+ - `/spec/react_on_rails/dummy-for-generators`
293
+
294
+ ## Communication with Human Maintainers
295
+
296
+ - Be transparent about AI-generated changes
297
+ - Explain reasoning behind implementation choices
298
+ - Ask for clarification when requirements are ambiguous
299
+ - Provide comprehensive commit messages and PR descriptions
300
+ - Include test plans and verification steps
301
+
302
+ ## Resources
303
+
304
+ - [Main Contributing Guide](./CONTRIBUTING.md)
305
+ - [Pull Request Guidelines](./docs/contributor-info/pull-requests.md)
306
+ - [Generator Testing](./docs/contributor-info/generator-testing.md)
307
+ - [RuboCop Documentation](https://docs.rubocop.org/)
308
+ - [RSpec Best Practices](https://rspec.info/)
309
+
310
+ ---
311
+
312
+ This guide evolves based on AI contributor experiences. Suggest improvements via issues or PRs!