diff --git a/src/language-html/printer-html.js b/src/language-html/printer-html.js index aa554d631..40840b24f 100644 --- a/src/language-html/printer-html.js +++ b/src/language-html/printer-html.js @@ -1021,7 +1021,7 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) { if (options.parser === "angular") { const ngTextToDoc = (code, opts) => // angular does not allow trailing comma - textToDoc(code, { trailingComma: "none", ...opts }); + textToDoc(code, { ...opts, trailingComma: "none" }); /** * *directive="angularDirective" diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 05f6d8672..4ff99219d 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -120,16 +120,6 @@ const { let uid = 0; function shouldPrintComma(options, level) { - // angular does not allow trailing comma - if ( - options.parser === "__ng_interpolation" || - options.parser === "__ng_action" || - options.parser === "__ng_binding" || - options.parser === "__ng_directive" - ) { - return false; - } - level = level || "es5"; switch (options.trailingComma) { diff --git a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap index 5bc48f0b1..6a2fb8fcb 100644 --- a/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap +++ b/tests/angular_interpolation/__snapshots__/jsfmt.spec.js.snap @@ -21,47 +21,6 @@ trailingComma: "none" ================================================================================ `; -exports[`logical-expression.ng 2`] = ` -====================================options===================================== -parsers: ["__ng_interpolation"] -printWidth: 80 - | printWidth -=====================================input====================================== -[ - advancedSearchService.patientInformationFieldsRow2 && advancedSearchService.patientInformationFieldsRow2.indexOf(advancedSearchService.formElementData.customFieldList[i].customFieldType) !== -1 -] - -=====================================output===================================== -[ - advancedSearchService.patientInformationFieldsRow2 && - advancedSearchService.patientInformationFieldsRow2.indexOf( - advancedSearchService.formElementData.customFieldList[i].customFieldType - ) !== -1 -] -================================================================================ -`; - -exports[`logical-expression.ng 3`] = ` -====================================options===================================== -parsers: ["__ng_interpolation"] -printWidth: 80 -trailingComma: "all" - | printWidth -=====================================input====================================== -[ - advancedSearchService.patientInformationFieldsRow2 && advancedSearchService.patientInformationFieldsRow2.indexOf(advancedSearchService.formElementData.customFieldList[i].customFieldType) !== -1 -] - -=====================================output===================================== -[ - advancedSearchService.patientInformationFieldsRow2 && - advancedSearchService.patientInformationFieldsRow2.indexOf( - advancedSearchService.formElementData.customFieldList[i].customFieldType - ) !== -1 -] -================================================================================ -`; - exports[`pipe-expression.ng 1`] = ` ====================================options===================================== parsers: ["__ng_interpolation"] @@ -128,136 +87,3 @@ trailingComma: "none" ] ================================================================================ `; - -exports[`pipe-expression.ng 2`] = ` -====================================options===================================== -parsers: ["__ng_interpolation"] -printWidth: 80 - | printWidth -=====================================input====================================== -[ - a ? (b | c : d) : (e | f : g), - a | b | c | d, - ((a | b) | c) | d, - a | b:(c | d), - { a: b | c }, - (a + b) | c, - (a | b) + c, - fn(a | b), - a?.b(c | d), - a[b | c], - ($students | async).items, - ($students | async)(), - myData | myPipe:'arg1':'arg2':'arg3', - value - | pipeA: { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - | aaa, - (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection) -] - -=====================================output===================================== -[ - a ? (b | c: d) : (e | f: g), - a | b | c | d, - a | b | c | d, - a | b: (c | d), - { a: b | c }, - a + b | c, - (a | b) + c, - fn(a | b), - a?.b(c | d), - a[b | c], - ($students | async).items, - ($students | async)(), - myData | myPipe: "arg1":"arg2":"arg3", - value - | pipeA - : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - | aaa, - (hideLinqPanel - ? "ReportSelection.HideShowLabel_Show.String" - : "ReportSelection.HideShowLabel_Hide.String" - ) | localize: localizationSection -] -================================================================================ -`; - -exports[`pipe-expression.ng 3`] = ` -====================================options===================================== -parsers: ["__ng_interpolation"] -printWidth: 80 -trailingComma: "all" - | printWidth -=====================================input====================================== -[ - a ? (b | c : d) : (e | f : g), - a | b | c | d, - ((a | b) | c) | d, - a | b:(c | d), - { a: b | c }, - (a + b) | c, - (a | b) + c, - fn(a | b), - a?.b(c | d), - a[b | c], - ($students | async).items, - ($students | async)(), - myData | myPipe:'arg1':'arg2':'arg3', - value - | pipeA: { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - | aaa, - (hideLinqPanel ? "ReportSelection.HideShowLabel_Show.String" : "ReportSelection.HideShowLabel_Hide.String") | localize:(localizationSection) -] - -=====================================output===================================== -[ - a ? (b | c: d) : (e | f: g), - a | b | c | d, - a | b | c | d, - a | b: (c | d), - { a: b | c }, - a + b | c, - (a | b) + c, - fn(a | b), - a?.b(c | d), - a[b | c], - ($students | async).items, - ($students | async)(), - myData | myPipe: "arg1":"arg2":"arg3", - value - | pipeA - : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - : { - keyA: reallySuperLongValue, - keyB: shortValue | pipeB | pipeC: valueToPipeC - } - | aaa, - (hideLinqPanel - ? "ReportSelection.HideShowLabel_Show.String" - : "ReportSelection.HideShowLabel_Hide.String" - ) | localize: localizationSection -] -================================================================================ -`; diff --git a/tests/angular_interpolation/jsfmt.spec.js b/tests/angular_interpolation/jsfmt.spec.js index 62daf3216..a71bd7c59 100644 --- a/tests/angular_interpolation/jsfmt.spec.js +++ b/tests/angular_interpolation/jsfmt.spec.js @@ -1,3 +1,2 @@ +// We always pass {trailingComma: "none"} when printing run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "none" }); -run_spec(__dirname, ["__ng_interpolation"]); -run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "all" });