prettier 1.6.1 → 2.0.0.pre.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +316 -293
  3. data/CONTRIBUTING.md +6 -9
  4. data/LICENSE +1 -1
  5. data/README.md +11 -12
  6. data/dist/haml/embed.js +53 -0
  7. data/dist/haml/parser.js +31 -0
  8. data/{src → dist}/haml/parser.rb +0 -0
  9. data/dist/haml/printer.js +336 -0
  10. data/dist/parser/getInfo.js +17 -0
  11. data/{src → dist}/parser/netcat.js +1 -0
  12. data/dist/parser/parseSync.js +128 -0
  13. data/dist/parser/server.rb +140 -0
  14. data/dist/plugin.js +143 -0
  15. data/dist/prettier.js +15 -0
  16. data/dist/rbs/parser.js +34 -0
  17. data/{src → dist}/rbs/parser.rb +0 -0
  18. data/dist/rbs/printer.js +517 -0
  19. data/dist/ruby/embed.js +110 -0
  20. data/dist/ruby/nodes/alias.js +59 -0
  21. data/{src → dist}/ruby/nodes/aref.js +26 -35
  22. data/dist/ruby/nodes/args.js +165 -0
  23. data/dist/ruby/nodes/arrays.js +126 -0
  24. data/dist/ruby/nodes/assign.js +41 -0
  25. data/dist/ruby/nodes/blocks.js +68 -0
  26. data/dist/ruby/nodes/calls.js +220 -0
  27. data/dist/ruby/nodes/case.js +50 -0
  28. data/dist/ruby/nodes/class.js +54 -0
  29. data/dist/ruby/nodes/commands.js +124 -0
  30. data/dist/ruby/nodes/conditionals.js +242 -0
  31. data/dist/ruby/nodes/constants.js +38 -0
  32. data/dist/ruby/nodes/flow.js +66 -0
  33. data/dist/ruby/nodes/hashes.js +130 -0
  34. data/dist/ruby/nodes/heredocs.js +30 -0
  35. data/dist/ruby/nodes/hooks.js +35 -0
  36. data/dist/ruby/nodes/ints.js +27 -0
  37. data/dist/ruby/nodes/lambdas.js +69 -0
  38. data/dist/ruby/nodes/loops.js +73 -0
  39. data/dist/ruby/nodes/massign.js +73 -0
  40. data/dist/ruby/nodes/methods.js +70 -0
  41. data/dist/ruby/nodes/operators.js +70 -0
  42. data/dist/ruby/nodes/params.js +89 -0
  43. data/dist/ruby/nodes/patterns.js +109 -0
  44. data/dist/ruby/nodes/regexp.js +45 -0
  45. data/dist/ruby/nodes/rescue.js +82 -0
  46. data/dist/ruby/nodes/return.js +75 -0
  47. data/dist/ruby/nodes/statements.js +111 -0
  48. data/dist/ruby/nodes/strings.js +218 -0
  49. data/dist/ruby/nodes/super.js +30 -0
  50. data/dist/ruby/nodes/undef.js +26 -0
  51. data/dist/ruby/nodes.js +151 -0
  52. data/dist/ruby/parser.js +34 -0
  53. data/{src → dist}/ruby/parser.rb +1215 -252
  54. data/dist/ruby/printer.js +125 -0
  55. data/dist/ruby/toProc.js +93 -0
  56. data/dist/types/haml.js +4 -0
  57. data/dist/types/plugin.js +3 -0
  58. data/dist/types/rbs.js +4 -0
  59. data/dist/types/ruby.js +4 -0
  60. data/dist/types/utils.js +2 -0
  61. data/dist/types.js +30 -0
  62. data/dist/utils/containsAssignment.js +15 -0
  63. data/dist/utils/getTrailingComma.js +6 -0
  64. data/dist/utils/hasAncestor.js +15 -0
  65. data/{src → dist}/utils/inlineEnsureParens.js +16 -17
  66. data/dist/utils/isEmptyBodyStmt.js +10 -0
  67. data/dist/utils/isEmptyStmts.js +10 -0
  68. data/dist/utils/literal.js +8 -0
  69. data/dist/utils/literallineWithoutBreakParent.js +8 -0
  70. data/dist/utils/makeCall.js +13 -0
  71. data/dist/utils/noIndent.js +11 -0
  72. data/dist/utils/printEmptyCollection.js +44 -0
  73. data/dist/utils/skipAssignIndent.js +15 -0
  74. data/dist/utils.js +30 -0
  75. data/node_modules/prettier/bin-prettier.js +313 -190
  76. data/node_modules/prettier/doc.js +191 -323
  77. data/node_modules/prettier/index.js +2753 -3677
  78. data/node_modules/prettier/package.json +1 -1
  79. data/node_modules/prettier/parser-angular.js +13 -14
  80. data/node_modules/prettier/parser-babel.js +7 -7
  81. data/node_modules/prettier/parser-espree.js +7 -7
  82. data/node_modules/prettier/parser-flow.js +7 -7
  83. data/node_modules/prettier/parser-glimmer.js +1 -1
  84. data/node_modules/prettier/parser-graphql.js +1 -1
  85. data/node_modules/prettier/parser-html.js +17 -17
  86. data/node_modules/prettier/parser-markdown.js +9 -9
  87. data/node_modules/prettier/parser-meriyah.js +7 -7
  88. data/node_modules/prettier/parser-postcss.js +2 -2
  89. data/node_modules/prettier/parser-typescript.js +7 -7
  90. data/node_modules/prettier/parser-yaml.js +2 -2
  91. data/node_modules/prettier/third-party.js +143 -78
  92. data/package.json +26 -18
  93. metadata +74 -67
  94. data/src/haml/embed.js +0 -87
  95. data/src/haml/parser.js +0 -23
  96. data/src/haml/printer.js +0 -438
  97. data/src/parser/parseSync.js +0 -172
  98. data/src/parser/server.rb +0 -66
  99. data/src/plugin.js +0 -148
  100. data/src/prettier.js +0 -16
  101. data/src/rbs/parser.js +0 -37
  102. data/src/rbs/printer.js +0 -643
  103. data/src/ruby/embed.js +0 -142
  104. data/src/ruby/nodes/alias.js +0 -73
  105. data/src/ruby/nodes/args.js +0 -222
  106. data/src/ruby/nodes/arrays.js +0 -162
  107. data/src/ruby/nodes/assign.js +0 -47
  108. data/src/ruby/nodes/blocks.js +0 -90
  109. data/src/ruby/nodes/calls.js +0 -246
  110. data/src/ruby/nodes/case.js +0 -65
  111. data/src/ruby/nodes/class.js +0 -64
  112. data/src/ruby/nodes/commands.js +0 -131
  113. data/src/ruby/nodes/conditionals.js +0 -282
  114. data/src/ruby/nodes/constants.js +0 -43
  115. data/src/ruby/nodes/flow.js +0 -74
  116. data/src/ruby/nodes/hashes.js +0 -155
  117. data/src/ruby/nodes/heredocs.js +0 -36
  118. data/src/ruby/nodes/hooks.js +0 -34
  119. data/src/ruby/nodes/ints.js +0 -31
  120. data/src/ruby/nodes/lambdas.js +0 -76
  121. data/src/ruby/nodes/loops.js +0 -98
  122. data/src/ruby/nodes/massign.js +0 -98
  123. data/src/ruby/nodes/methods.js +0 -74
  124. data/src/ruby/nodes/operators.js +0 -83
  125. data/src/ruby/nodes/params.js +0 -106
  126. data/src/ruby/nodes/patterns.js +0 -157
  127. data/src/ruby/nodes/regexp.js +0 -56
  128. data/src/ruby/nodes/rescue.js +0 -101
  129. data/src/ruby/nodes/return.js +0 -94
  130. data/src/ruby/nodes/statements.js +0 -142
  131. data/src/ruby/nodes/strings.js +0 -272
  132. data/src/ruby/nodes/super.js +0 -35
  133. data/src/ruby/nodes/undef.js +0 -42
  134. data/src/ruby/nodes.js +0 -34
  135. data/src/ruby/parser.js +0 -37
  136. data/src/ruby/printer.js +0 -147
  137. data/src/ruby/toProc.js +0 -105
  138. data/src/utils/containsAssignment.js +0 -11
  139. data/src/utils/getTrailingComma.js +0 -5
  140. data/src/utils/hasAncestor.js +0 -17
  141. data/src/utils/isEmptyBodyStmt.js +0 -7
  142. data/src/utils/isEmptyStmts.js +0 -11
  143. data/src/utils/literal.js +0 -7
  144. data/src/utils/literallineWithoutBreakParent.js +0 -7
  145. data/src/utils/makeCall.js +0 -14
  146. data/src/utils/noIndent.js +0 -10
  147. data/src/utils/printEmptyCollection.js +0 -49
  148. data/src/utils/skipAssignIndent.js +0 -17
  149. data/src/utils.js +0 -13
