Skip to content

fix(parser): no longer ignore whole block when prettier-ignore at start#603

Merged
clementdessoude merged 1 commit intojhipster:mainfrom
jtkiesel:fix/prettier-ignore-at-block-start
Nov 13, 2023
Merged

fix(parser): no longer ignore whole block when prettier-ignore at start#603
clementdessoude merged 1 commit intojhipster:mainfrom
jtkiesel:fix/prettier-ignore-at-block-start

Conversation

@jtkiesel
Copy link
Copy Markdown
Contributor

@jtkiesel jtkiesel commented Sep 6, 2023

What changed with this PR:

When a block begins with // prettier-ignore, only the first statement is ignored, rather than the whole block.

Example

Input

package tech.jhipster;

import java.util.Map;

public class StrangePrettierIgnore {

  private StrangePrettierIgnore() {}

  public static void drinkBeers() {
    // prettier-ignore
    Map<String, String> beers = Map.of(
      "beer1", "Gulden Draak",
      "beer2", "Piraat",
      "beer3", "Kapittel"
    );

           System.out.println(beers); // not well formated here
  }
}

Output

package tech.jhipster;

import java.util.Map;

public class StrangePrettierIgnore {

  private StrangePrettierIgnore() {}

  public static void drinkBeers() {
    // prettier-ignore
    Map<String, String> beers = Map.of(
      "beer1", "Gulden Draak",
      "beer2", "Piraat",
      "beer3", "Kapittel"
    );

    System.out.println(beers); // not well formated here
  }
}

Relative issues or prs:

Closes #505

@jtkiesel
Copy link
Copy Markdown
Contributor Author

@clementdessoude This is a small PR that ought to be a relatively short review & relatively easy to get merged in. Let me know if you have any comments or concerns.

@clementdessoude clementdessoude merged commit b56e69f into jhipster:main Nov 13, 2023
@clementdessoude
Copy link
Copy Markdown
Contributor

Sorry for the leadtime !

@jtkiesel
Copy link
Copy Markdown
Contributor Author

No worries at all, thanks for the review! To be honest I forgot about this one, and happened to see it again yesterday.

@jtkiesel jtkiesel deleted the fix/prettier-ignore-at-block-start branch November 13, 2023 18:21
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

Successfully merging this pull request may close these issues.

prettier-ignore not working as expected

2 participants