Closed OlegChuev closed 1 hour ago
Reading the description you wrote, I couldn't understand why rubocop-slim, which is just a static parser of slim templates, is related to the view_component gem. Can you elaborate a bit more on the situation?
This is just a guess, but is it possible that the version of other gems (e.g., temple gem) that Gemfile.lock refers to has changed between when you were using slimcop and when you were using rubocop-slim?
Since rubocop-slim is not a library that is loaded at runtime in normal usage, it seems odd that this would change the behavior of a process that uses view_component.
(If you accidentally forgot to add require: false
to your Gemfile and inadvertently loaded rubocop-slim at Rails startup, something strange could happen... 🤔)
Just tested with require: false
, and it seems that was the issue. Not entirely sure what the root cause might have been.
Maybe we should update the README to make require: false
a mandatory part of the setup instructions?
I see. I'm glad it was resolved 👍
Hmm. As you say, this is a common trap to step through when using Rails and RuboCop together. I will consider adding it.
Since require: false
is not required for normal Ruby projects, but only for Rails apps, it may be debatable whether to add it to README or not.
There is another good workaround besides adding require: false
.
When using RuboCop in a Rails app, I believe it is good practice to provide rubocop
gem group as follows:
# Gemfile
group :rubocop do
gem 'rubocop'
gem 'rubocop-rails'
gem 'rubocop-slim'
...
end
This way, you don't have to go around adding require: false
, and you can also specify BUNDLE_ONLY
to avoid installing these unnecessary gems on production or staging environments. (e.g. BUNDLE_ONLY=default:production
)
Description
In our application, we use the Slim template language alongside the view_component gem. There is a known issue in view_component where internal content is duplicated in nested forms. This issue was previously resolved by enabling the
config.view_component.capture_compatibility_patch_enabled = true
option inenvironment.rb
.After migrating from
slimcop
torubocop-slim
, the duplication issue reappeared. I tested the staging environment and attempted to revert to the deprecatedslimcop
version, which confirmed that the issue is directly related torubocop-slim
.Expected Behavior
The duplication issue should not occur when using rubocop-slim, provided the compatibility patch is enabled.
Actual Behavior
Internal content in nested forms is duplicated after the migration to rubocop-slim.
Additional Context
The issue is confirmed to be linked to
rubocop-slim
since reverting toslimcop
resolves the problem. Let me know if you need further details or steps to reproduce the issue.