Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ spec/dummy/public
*.res.js

# Prettier doesn't understand ERB syntax in YAML files and can damage templates
.rubocop.yml
*.yml
*.yaml
# Intentionally invalid
Expand Down
100 changes: 100 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Root RuboCop configuration for React on Rails monorepo
# This contains shared settings inherited by react_on_rails/ and react_on_rails_pro/
require:
- rubocop-performance
- rubocop-rspec

AllCops:
NewCops: enable
DisplayCopNames: true
SuggestExtensions: false
TargetRubyVersion: 3.0

Include:
- '**/Rakefile'
- '**/config.ru'
- 'Gemfile'
- '**/*.rb'
- '**/*.rake'

Exclude:
- '**/*.js'
- '**/node_modules/**/*'
- '**/public/**/*'
- '**/tmp/**/*'
- 'coverage/**/*'
- 'gen-examples/**/*'
- 'node_modules/**/*'
- 'spec/fixtures/**/*'
- 'spec/react_on_rails/dummy-for-generators/**/*'
- '**/vendor/**/*'

Naming/FileName:
Exclude:
- '**/Gemfile'
- '**/Rakefile'

Layout/LineLength:
Max: 120

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/Documentation:
Enabled: false

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Metrics/AbcSize:
Max: 28

Metrics/ClassLength:
Max: 150

Metrics/CyclomaticComplexity:
Max: 8

Metrics/PerceivedComplexity:
Max: 10

Metrics/ParameterLists:
Max: 5
CountKeywordArgs: false

Metrics/MethodLength:
Max: 41

Metrics/ModuleLength:
Max: 180

RSpec/DescribeClass:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/MessageSpies:
Enabled: false

RSpec/MessageChain:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Max: 12

RSpec/NestedGroups:
Max: 5

Style/FrozenStringLiteralComment:
EnforcedStyle: always

88 changes: 7 additions & 81 deletions react_on_rails/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,23 @@
# This is the configuration used to check the rubocop source code.
# Check out: https://github.com/bbatsov/rubocop
require:
- rubocop-performance
- rubocop-rspec
# Inherits from root config
inherit_from: ../.rubocop.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inherit_from: ../.rubocop.yml
inherit_from: ../.rubocop.yml
# Merge Exclude arrays with parent instead of replacing them
inherit_mode:
merge:
- Exclude

default inherit mode is override, so without inherit_mode: merge, child Exclude arrays replace the parent's instead of merging. This means all the root excludes are lost.


# Merge Exclude arrays with parent instead of replacing them
inherit_mode:
merge:
- Exclude

AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: 3.0.0
SuggestExtensions: false

Include:
- '**/Rakefile'
- '**/config.ru'
- 'Gemfile'
- '**/*.rb'
- '**/*.rake'

Exclude:
- '**/*.js'
- '**/node_modules/**/*'
- '**/public/**/*'
- '**/tmp/**/*'
- 'coverage/**/*'
- 'gen-examples/examples/**/*'
- 'node_modules/**/*'
- '../react_on_rails_pro/**/*' # Exclude pro package (has its own linting)
- 'spec/dummy/bin/*'
- 'spec/fixtures/**/*'
- 'spec/react_on_rails/dummy-for-generators/**/*'
- 'tmp/**/*'
- 'vendor/**/*'

Naming/FileName:
Exclude:
- '**/Gemfile*'
- '**/Rakefile'
- '**/Steepfile'

Layout/LineLength:
Max: 120

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/Documentation:
Enabled: false

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Lint/AssignmentInCondition:
Exclude:
- 'spec/dummy/bin/spring'
Expand All @@ -66,33 +28,19 @@ Lint/SuppressedException:
- 'spec/dummy/bin/rake'

Metrics/AbcSize:
Max: 28
Exclude:
- 'lib/generators/react_on_rails/install_generator.rb' # Generator setup methods require comprehensive error handling

Metrics/CyclomaticComplexity:
Max: 7

Metrics/PerceivedComplexity:
Max: 10

Metrics/ClassLength:
Max: 150
Exclude:
- 'lib/generators/react_on_rails/base_generator.rb' # Generator complexity justified
- 'lib/react_on_rails/dev/server_manager.rb' # Dev tool with comprehensive help system

Metrics/ParameterLists:
Max: 5
CountKeywordArgs: false

Metrics/MethodLength:
Max: 41
Exclude:
- 'lib/generators/react_on_rails/install_generator.rb' # Generator setup methods require comprehensive error handling

Metrics/ModuleLength:
Max: 180
Exclude:
- 'spec/react_on_rails/engine_spec.rb' # Comprehensive engine tests require many examples

Expand All @@ -107,18 +55,6 @@ RSpec/AnyInstance:
- 'spec/react_on_rails/binstubs/dev_static_spec.rb'
- 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests require system mocking

RSpec/DescribeClass:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/MessageSpies:
Enabled: false

