Skip to content

Change in method call chaining style #1416

Description

@ekmartin

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions