Propagate hard breaks within member expressions (fixes #1117) (#1193)

This commit is contained in:
James Long authored and Christopher Chedeau committed 2017-04-12 09:26:27 -07:00
1 parent 36bec87d17
commit 9a5b447c7f
3 files changed
+69 -3

No files matched your search

+7 -1
View File
@@ -2827,7 +2827,13 @@ function printMemberChain(path, options, print) {
return group(expanded);
}
return conditionalGroup([oneLine, expanded]);
return concat([
// We only need to check `oneLine` because if `expanded` is chosen
// that means that the parent group has already been broken
// naturally
willBreak(oneLine) ? breakParent : "",
conditionalGroup([oneLine, expanded])
])
}
function isEmptyJSXElement(node) {
+43 -1
View File
@@ -2,9 +2,51 @@
exports[`expand.js 1`] = `
"const veryVeryVeryVeryVeryVeryVeryLong = doc.expandedStates[doc.expandedStates.length - 1];
const small = doc.expandedStates[doc.expandedStates.length - 1];~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const small = doc.expandedStates[doc.expandedStates.length - 1];
const promises = [
promise.resolve().then(console.log).catch(err => {
console.log(err)
return null
}),
redis.fetch(),
other.fetch(),
];
const promises = [
promise.resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch(err => {
console.log(err)
return null
}),
redis.fetch(),
other.fetch(),
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const veryVeryVeryVeryVeryVeryVeryLong =
doc.expandedStates[doc.expandedStates.length - 1];
const small = doc.expandedStates[doc.expandedStates.length - 1];
const promises = [
promise.resolve().then(console.log).catch(err => {
console.log(err);
return null;
}),
redis.fetch(),
other.fetch()
];
const promises = [
promise
.resolve()
.veryLongFunctionCall()
.veryLongFunctionCall()
.then(console.log)
.catch(err => {
console.log(err);
return null;
}),
redis.fetch(),
other.fetch()
];
"
`;
+19 -1
View File
@@ -1,2 +1,20 @@
const veryVeryVeryVeryVeryVeryVeryLong = doc.expandedStates[doc.expandedStates.length - 1];
const small = doc.expandedStates[doc.expandedStates.length - 1];
const small = doc.expandedStates[doc.expandedStates.length - 1];
const promises = [
promise.resolve().then(console.log).catch(err => {
console.log(err)
return null
}),
redis.fetch(),
other.fetch(),
];
const promises = [
promise.resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch(err => {
console.log(err)
return null
}),
redis.fetch(),
other.fetch(),
];