@@ -1,42 +0,0 @@
1
- const {
2
- addTrailingComment,
3
- align,
4
- concat,
5
- group,
6
- join,
7
- line
8
- } = require("../../prettier");
9
-
10
- function printUndefSymbol(path, opts, print) {
11
- const node = path.getValue();
12
-
13
- // Since we're going to descend into the symbol literal to grab out the ident
14
- // node, then we need to make sure we copy over any comments as well,
15
- // otherwise we could accidentally skip printing them.
16
- if (node.comments) {
17
- node.comments.forEach((comment) => {
18
- addTrailingComment(node.body[0], comment);
19
- });
20
- }
21
-
22
- return path.call(print, "body", 0);
23
- }
24
-
25
- function printUndef(path, opts, print) {
26
- const keyword = "undef ";
27
- const argNodes = path.map(
28
- (symbolPath) => printUndefSymbol(symbolPath, opts, print),
29
- "body"
30
- );
31
-
32
- return group(
33
- concat([
34
- keyword,
35
- align(keyword.length, join(concat([",", line]), argNodes))
36
- ])
37
- );
38
- }
39
-
40
- module.exports = {
41
- undef: printUndef
42
- };
data/src/ruby/nodes.js DELETED
@@ -1,34 +0,0 @@
1
- module.exports = Object.assign(
2
- {},
3
- require("./nodes/alias"),
4
- require("./nodes/aref"),
5
- require("./nodes/args"),
6
- require("./nodes/arrays"),
7
- require("./nodes/assign"),
8
- require("./nodes/blocks"),
9
- require("./nodes/calls"),
10
- require("./nodes/case"),
11
- require("./nodes/class"),
12
- require("./nodes/commands"),
13
- require("./nodes/conditionals"),
14
- require("./nodes/constants"),
15
- require("./nodes/flow"),
16
- require("./nodes/hashes"),
17
- require("./nodes/heredocs"),
18
- require("./nodes/hooks"),
19
- require("./nodes/ints"),
20
- require("./nodes/lambdas"),
21
- require("./nodes/loops"),
22
- require("./nodes/massign"),
23
- require("./nodes/methods"),
24
- require("./nodes/operators"),
25
- require("./nodes/params"),
26
- require("./nodes/patterns"),
27
- require("./nodes/regexp"),
28
- require("./nodes/rescue"),
29
- require("./nodes/return"),
30
- require("./nodes/statements"),
31
- require("./nodes/strings"),
32
- require("./nodes/super"),
33
- require("./nodes/undef")
34
- );
data/src/ruby/parser.js DELETED
@@ -1,37 +0,0 @@
1
- const parseSync = require("../parser/parseSync");
2
-
3
- // This function is responsible for taking an input string of text and returning
4
- // to prettier a JavaScript object that is the equivalent AST that represents
5
- // the code stored in that string. We accomplish this by spawning a new Ruby
6
- // process of parser.rb and reading JSON off STDOUT.
7
- function parse(text, _parsers, opts) {
8
- return parseSync("ruby", text, opts);
9
- }
10
-
11
- // This function handles checking whether or not the source string has the
12
- // pragma for prettier. This is an optional workflow for incremental adoption.
13
- function hasPragma(text) {
14
- return /^\s*#[^\S\n]*@(format|prettier)\s*(\n|$)/.test(text);
15
- }
16
-
17
- // This function is critical for comments and cursor support, and is responsible
18
- // for returning the index of the character within the source string that is the
19
- // beginning of the given node.
20
- function locStart(node) {
21
- return node.sc;
22
- }
23
-
24
- // This function is critical for comments and cursor support, and is responsible
25
- // for returning the index of the character within the source string that is the
26
- // ending of the given node.
27
- function locEnd(node) {
28
- return node.ec;
29
- }
30
-
31
- module.exports = {
32
- parse,
33
- astFormat: "ruby",
34
- hasPragma,
35
- locStart,
36
- locEnd
37
- };
data/src/ruby/printer.js DELETED
@@ -1,147 +0,0 @@
1
- const { concat, trim } = require("../prettier");
2
-
3
- const embed = require("./embed");
4
- const nodes = require("./nodes");
5
-
6
- // This is the generic node print function, used to convert any node in the AST
7
- // into its equivalent Doc representation.
8
- function printNode(path, opts, print) {
9
- const { type, body } = path.getValue();
10
-
11
- if (type in nodes) {
12
- return nodes[type](path, opts, print);
13
- }
14
-
15
- if (type[0] === "@") {
16
- return body;
17
- }
18
-
19
- const ast = JSON.stringify(body, null, 2);
20
- throw new Error(`Unsupported node encountered: ${type}\n${ast}`);
21
- }
22
-
23
- // This is an escape-hatch to ignore nodes in the tree. If you have a comment
24
- // that includes this pattern, then the entire node will be ignored and just the
25
- // original source will be printed out.
26
- function hasPrettierIgnore(path) {
27
- const node = path.getValue();
28
-
29
- return (
30
- node.comments &&
31
- node.comments.some((comment) => comment.value.includes("prettier-ignore"))
32
- );
33
- }
34
-
35
- const noComments = [
36
- "args",
37
- "args_add_block",
38
- "args_add_star",
39
- "mlhs",
40
- "mlhs_add_post",
41
- "mlhs_add_star",
42
- "mlhs_paren"
43
- ];
44
-
45
- // Certain nodes are used more for organizational purposed than for actually
46
- // displaying content, so we tell prettier that we don't want comments attached
47
- // to them.
48
- function canAttachComment(node) {
49
- return !noComments.includes(node.type);
50
- }
51
-
52
- // This function tells prettier how to recurse down our AST so that it can find
53
- // where it needs to attach the comments.
54
- function getCommentChildNodes(node) {
55
- switch (node.type) {
56
- case "heredoc":
57
- return [node.beging];
58
- case "aryptn":
59
- return [node.body[0]]
60
- .concat(node.body[1])
61
- .concat(node.body[2])
62
- .concat(node.body[3]);
63
- case "hshptn": {
64
- const pairs = node.body[1];
65
- const values = pairs.reduce((left, right) => left.concat(right), []);
66
-
67
- return [node.body[0]].concat(values).concat(node.body[2]);
68
- }
69
- case "params": {
70
- const [reqs, optls, rest, post, kwargs, kwargRest, block] = node.body;
71
- let parts = reqs || [];
72
-
73
- (optls || []).forEach((optl) => {
74
- parts = parts.concat(optl);
75
- });
76
-
77
- if (rest) {
78
- parts.push(rest);
79
- }
80
-
81
- parts = parts.concat(post || []);
82
-
83
- (kwargs || []).forEach((kwarg) => {
84
- if (kwarg[1]) {
85
- parts = parts.concat(kwarg);
86
- } else {
87
- parts.push(kwarg[0]);
88
- }
89
- });
90
-
91
- if (kwargRest && kwargRest !== "nil") {
92
- parts.push(kwargRest);
93
- }
94
-
95
- if (block) {
96
- parts.push(block);
97
- }
98
-
99
- return parts;
100
- }
101
- default: {
102
- if (Array.isArray(node.body)) {
103
- return node.body.filter((child) => child && typeof child === "object");
104
- }
105
- return [];
106
- }
107
- }
108
- }
109
-
110
- // This is the generic print function for any comment in the AST. It handles
111
- // both regular comments that begin with a # and embdoc comments, which are
112
- // surrounded by =begin..=end.
113
- function printComment(path, _opts) {
114
- const comment = path.getValue();
115
-
116
- if (comment.type === "@comment") {
117
- return `#${comment.value}`;
118
- }
119
-
120
- return concat([trim, comment.value]);
121
- }
122
-
123
- // To be honest I'm not 100% sure this function is actually necessary, but it
124
- // *feels* like a block comment equivalent in JavaScript so I'm going to leave
125
- // it in place for now.
126
- function isBlockComment(comment) {
127
- return comment.type === "@embdoc";
128
- }
129
-
130
- // This function handles adding the format pragma to a source string. This is an
131
- // optional workflow for incremental adoption.
132
- function insertPragma(text) {
133
- const boundary = text.startsWith("#") ? "\n" : "\n\n";
134
-
135
- return `# @format${boundary}${text}`;
136
- }
137
-
138
- module.exports = {
139
- embed,
140
- print: printNode,
141
- hasPrettierIgnore,
142
- canAttachComment,
143
- getCommentChildNodes,
144
- printComment,
145
- isBlockComment,
146
- insertPragma
147
- };
data/src/ruby/toProc.js DELETED
@@ -1,105 +0,0 @@
1
- const isCall = (node) => ["::", "."].includes(node) || node.type === "@period";
2
-
3
- // If you have a simple block that only calls a method on the single required
4
- // parameter that is passed to it, then you can replace that block with the
5
- // simpler `Symbol#to_proc`. Meaning, it would go from:
6
- //
7
- // [1, 2, 3].map { |i| i.to_s }
8
- //
9
- // to:
10
- //
11
- // [1, 2, 3].map(&:to_s)
12
- //
13
- // This works with `do` blocks as well.
14
- const toProc = (path, node) => {
15
- const [variables, blockContents] = node.body;
16
-
17
- // Ensure that there are variables being passed to this block.
18
- const params = variables && variables.body[0];
19
- if (!params) {
20
- return null;
21
- }
22
-
23
- // Ensure there is one and only one parameter, and that it is required.
24
- const reqParams = params.body[0];
25
- const otherParams = params.body.slice(1);
26
- if (
27
- !Array.isArray(reqParams) ||
28
- reqParams.length !== 1 ||
29
- otherParams.some(Boolean)
30
- ) {
31
- return null;
32
- }
33
-
34
- let statements;
35
- if (blockContents.type === "bodystmt") {
36
- // We’re in a `do` block
37
- const blockStatements = blockContents.body[0];
38
- const rescueElseEnsure = blockContents.body.slice(1);
39
-
40
- // You can’t use the to_proc shortcut if you’re rescuing
41
- if (rescueElseEnsure.some(Boolean)) {
42
- return null;
43
- }
44
-
45
- statements = blockStatements;
46
- } else {
47
- // We’re in a brace block
48
- statements = blockContents;
49
- }
50
-
51
- // Ensure the block contains only one statement
52
- if (statements.body.length !== 1) {
53
- return null;
54
- }
55
-
56
- // Ensure that statement is a call and that it has no comments attached
57
- const [statement] = statements.body;
58
- if (statement.type !== "call" || statement.comments) {
59
- return null;
60
- }
61
-
62
- // Ensure the call is a method of the block argument
63
- const [varRef, call, method, args] = statement.body;
64
-
65
- if (
66
- varRef.type !== "var_ref" ||
67
- varRef.body[0].body !== reqParams[0].body ||
68
- !isCall(call) ||
69
- method.type !== "@ident" ||
70
- args
71
- ) {
72
- return null;
73
- }
74
-
75
- // Ensure that we're not inside of a hash that is being passed to a key that
76
- // corresponds to `:if` or `:unless` to avoid problems with callbacks with
77
- // Rails. For more context, see:
78
- // https://github.com/prettier/plugin-ruby/issues/449
79
- let assocNode = null;
80
-
81
- if (path.getValue().type === "method_add_block") {
82
- assocNode = path.getParentNode();
83
- } else {
84
- assocNode = path.getParentNode(2);
85
- }
86
-
87
- if (assocNode && assocNode.type === "assoc_new") {
88
- const [key] = assocNode.body;
89
-
90
- if (key.type === "@label" && ["if:", "unless:"].includes(key.body)) {
91
- return null;
92
- }
93
-
94
- if (
95
- key.type === "symbol_literal" &&
96
- ["if", "unless"].includes(key.body[0].body)
97
- ) {
98
- return null;
99
- }
100
- }
101
-
102
- return `&:${method.body}`;
103
- };
104
-
105
- module.exports = toProc;
@@ -1,11 +0,0 @@
1
- // If the node is a type of assignment or if the node is a paren and nested
2
- // inside that paren is a node that is a type of assignment.
3
- function containsAssignment(node) {
4
- return (
5
- node &&
6
- (["assign", "massign", "opassign"].includes(node.type) ||
7
- (Array.isArray(node.body) && node.body.some(containsAssignment)))
8
- );
9
- }
10
-
11
- module.exports = containsAssignment;
@@ -1,5 +0,0 @@
1
- function getTrailingComma(opts) {
2
- return ["all", "es5"].includes(opts.trailingComma);
3
- }
4
-
5
- module.exports = getTrailingComma;
@@ -1,17 +0,0 @@
1
- function hasAncestor(path, types) {
2
- let parent = 0;
3
- let parentNode = path.getParentNode();
4
-
5
- while (parentNode) {
6
- if (types.includes(parentNode.type)) {
7
- return true;
8
- }
9
-
10
- parent += 1;
11
- parentNode = path.getParentNode(parent);
12
- }
13
-
14
- return false;
15
- }
16
-
17
- module.exports = hasAncestor;
@@ -1,7 +0,0 @@
1
- const isEmptyStmts = require("./isEmptyStmts");
2
-
3
- function isEmptyBodyStmt(node) {
4
- return isEmptyStmts(node.body[0]) && !node.body.slice(1).some(Boolean);
5
- }
6
-
7
- module.exports = isEmptyBodyStmt;
@@ -1,11 +0,0 @@
1
- function isEmptyStmts(node) {
2
- return (
3
- node &&
4
- node.type === "stmts" &&
5
- node.body.length === 1 &&
6
- node.body[0].type === "void_stmt" &&
7
- !node.body[0].comments
8
- );
9
- }
10
-
11
- module.exports = isEmptyStmts;
data/src/utils/literal.js DELETED
@@ -1,7 +0,0 @@
1
- function literal(value) {
2
- return function printLiteral() {
3
- return value;
4
- };
5
- }
6
-
7
- module.exports = literal;
@@ -1,7 +0,0 @@
1
- const literallineWithoutBreakParent = {
2
- type: "line",
3
- hard: true,
4
- literal: true
5
- };
6
-
7
- module.exports = literallineWithoutBreakParent;
@@ -1,14 +0,0 @@
1
- function makeCall(path, opts, print) {
2
- const operation = path.getValue().body[1];
3
-
4
- // Ignoring the next block for coverage information because it's only relevant
5
- // in Ruby 2.5 and below.
6
- /* istanbul ignore next */
7
- if ([".", "&."].includes(operation)) {
8
- return operation;
9
- }
10
-
11
- return operation === "::" ? "." : path.call(print, "body", 1);
12
- }
13
-
14
- module.exports = makeCall;
@@ -1,10 +0,0 @@
1
- const noIndent = [
2
- "array",
3
- "hash",
4
- "heredoc",
5
- "if",
6
- "unless",
7
- "xstring_literal"
8
- ];
9
-
10
- module.exports = noIndent;
@@ -1,49 +0,0 @@
1
- const { concat, group, hardline, indent, join, line } = require("../prettier");
2
-
3
- function containedWithin(node) {
4
- return function containedWithinNode(comment) {
5
- return comment.sc >= node.sc && comment.ec <= node.ec;
6
- };
7
- }
8
-
9
- // Empty collections are array or hash literals that do not contain any
10
- // contents. They can, however, have comments inside the body. You can solve
11
- // this by having a child node inside the array that gets the comments attached
12
- // to it, but that requires modifying the parser. Instead, we can just manually
13
- // print out the non-leading comments here.
14
- function printEmptyCollection(path, opts, startToken, endToken) {
15
- const node = path.getValue();
16
- const containedWithinNode = containedWithin(node);
17
-
18
- // If there are no comments or only leading comments, then we can just print
19
- // out the start and end token and be done, as there are no comments inside
20
- // the body of this node.
21
- if (!node.comments || !node.comments.some(containedWithinNode)) {
22
- return `${startToken}${endToken}`;
23
- }
24
-
25
- const comments = [];
26
-
27
- // For each comment, go through its path and print it out manually.
28
- const printComment = (commentPath) => {
29
- const comment = commentPath.getValue();
30
-
31
- if (containedWithinNode(comment)) {
32
- comment.printed = true;
33
- comments.push(opts.printer.printComment(commentPath));
34
- }
35
- };
36
-
37
- path.each(printComment, "comments");
38
-
39
- return group(
40
- concat([
41
- startToken,
42
- indent(concat([hardline, join(hardline, comments)])),
43
- line,
44
- endToken
45
- ])
46
- );
47
- }
48
-
49
- module.exports = printEmptyCollection;
@@ -1,17 +0,0 @@
1
- const skippable = [
2
- "array",
3
- "dyna_symbol",
4
- "hash",
5
- "heredoc",
6
- "lambda",
7
- "regexp_literal"
8
- ];
9
-
10
- function skipAssignIndent(node) {
11
- return (
12
- skippable.includes(node.type) ||
13
- (node.type === "call" && skipAssignIndent(node.body[0]))
14
- );
15
- }
16
-
17
- module.exports = skipAssignIndent;
data/src/utils.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- containsAssignment: require("./utils/containsAssignment"),
3
- getTrailingComma: require("./utils/getTrailingComma"),
4
- isEmptyBodyStmt: require("./utils/isEmptyBodyStmt"),
5
- isEmptyStmts: require("./utils/isEmptyStmts"),
6
- hasAncestor: require("./utils/hasAncestor"),
7
- literal: require("./utils/literal"),
8
- literallineWithoutBreakParent: require("./utils/literallineWithoutBreakParent"),
9
- makeCall: require("./utils/makeCall"),
10
- noIndent: require("./utils/noIndent"),
11
- printEmptyCollection: require("./utils/printEmptyCollection"),
12
- skipAssignIndent: require("./utils/skipAssignIndent")
13
- };