Fix dangling comments for arrays (#665)

It was missing a softline. I copy and pasted the dangling handling for objects.

Fixes #624
master
Christopher Chedeau 2017-02-12 20:09:39 -08:00 committed by James Long
parent 8a27e121ed
commit c5bfdae5d8
3 changed files with 37 additions and 1 deletions

View File

@ -712,7 +712,14 @@ function genericPrintNoParens(path, options, print) {
case "ArrayPattern":
if (n.elements.length === 0) {
parts.push(
concat(["[", comments.printDanglingComments(path, options), "]"])
group(
concat([
"[",
comments.printDanglingComments(path, options),
softline,
"]"
])
)
);
} else {
const lastElem = util.getLast(n.elements);

View File

@ -74,6 +74,32 @@ declare class Foo extends Qux<string> {/* dangling */}
"
`;
exports[`test dangling_array.js 1`] = `
"expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
expect(() => {}).toTriggerReadyStateChanges(
[
// Nothing.
]
);
"
`;
exports[`test dangling_array.js 2`] = `
"expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
expect(() => {}).toTriggerReadyStateChanges(
[
// Nothing.
]
);
"
`;
exports[`test first-line.js 1`] = `
"a // comment
b

View File

@ -0,0 +1,3 @@
expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);