Skip to content

[Formatting issue] trailing_commas=preserve not working for some enums with a constructor declaration #1729

Open
@androidseb

Description

@androidseb

When setting trailing_commas to preserve, I would expect the formatter to preserve trailing commas in my code. This is not the case when creating an enum with a constructor as shown below.

What input code did you provide to the formatter?

enum RawPhotoType {
  jpeg('image/jpeg'), png('image/png'),
  ;

  final String mimeType;
  const RawPhotoType(this.mimeType);
}

What output did the formatter produce?

enum RawPhotoType {
  jpeg('image/jpeg'),
  png('image/png');

  final String mimeType;
  const RawPhotoType(this.mimeType);
}

What output did you expect or want the formatter to produce?

enum RawPhotoType {
  jpeg('image/jpeg'),
  png('image/png'),
  ;

  final String mimeType;
  const RawPhotoType(this.mimeType);
}

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