Put short body of arrow functions on the same line (#829)

By adding a group, we can avoid adding a newline if the expression fits in a single line.

Fixes #800
This commit is contained in:
Christopher Chedeau authored and James Long committed 2017-02-27 17:18:43 -05:00
1 parent edf2bde590
commit 4540f473e9
3 files changed
+24 -1

No files matched your search

+1 -1
View File
@@ -353,7 +353,7 @@ function genericPrintNoParens(path, options, print) {
collapsed,
concat([
concat(parts),
indent(options.tabWidth, concat([line, body]))
group(indent(options.tabWidth, concat([line, body])))
])
]),
{ shouldBreak: willBreak(body) }
@@ -52,3 +52,20 @@ const foo = () => {
};
"
`;
exports[`short_body.js 1`] = `
"const initializeSnapshotState = (
testFile: Path,
update: boolean,
testPath: string,
expand: boolean,
) => new SnapshotState(testFile, update, testPath, expand);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const initializeSnapshotState = (
testFile: Path,
update: boolean,
testPath: string,
expand: boolean
) => new SnapshotState(testFile, update, testPath, expand);
"
`;
+6
View File
@@ -0,0 +1,6 @@
const initializeSnapshotState = (
testFile: Path,
update: boolean,
testPath: string,
expand: boolean,
) => new SnapshotState(testFile, update, testPath, expand);