Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document RuboCop's Style/Lambda should be disabled #816

Merged
merged 2 commits into from
Feb 5, 2021

Conversation

valscion
Copy link
Contributor

@valscion valscion commented Feb 5, 2021

I noticed that Style/Lambda cop from RuboCop has a chance on conflicting with the way @prettier/plugin-ruby wants to format code.

Say we have this original code:

something = -> { a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb }

After prettifying, the code will turn to this:

something = -> do
  a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb
end

However, RuboCop does not like this, and would prefer multiline lambdas to instead look like this:

something = lambda do
  a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb
end

But if I did that change, then after prettier run, the code would turn to this one:

something =
  lambda { a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb }

which Style/Lambda cop would then complain that the code should be like this instead:

something =
  -> { a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb }

...but if I did that, then we'd be back at this code after prettier run:

something = -> do
  a_very_long_line_that_needs_to_be_splitted_to_next_one_aaa_bbb
end

So in the end, what we decided to do was disable Style/Lambda for the Ruby files that are formatted with Prettier. I figured it would be worth it to document this cop needs to be disabled in order not to cause conflicts between RuboCop and @prettier/plugin-ruby.

@kddnewton
Copy link
Member

You even did the CHANGELOG entry! Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants