src/ruby/nodes/params.js in prettier-1.2.3 vs src/ruby/nodes/params.js in prettier-1.2.4

- old
+ new

@@ -27,22 +27,26 @@ block ] = path.getValue().body; let parts = []; if (reqs) { - parts = parts.concat(path.map(print, "body", 0)); + path.each( + (reqPath) => { + // For some very strange reason, if you have a comment attached to a + // rest_param, it shows up here in the list of required params. + if (reqPath.getValue().type !== "rest_param") { + parts.push(print(reqPath)); + } + }, + "body", + 0 + ); } if (optls) { parts = parts.concat( - optls.map((_, index) => - concat([ - path.call(print, "body", 1, index, 0), - " = ", - path.call(print, "body", 1, index, 1) - ]) - ) + path.map((optlPath) => join(" = ", optlPath.map(print)), "body", 1) ); } if (rest && rest.type !== "excessed_comma") { parts.push(path.call(print, "body", 2)); @@ -52,15 +56,19 @@ parts = parts.concat(path.map(print, "body", 3)); } if (kwargs) { parts = parts.concat( - kwargs.map(([, value], index) => { - if (!value) { - return path.call(print, "body", 4, index, 0); - } - return group(join(" ", path.map(print, "body", 4, index))); - }) + path.map( + (kwargPath) => { + if (!kwargPath.getValue()[1]) { + return kwargPath.call(print, 0); + } + return group(join(" ", kwargPath.map(print))); + }, + "body", + 4 + ) ); } if (kwargRest) { parts.push(kwargRest === "nil" ? "**nil" : path.call(print, "body", 5));