Indent conditions inside of !() (#1731)

This has been a longstanding issue and I thought it would be hard to do, but turns out it is pretty easy!

Fixes #774
master
Christopher Chedeau 2017-05-25 16:26:34 -07:00 committed by GitHub
parent 198ba3c065
commit 62679f20f0
4 changed files with 27 additions and 2 deletions

View File

@ -254,6 +254,12 @@ function genericPrintNoParens(path, options, print, args) {
return concat(parts);
}
if (parent.type === "UnaryExpression") {
return group(
concat([indent(concat([softline, concat(parts)])), softline])
);
}
// Avoid indenting sub-expressions in assignment/return/etc statements.
if (
parent.type === "AssignmentExpression" ||

View File

@ -272,3 +272,16 @@ foo(
);
`;
exports[`unary.js 1`] = `
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);
`;

View File

@ -0,0 +1,4 @@
const anyTestFailures = !(
aggregatedResults.numFailedTests === 0 &&
aggregatedResults.numRuntimeErrorTestSuites === 0
);

View File

@ -95,9 +95,11 @@ function hasObjectMode_bad(options: DuplexStreamOptions): boolean {
}
function hasObjectMode_ok(options: DuplexStreamOptions): boolean {
return !!(options.objectMode ||
return !!(
options.objectMode ||
options.readableObjectMode ||
options.writableObjectMode);
options.writableObjectMode
);
}
`;