Skip to content

fix(printer): don't wrap broken when-guards in parentheses - #1018

Open
braxtonzhangio wants to merge 5 commits into
jhipster:mainfrom
braxtonzhangio:fix/when-guard-no-needless-parens-1001
Open

fix(printer): don't wrap broken when-guards in parentheses#1018
braxtonzhangio wants to merge 5 commits into
jhipster:mainfrom
braxtonzhangio:fix/when-guard-no-needless-parens-1001

Conversation

@braxtonzhangio

Copy link
Copy Markdown

Summary

With a narrow printWidth, when guards in switch rules wrapped the expression in parentheses (when ( … )). Those parens are unnecessary for Java pattern guards and look noisy next to the trailing ->.

Changes

  • Print when guards by breaking/indenting the expression instead of using ifBreak("(" / ")").
  • Update the existing wrapping snapshot and add a regression fixture for Adds needlessly parentheses #1001 (printWidth: 40).

Test plan

  • npm test (or the repo’s usual unit-test command for test/unit-test)
  • Fixture switch-when-guard-parens matches expected output

Fixes #1001

milan-oscard-8561 added 5 commits August 8, 2026 14:56
Signed-off-by: milan-oscard-8561 <milan-oscard-8561@users.noreply.github.com>
Signed-off-by: milan-oscard-8561 <milan-oscard-8561@users.noreply.github.com>
Signed-off-by: milan-oscard-8561 <milan-oscard-8561@users.noreply.github.com>
Signed-off-by: milan-oscard-8561 <milan-oscard-8561@users.noreply.github.com>
Signed-off-by: milan-oscard-8561 <milan-oscard-8561@users.noreply.github.com>
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.

Adds needlessly parentheses

1 participant