From 91fee105a3641b2b6dc0d3d074d474f4ae0ca765 Mon Sep 17 00:00:00 2001 From: Ika Date: Thu, 8 Nov 2018 16:23:55 +0800 Subject: [PATCH 1/2] test: add tests --- .../__snapshots__/jsfmt.spec.js.snap | 9 +++++++-- tests/angular_interpolation/pipe-expression.ng | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap index 8885a5343b2b..7374ceb3c077 100644 --- a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap +++ b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap @@ -36,7 +36,8 @@ exports[`pipe-expression.ng - __ng_interpolation-verify 1`] = ` keyA: reallySuperLongValue, keyB: shortValue | pipeB | pipeC: valueToPipeC } - | aaa + | aaa, + (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection) ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ @@ -63,6 +64,10 @@ exports[`pipe-expression.ng - __ng_interpolation-verify 1`] = ` keyA: reallySuperLongValue, keyB: shortValue | pipeB | pipeC: valueToPipeC } - | aaa + | aaa, + hideLinqPanel + ? "ReportSelection.HideShowLabel_Show.String" + : "ReportSelection.HideShowLabel_Hide.String" + | localize: localizationSection ] `; diff --git a/tests/angular_interpolation/pipe-expression.ng b/tests/angular_interpolation/pipe-expression.ng index 9477cadb738a..349b7ba0c54f 100644 --- a/tests/angular_interpolation/pipe-expression.ng +++ b/tests/angular_interpolation/pipe-expression.ng @@ -20,5 +20,6 @@ keyA: reallySuperLongValue, keyB: shortValue | pipeB | pipeC: valueToPipeC } - | aaa + | aaa, + (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection) ] From 32342f703960a8b5cfd055754a1d84c8d440a19e Mon Sep 17 00:00:00 2001 From: Ika Date: Thu, 8 Nov 2018 16:24:28 +0800 Subject: [PATCH 2/2] fix(angular): add missing parens for pipe in ternary --- src/language-js/needs-parens.js | 1 + tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/language-js/needs-parens.js b/src/language-js/needs-parens.js index 4d65e92987ea..d81b31252a9f 100644 --- a/src/language-js/needs-parens.js +++ b/src/language-js/needs-parens.js @@ -513,6 +513,7 @@ function needsParens(path, options) { case "SpreadProperty": case "BinaryExpression": case "LogicalExpression": + case "NGPipeExpression": case "ExportDefaultDeclaration": case "AwaitExpression": case "JSXSpreadAttribute": diff --git a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap index 7374ceb3c077..731741e5e177 100644 --- a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap +++ b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap @@ -65,9 +65,9 @@ exports[`pipe-expression.ng - __ng_interpolation-verify 1`] = ` keyB: shortValue | pipeB | pipeC: valueToPipeC } | aaa, - hideLinqPanel + (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" - : "ReportSelection.HideShowLabel_Hide.String" + : "ReportSelection.HideShowLabel_Hide.String") | localize: localizationSection ] `;