Repository navigation
Conversation
A `// prettier-ignore` (or `/* prettier-ignore */`) comment sitting between
two annotations in a modifier list was attached by Prettier's default
algorithm as a trailing comment of the preceding annotation, so the
following annotation was still reformatted:
@what
// prettier-ignore
@SuppressFBWarnings({ "A", "B" })
void foo() {}
handleModifiersComments now attaches such a comment as a leading comment of
the following annotation, which makes hasPrettierIgnore keep that annotation
verbatim. Other comments between annotations keep their existing behaviour.
Fixes jhipster#890
jtkiesel
requested changes
Nov 16, 2026
jtkiesel
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution! I've left a comment detailing an issue with this solution, and a potential alternative solution.
Only attach trailing comments to the Modifiers node and drop the annotation special case, so a prettier-ignore comment on the same line as an annotation stays with that annotation.
jtkiesel
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed with this PR:
A
// prettier-ignoreor/* prettier-ignore */comment placed between two annotations was attached by Prettier as a trailing comment of the preceding annotation, so the annotation that follows it was still reformatted.handleModifiersCommentsnow attaches such a comment as a leading comment of the following annotation, so that annotation is printed verbatim. Other comments between annotations are handled as before. A unit test (prettier-ignore/annotation) covers line and block comments, marker annotations and a regular comment that must not ignore anything.Example
Input
Output
Relative issues or prs:
Fixes #890