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

Change in method call chaining style #1416

Open
ekmartin opened this issue Dec 28, 2023 · 0 comments
Open

Change in method call chaining style #1416

ekmartin opened this issue Dec 28, 2023 · 0 comments

Comments

@ekmartin
Copy link

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

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

No branches or pull requests

1 participant