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 #800master
parent
edf2bde590
commit
4540f473e9
|
@ -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);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
const initializeSnapshotState = (
|
||||
testFile: Path,
|
||||
update: boolean,
|
||||
testPath: string,
|
||||
expand: boolean,
|
||||
) => new SnapshotState(testFile, update, testPath, expand);
|
Loading…
Reference in New Issue