Angular: closing parenthesis on a new line after ternaries passed to pipes (#5902)

master
Selvazhagan 2019-10-21 02:38:21 -07:00 committed by Georgii Dolzhykov
parent 8a37258a33
commit 10deb1f086
3 changed files with 31 additions and 3 deletions

View File

@ -1014,6 +1014,30 @@ class A {
}
```
#### Angular: Put a closing parenthesis onto a new line after ternaries passed to pipes ([#5682] by [@selvazhagan])
<!-- prettier-ignore -->
```html
<!-- Input -->
{{ (isCustomDiscount ? 'DISCOUNTS__DISCOUNT_TRAINING_HEADER__CUSTOM_DISCOUNT' : 'DISCOUNTS__DISCOUNT_TRAINING_HEADER__DISCOUNT') | translate }}
<!-- Output (Prettier stable) -->
{{
(isCustomDiscount
? "DISCOUNTS__DISCOUNT_TRAINING_HEADER__CUSTOM_DISCOUNT"
: "DISCOUNTS__DISCOUNT_TRAINING_HEADER__DISCOUNT") | translate
}}
<!-- Output (Prettier master) -->
{{
(isCustomDiscount
? "DISCOUNTS__DISCOUNT_TRAINING_HEADER__CUSTOM_DISCOUNT"
: "DISCOUNTS__DISCOUNT_TRAINING_HEADER__DISCOUNT"
) | translate
}}
```
[#5682]: https://github.com/prettier/prettier/pull/5682
[#5910]: https://github.com/prettier/prettier/pull/5910
[#6033]: https://github.com/prettier/prettier/pull/6033
[#6186]: https://github.com/prettier/prettier/pull/6186
@ -1062,3 +1086,4 @@ class A {
[@ericsakmar]: https://github.com/ericsakmar
[@squidfunk]: https://github.com/squidfunk
[@vjeux]: https://github.com/vjeux
[@selvazhagan]: https://github.com/selvazhagan

View File

@ -389,7 +389,10 @@ function printTernaryOperator(path, options, print, operatorOptions) {
const breakClosingParen =
!jsxMode &&
(parent.type === "MemberExpression" ||
parent.type === "OptionalMemberExpression") &&
parent.type === "OptionalMemberExpression" ||
(parent.type === "NGPipeExpression" &&
parent.left === node &&
operatorOptions.breakNested)) &&
!parent.computed;
return maybeGroup(

View File

@ -80,8 +80,8 @@ printWidth: 80
| aaa,
(hideLinqPanel
? "ReportSelection.HideShowLabel_Show.String"
: "ReportSelection.HideShowLabel_Hide.String")
| localize: localizationSection
: "ReportSelection.HideShowLabel_Hide.String"
) | localize: localizationSection
]
================================================================================
`;