Disable trailingComma for Angular internal parser (#6912)

This commit is contained in:
fisker Cheung authored and Simon Lydell committed 2019-11-14 17:06:45 +01:00
1 parent 4ed5253509
commit ab88423a4a
3 files changed
+188

No files matched your search

+10
View File
@@ -120,6 +120,16 @@ 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) {
@@ -20,6 +20,48 @@ printWidth: 80
================================================================================
`;
exports[`logical-expression.ng 2`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "es5"
| 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"]
@@ -85,3 +127,137 @@ printWidth: 80
]
================================================================================
`;
exports[`pipe-expression.ng 2`] = `
====================================options=====================================
parsers: ["__ng_interpolation"]
printWidth: 80
trailingComma: "es5"
| 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
]
================================================================================
`;
@@ -1 +1,3 @@
run_spec(__dirname, ["__ng_interpolation"]);
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "es5" });
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "all" });