Skip to content

Commit

Permalink
Fix trailing comma for rest element in Babylon (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism authored and vjeux committed Apr 13, 2017
1 parent 4dfe92a commit 4d9edec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/printer.js
Expand Up @@ -706,8 +706,11 @@ function genericPrintNoParens(path, options, print, args) {
});

const lastElem = util.getLast(n[propertiesField]);
const canHaveTrailingComma = !(lastElem &&
lastElem.type === "RestProperty");

const canHaveTrailingComma = !(
lastElem &&
(lastElem.type === "RestProperty" || lastElem.type === "RestElement")
);

const shouldBreak =
n.type !== "ObjectPattern" &&
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/jsfmt.spec.js
@@ -1 +1 @@
run_spec(__dirname, { trailingComma: "all" });
run_spec(__dirname, { trailingComma: "all" }, ["babylon"]);

0 comments on commit 4d9edec

Please sign in to comment.