Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Inconsistent Formatting (with Interface)

Đang mở
#521 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện đầu vào Java được cung cấp với Prettier-Java 0.5.1 và cấu hình printWidth được hiển thị, sau đó so sánh cách định dạng các khai báo lớp, interface và enum. Xác định hành vi xuống dòng dự kiến hoặc phạm vi áp dụng của tùy chọn, rồi bổ sung coverage thể hiện kết quả đã thống nhất cho các khai báo interface.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
1.2k
Fork
123
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jhipster/prettier-java

Tất cả issue của jhipster/prettier-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.