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

Inconsistent Formatting (with Interface) #521

Open
lamergameryt opened this issue Dec 6, 2021 · 1 comment
Open

Inconsistent Formatting (with Interface) #521

lamergameryt opened this issue Dec 6, 2021 · 1 comment

Comments

@lamergameryt
Copy link

lamergameryt commented Dec 6, 2021

Prettier-Java 0.5.1

I'm not sure if this is the intended behavior of Prettier; Prettier adds a new line after class declarations but not after interface declarations.

overrides:
  - files: ["*.java"]
    options:
      printWidth: 120

Input:

public interface ProjectOrBuilder extends com.google.protobuf.MessageOrBuilder {
	String getModelVersion();

	com.google.protobuf.ByteString getModelVersionBytes();

	String getGroupId();

	com.google.protobuf.ByteString getGroupIdBytes();

	String getArtifactId();

	com.google.protobuf.ByteString getArtifactIdBytes();

	String getVersion();
}

Output:

public interface ProjectOrBuilder extends com.google.protobuf.MessageOrBuilder {
	String getModelVersion();

	com.google.protobuf.ByteString getModelVersionBytes();

	String getGroupId();

	com.google.protobuf.ByteString getGroupIdBytes();

	String getArtifactId();

	com.google.protobuf.ByteString getArtifactIdBytes();

	String getVersion();
}

Expected behavior:

public interface ProjectOrBuilder extends com.google.protobuf.MessageOrBuilder {

	String getModelVersion();

	com.google.protobuf.ByteString getModelVersionBytes();

	String getGroupId();

	com.google.protobuf.ByteString getGroupIdBytes();

	String getArtifactId();

	com.google.protobuf.ByteString getArtifactIdBytes();

	String getVersion();
}

I feel like if classes have new lines after their declaration, then interfaces and enums should follow the same pattern as well. An option to choose if newlines are added would be appreciated as well.

I'm not sure if this is a bug or an intended feature, however, I'm creating this issue to discuss this inconsistency in prettier.

@lamergameryt
Copy link
Author

I'm not sure if this helps, but the interface ProjectOrBuilder is present within a parent class. Maybe that's causing some issues with Prettier's formatting?

@lamergameryt lamergameryt changed the title Inconsistent Formatting Inconsistent Formatting (with Interface) Dec 6, 2021
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