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

Comment before // prettier-ignore on an expression fails with "Comment was not printed"

Aperta
#1,115 0 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
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

The issue provides two Java inputs that trigger the error, one in an array initializer and one in a conditional expression, but names no source files or tests. Start by locating the comment printing and prettier-ignore handling paths and run the relevant tests with these examples. Done means both comments are retained and the ignored expression stays unchanged without a “Comment was not printed” error.

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

Descrizione

Prettier-Java 2.11.0

Input:

class A {
  Object[] a = {
    // explain
    // prettier-ignore
    foo(1,
        2),
  };
}
class A {
  Object f(boolean c) {
    return c
      ? a()
      : // prettier-ignore
        // explain
        b(1,   2);
  }
}

Output:

[error] A.java: Error: Comment "// explain" was not printed. Please report this error!

(Same error for both inputs.)

Expected behavior: Both comments are kept, and the ignored expression is printed as-is. For the first input:

class A {

  Object[] a = {
    // explain
    // prettier-ignore
    foo(1,
        2),
  };
}

Note: This issue is similar to #1098, but that one is about @formatter:on and @formatter:off comments.

Lingua principale
Java
Stelle
1.2k
Fork
122
Merge medio
2g 13h
PR unite (30g)
32

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.