WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Non-stable formatting with a multi-line comment in a method chain #1420

@mharris-figma

Description

@mharris-figma

Using prettier 3.2.4 and version 4.0.4 of @pretter/plugin-ruby

The following code snippet:

invites =
  Invite
  .where(id: invite_ids)
  .where(redeemed_at: nil)
  # this is a
  # multi-line-comment
  .limit(20)

Gets formatted as:

invites =
  Invite
    .where(id: invite_ids)
    .where(redeemed_at: nil)# this is a
    # multi-line-comment
    .
    limit(20)

However, this formatting is unstable. When formatting is applied again, it changes to:

invites =
  Invite
    .where(id: invite_ids)
    .where(redeemed_at: nil) # this is a# multi-line-comment
    .
    limit(20)

And then an additional round of formatting results in:

invites =
  Invite
    .where(id: invite_ids)
    .where(redeemed_at: nil) # this is a# multi-line-comment
    .limit(20)

Which is finally stable.

In particular, I hit this when upgrading my codebase from version 1.6.1 of @pretter-plugin-ruby.

The original formatting seems the best?

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