Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Inconsistent Formatting (with Interface)

Aperta
#521 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

Inizia riproducendo l’input Java fornito con Prettier-Java 0.5.1 e la configurazione printWidth mostrata, quindi confronta la formattazione delle dichiarazioni di classe, interfaccia ed enum. Determina il comportamento previsto per i ritorni a capo o l’ambito dell’opzione, e aggiungi una copertura che mostri il risultato concordato per le dichiarazioni di interfaccia.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
1.2k
Fork
123
Merge medio
2g 10h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jhipster/prettier-java

Tutte le issue di jhipster/prettier-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.