-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
prettier-ignore not working as expected #505
Comments
Oh indeed ! I'll have a look |
Thanks for the confirmation. |
I investigated a bit, and it is a bit tricky, as it is only happening if you put the prettier-ignore comment at the beginning of a block. For instance, in the following snippet, the package tech.jhipster;
import java.util.Map;
public class StrangePrettierIgnore {
private StrangePrettierIgnore() {}
public static void drinkBeers() {
int i;
// prettier-ignore
Map<String, String> beers = Map.of(
"beer1", "Gulden Draak",
"beer2", "Piraat",
"beer3", "Kapittel"
);
System.out.println(beers); // not well formated here
}
} This is caused by the way the comments are attached to the most enclosive node. Here, the prettier ignore comment is attached to the global I'm not sure how to handle this. One way could be to ignore some node types when we are trying to attach comments, but it could be a bit complex. I may need some time to find a correct solution... |
Hi, I tried this version of the plugin com.hubspot.maven.plugins prettier-maven-plugin 0.8case 1: without //prettier-ignore package com.example.demo; import org.springframework.boot.SpringApplication; @SpringBootApplication
} was formatted to: as expected. import org.springframework.boot.SpringApplication; @SpringBootApplication
} package com.example.demo; import org.springframework.boot.SpringApplication; //prettier-ignore
} is there a defect at all? maybe I'm missing something here? Asha |
any update here? |
@jtkiesel : approved, thanks for your work |
// prettier-ignore
seems not working as expected, unless I don't know how to use it.If I use
// @formatter:off
and// @formatter:on
, it works well.Prettier-Java 1.4.0
Input:
Output:
Expected behavior:
The text was updated successfully, but these errors were encountered: