plugin-ruby icon indicating copy to clipboard operation
plugin-ruby copied to clipboard

Change in method call chaining style

Open ekmartin opened this issue 2 years ago • 0 comments

I'm upgrading from version 2 to 4 for a large codebase and noticed that the method chaining behavior seems to have changed:

# Before
sig do
  params(foo: String)
    .returns(Integer)
end

# After
sig do
  params(foo: String).returns(Integer)
end

# Before
Fixture
   .of(Foo)
  .create!(bar: 1)

# After
Fixture.of(Foo).create!(
  bar: 1
)

# Before
foo = Foo
  .where(foo: bar)
  .where(baz: 4)

# After
foo =
  Foo.where(
    foo: bar
  ).where(baz: 4)

Which seems intended looking at the tests[0], where it also seems to be a bit inconsistent between tests—e.g., within sig blocks doesn't chain while chains with other methods does. Is there a way to force the old behavior of always chaining? Maybe with a syntax-tree plugin?

[0] https://github.com/prettier/plugin-ruby/blob/main/test/js/ruby/nodes/calls.test.js#L63-L68

ekmartin avatar Dec 28 '23 07:12 ekmartin