Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

jtkiesel
Copy link
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
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
7 checks passed
@clementdessoude
Copy link
Contributor

Sorry for the leadtime !

@jtkiesel
Copy link
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