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
master
Christopher Chedeau 2017-02-27 14:18:43 -08:00 committed by James Long
parent edf2bde590
commit 4540f473e9
3 changed files with 24 additions and 1 deletions

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) }

View File

@ -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);
"
`;

View File

@ -0,0 +1,6 @@
const initializeSnapshotState = (
testFile: Path,
update: boolean,
testPath: string,
expand: boolean,
) => new SnapshotState(testFile, update, testPath, expand);