Sha256: fadd86fe29c9a5c9ee6c2b58c9cf91a348ff705486173825f9dba79e63ac302f

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

const { concat, group, hardline, indent, join, line } = require("../prettier");

module.exports = {
  aryptn: (path, opts, print) => {
    const [constant, preargs, splatarg, postargs] = path.getValue().body;
    let args = [];

    if (preargs) {
      args = args.concat(path.map(print, "body", 1));
    }

    if (splatarg) {
      args.push(concat(["*", path.call(print, "body", 2)]));
    }

    if (postargs) {
      args = args.concat(path.map(print, "body", 3));
    }

    args = group(join(concat([",", line]), args));

    if (constant || path.getParentNode().type === "binary") {
      args = concat(["[", args, "]"]);
    }

    if (constant) {
      return concat([path.call(print, "body", 0), args]);
    }

    return args;
  },
  hshptn: () => {
    throw new Error(
      "Hash pattern not currently supported (https://bugs.ruby-lang.org/issues/16008)"
    );
  },
  in: (path, opts, print) =>
    concat([
      "in ",
      path.call(print, "body", 0),
      indent(concat([hardline, path.call(print, "body", 1)]))
    ])
};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prettier-0.21.0 src/nodes/patterns.js
prettier-0.20.1 src/nodes/patterns.js
prettier-0.20.0 src/nodes/patterns.js
prettier-0.19.1 src/nodes/patterns.js
prettier-0.19.0 src/nodes/patterns.js
prettier-0.18.2 src/nodes/patterns.js
prettier-0.18.1 src/nodes/patterns.js
prettier-0.18.0 src/nodes/patterns.js
prettier-0.17.0 src/nodes/patterns.js
prettier-0.16.0 src/nodes/patterns.js
prettier-0.15.1 src/nodes/patterns.js
prettier-0.15.0 src/nodes/patterns.js
prettier-0.14.0 src/nodes/patterns.js