RSpec/NestedGroups:
Max: 4

RSpec/BeforeAfterAll:
Exclude:
- 'spec/react_on_rails/generators/dev_tests_generator_spec.rb'
Expand All @@ -127,19 +63,10 @@ RSpec/BeforeAfterAll:
- 'spec/react_on_rails/binstubs/dev_static_spec.rb'
- 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests require global setup

RSpec/MessageChain:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleDescribes:
Exclude:
- 'spec/dummy/spec/system/integration_spec.rb'

RSpec/MultipleMemoizedHelpers:
Max: 12

Style/GlobalVars:
Exclude:
- 'spec/dummy/config/environments/development.rb'
Expand All @@ -156,4 +83,3 @@ RSpec/InstanceVariable:
RSpec/StubbedMock:
Exclude:
- 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests use mixed stub/mock patterns

8 changes: 8 additions & 0 deletions react_on_rails/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,17 @@ GEM
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rails (2.29.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class BundlerSwitcher
puts "✅ Updated assets_bundler to '#{@target_bundler}'"
end

# rubocop:disable Metrics/CyclomaticComplexity
def update_dependencies
puts "📦 Updating package.json dependencies..."

Expand All @@ -86,9 +85,7 @@ class BundlerSwitcher
puts "✅ Removed #{@target_bundler == 'rspack' ? 'webpack' : 'rspack'} dependencies"
File.write(package_json_path, JSON.pretty_generate(package_json))
end
# rubocop:enable Metrics/CyclomaticComplexity

# rubocop:disable Metrics/CyclomaticComplexity
def install_dependencies
puts "📥 Installing #{@target_bundler} dependencies..."

Expand Down Expand Up @@ -123,7 +120,6 @@ class BundlerSwitcher

puts "✅ Installed #{@target_bundler} dependencies"
end
# rubocop:enable Metrics/CyclomaticComplexity

def detect_package_manager
return "yarn" if File.exist?("yarn.lock")
Expand Down
8 changes: 0 additions & 8 deletions react_on_rails/lib/react_on_rails/doctor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ def check_version_wildcards
check_npm_wildcards
end

# rubocop:disable Metrics/CyclomaticComplexity
def check_gem_wildcards
gemfile_path = ENV["BUNDLE_GEMFILE"] || "Gemfile"
return unless File.exist?(gemfile_path)
Expand All @@ -490,9 +489,7 @@ def check_gem_wildcards
# Ignore errors reading Gemfile
end
end
# rubocop:enable Metrics/CyclomaticComplexity

# rubocop:disable Metrics/CyclomaticComplexity
def check_npm_wildcards
return unless File.exist?("package.json")

Expand All @@ -514,7 +511,6 @@ def check_npm_wildcards
# Ignore other errors
end
end
# rubocop:enable Metrics/CyclomaticComplexity

def check_key_configuration_files
files_to_check = {
Expand All @@ -538,7 +534,6 @@ def check_key_configuration_files
check_server_rendering_engine
end

# rubocop:disable Metrics/CyclomaticComplexity
def check_layout_files
layout_files = Dir.glob("app/views/layouts/**/*.erb")
return if layout_files.empty?
Expand All @@ -565,7 +560,6 @@ def check_layout_files
end
end
end
# rubocop:enable Metrics/CyclomaticComplexity

# rubocop:disable Metrics/CyclomaticComplexity
def check_server_rendering_engine
Expand Down Expand Up @@ -603,7 +597,6 @@ def check_server_rendering_engine
end
# rubocop:enable Metrics/CyclomaticComplexity

# rubocop:disable Metrics/CyclomaticComplexity
def check_shakapacker_configuration_details
return unless File.exist?("config/shakapacker.yml")

Expand Down Expand Up @@ -632,7 +625,6 @@ def check_shakapacker_configuration_details
checker.add_warning(" ⚠️ Could not run 'rake shakapacker:info': #{e.message}")
end
end
# rubocop:enable Metrics/CyclomaticComplexity

def check_react_on_rails_configuration_details
check_react_on_rails_initializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def reset_pool_if_server_bundle_was_modified
# Note, js_code does not have to be based on React.
# js_code MUST RETURN json stringify Object
# Calling code will probably call 'html_safe' on return value before rendering to the view.
# rubocop:disable Metrics/CyclomaticComplexity
def exec_server_render_js(js_code, render_options, js_evaluator = nil)
js_evaluator ||= self
if render_options.trace
Expand Down Expand Up @@ -87,7 +86,6 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil)
# We need to parse each chunk and replay the console messages.
result.transform { |chunk| parse_result_and_replay_console_messages(chunk, render_options) }
end
# rubocop:enable Metrics/CyclomaticComplexity

def trace_js_code_used(msg, js_code, file_name = "tmp/server-generated.js", force: false)
return unless ReactOnRails.configuration.trace || force
Expand Down
Loading
Loading