Whitelist UnaryExpression for parentless objects (#545)

It seems like unary are unlikely to need parenthesis

Fixes #542
master
Christopher Chedeau 2017-02-01 16:24:22 -08:00 committed by GitHub
parent e56fd38604
commit b6c9e42705
3 changed files with 19 additions and 1 deletions

View File

@ -2665,7 +2665,8 @@ function shouldPrintSameLine(node) {
type === "ObjectPattern" ||
type === "StringLiteral" ||
type === "ThisExpression" ||
type === "TypeCastExpression";
type === "TypeCastExpression" ||
type === "UnaryExpression";
}
function printAstToDoc(ast, options) {

View File

@ -1,3 +1,16 @@
exports[`test object.js 1`] = `
"state = {
// students
hoverColumn: -1
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
state = {
// students
hoverColumn: -1
};
"
`;
exports[`test series.js 1`] = `
"1 + ++x;
1 + x++;

4
tests/unary/object.js Normal file
View File

@ -0,0 +1,4 @@
state = {
// students
hoverColumn: -1
};