jhipster / jhipster/prettier-java

Inconsistent Formatting (with Interface)

Open
#521 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
120
Avg merge
1d 14h
Merged PRs (30d)
27

Description

**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.

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

**Input:**

```java
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:**

```java
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:**

```java
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.