Always output comment newlines, fix edge case with function param output
This commit is contained in:
1 parent
67e2f6d482
commit
835befebf5
5 files changed
+1998
-15
No files matched your search
+3
-3
@@ -6,7 +6,7 @@ var isObject = types.builtInTypes.object;
|
||||
var pp = require("./pp");
|
||||
var fromString = pp.fromString;
|
||||
var concat = pp.concat;
|
||||
var line = pp.line;
|
||||
var hardline = pp.hardline;
|
||||
var util = require("./util");
|
||||
var comparePos = util.comparePos;
|
||||
var childNodesCacheKey = require("private").makeUniqueKey();
|
||||
@@ -266,7 +266,7 @@ function printLeadingComment(commentPath, print) {
|
||||
if (comment.trailing) {
|
||||
// When we print trailing comments as leading comments, we don't
|
||||
// want to bring any trailing spaces along.
|
||||
parts.push(line);
|
||||
parts.push(hardline);
|
||||
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ function printLeadingComment(commentPath, print) {
|
||||
|
||||
// }
|
||||
else {
|
||||
parts.push(line);
|
||||
parts.push(hardline);
|
||||
}
|
||||
|
||||
return concat(parts);
|
||||
|
||||
+5
-2
@@ -1740,7 +1740,6 @@ function printArgumentsList(path, options, print) {
|
||||
return "()";
|
||||
}
|
||||
|
||||
const shouldBreak = printed.slice(0, -1).some(hasHardLine);
|
||||
const lastArg = util.getLast(path.getValue().arguments);
|
||||
// This is just an optimization; I think we could return the
|
||||
// conditional group for all function calls, but it's more expensive
|
||||
@@ -1748,9 +1747,12 @@ function printArgumentsList(path, options, print) {
|
||||
const groupLastArg = lastArg.type === "ObjectExpression" ||
|
||||
lastArg.type === "ArrayExpression" ||
|
||||
lastArg.type === "FunctionExpression" ||
|
||||
lastArg.type === "ArrowFunctionExpression";
|
||||
lastArg.type === "ArrowFunctionExpression" ||
|
||||
lastArg.type === "CallExpression" ||
|
||||
lastArg.type === "NewExpression";
|
||||
|
||||
if (groupLastArg) {
|
||||
const shouldBreak = printed.slice(0, -1).some(hasHardLine);
|
||||
return conditionalGroup(
|
||||
[
|
||||
concat([
|
||||
@@ -1784,6 +1786,7 @@ function printArgumentsList(path, options, print) {
|
||||
);
|
||||
}
|
||||
|
||||
const shouldBreak = printed.some(hasHardLine);
|
||||
return group(
|
||||
concat([
|
||||
"(",
|
||||
|
||||
+1980
File diff suppressed because it is too large.
Load diff
@@ -67,8 +67,8 @@ class MyWriteStream extends stream.Writable {}
|
||||
class MyDuplex extends stream.Duplex {}
|
||||
class MyTransform extends stream.Duplex {}
|
||||
|
||||
new MyReadStream().pipe(new MyDuplex()).pipe(new MyTransform()).pipe(
|
||||
new MyWriteStream()
|
||||
);
|
||||
new MyReadStream().pipe(
|
||||
new MyDuplex()
|
||||
).pipe(new MyTransform()).pipe(new MyWriteStream());
|
||||
"
|
||||
`;
|
||||
@@ -438,8 +438,8 @@ new Promise((resolve, reject) => resolve(0)).then(function(num) {
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
resolve(new Promise(function(resolve, reject) {
|
||||
resolve(0);
|
||||
}));
|
||||
resolve(0);
|
||||
}));
|
||||
}).then(function(num) {
|
||||
var a: number = num;
|
||||
var b: string = num;
|
||||
@@ -447,10 +447,10 @@ new Promise(function(resolve, reject) {
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
resolve(new Promise(function(resolve, reject) {
|
||||
resolve(new Promise(function(resolve, reject) {
|
||||
resolve(0);
|
||||
}));
|
||||
resolve(new Promise(function(resolve, reject) {
|
||||
resolve(0);
|
||||
}));
|
||||
}));
|
||||
}).then(function(num) {
|
||||
var a: number = num;
|
||||
var b: string = num;
|
||||
@@ -481,8 +481,8 @@ new Promise(function(resolve, reject) {
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
reject(new Promise(function(resolve, reject) {
|
||||
reject(0);
|
||||
}));
|
||||
reject(0);
|
||||
}));
|
||||
}).catch(function(num) {
|
||||
var a: Promise<number> = num;
|
||||
var b: number = num;
|
||||
|
||||
Reference in new issue
Block a user