prettier 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -6
  3. data/README.md +16 -16
  4. data/exe/rbprettier +2 -2
  5. data/lib/prettier/rake/task.rb +5 -5
  6. data/lib/prettier.rb +11 -11
  7. data/package.json +9 -23
  8. data/rubocop.yml +6 -6
  9. data/{dist/parser → src}/getInfo.js +0 -1
  10. data/{dist/parser → src}/netcat.js +0 -1
  11. data/src/parseSync.js +212 -0
  12. data/src/plugin.js +161 -0
  13. data/{dist/parser → src}/server.rb +45 -31
  14. metadata +94 -78
  15. data/bin/console +0 -7
  16. data/dist/haml/embed.js +0 -53
  17. data/dist/haml/parser.js +0 -31
  18. data/dist/haml/parser.rb +0 -149
  19. data/dist/haml/printer.js +0 -336
  20. data/dist/parser/parseSync.js +0 -179
  21. data/dist/plugin.js +0 -143
  22. data/dist/prettier.js +0 -15
  23. data/dist/rbs/parser.js +0 -34
  24. data/dist/rbs/parser.rb +0 -155
  25. data/dist/rbs/printer.js +0 -525
  26. data/dist/ruby/embed.js +0 -115
  27. data/dist/ruby/location.js +0 -19
  28. data/dist/ruby/nodes/alias.js +0 -60
  29. data/dist/ruby/nodes/aref.js +0 -51
  30. data/dist/ruby/nodes/args.js +0 -138
  31. data/dist/ruby/nodes/arrays.js +0 -122
  32. data/dist/ruby/nodes/assign.js +0 -37
  33. data/dist/ruby/nodes/blocks.js +0 -90
  34. data/dist/ruby/nodes/calls.js +0 -263
  35. data/dist/ruby/nodes/case.js +0 -50
  36. data/dist/ruby/nodes/class.js +0 -54
  37. data/dist/ruby/nodes/commands.js +0 -138
  38. data/dist/ruby/nodes/conditionals.js +0 -246
  39. data/dist/ruby/nodes/constants.js +0 -35
  40. data/dist/ruby/nodes/flow.js +0 -59
  41. data/dist/ruby/nodes/hashes.js +0 -126
  42. data/dist/ruby/nodes/heredocs.js +0 -30
  43. data/dist/ruby/nodes/hooks.js +0 -35
  44. data/dist/ruby/nodes/ints.js +0 -27
  45. data/dist/ruby/nodes/lambdas.js +0 -70
  46. data/dist/ruby/nodes/loops.js +0 -75
  47. data/dist/ruby/nodes/massign.js +0 -60
  48. data/dist/ruby/nodes/methods.js +0 -50
  49. data/dist/ruby/nodes/operators.js +0 -68
  50. data/dist/ruby/nodes/params.js +0 -95
  51. data/dist/ruby/nodes/patterns.js +0 -119
  52. data/dist/ruby/nodes/regexp.js +0 -45
  53. data/dist/ruby/nodes/rescue.js +0 -86
  54. data/dist/ruby/nodes/return.js +0 -100
  55. data/dist/ruby/nodes/statements.js +0 -110
  56. data/dist/ruby/nodes/strings.js +0 -220
  57. data/dist/ruby/nodes/super.js +0 -26
  58. data/dist/ruby/nodes/undef.js +0 -31
  59. data/dist/ruby/nodes.js +0 -177
  60. data/dist/ruby/parser.js +0 -35
  61. data/dist/ruby/parser.rb +0 -9134
  62. data/dist/ruby/printer.js +0 -67
  63. data/dist/ruby/toProc.js +0 -91
  64. data/dist/types/haml.js +0 -4
  65. data/dist/types/plugin.js +0 -3
  66. data/dist/types/rbs.js +0 -4
  67. data/dist/types/ruby.js +0 -4
  68. data/dist/types/utils.js +0 -2
  69. data/dist/types.js +0 -34
  70. data/dist/utils/containsAssignment.js +0 -18
  71. data/dist/utils/getChildNodes.js +0 -305
  72. data/dist/utils/getTrailingComma.js +0 -6
  73. data/dist/utils/hasAncestor.js +0 -15
  74. data/dist/utils/inlineEnsureParens.js +0 -49
  75. data/dist/utils/isEmptyBodyStmt.js +0 -10
  76. data/dist/utils/isEmptyParams.js +0 -12
  77. data/dist/utils/isEmptyStmts.js +0 -10
  78. data/dist/utils/literal.js +0 -8
  79. data/dist/utils/literallineWithoutBreakParent.js +0 -8
  80. data/dist/utils/makeCall.js +0 -14
  81. data/dist/utils/noIndent.js +0 -11
  82. data/dist/utils/printEmptyCollection.js +0 -46
  83. data/dist/utils/skipAssignIndent.js +0 -19
  84. data/dist/utils.js +0 -32
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const makeCall = (path, opts, print) => {
4
- const node = path.getValue();
5
- const operator = node.op;
6
- // Ignoring the next block for coverage information because it's only relevant
7
- // in Ruby 2.5 and below.
8
- /* istanbul ignore next */
9
- if ([".", "&."].includes(operator)) {
10
- return operator;
11
- }
12
- return operator === "::" ? "." : path.call(print, "op");
13
- };
14
- exports.default = makeCall;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const noIndent = [
4
- "array",
5
- "hash",
6
- "heredoc",
7
- "if",
8
- "unless",
9
- "xstring_literal"
10
- ];
11
- exports.default = noIndent;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const prettier_1 = __importDefault(require("../prettier"));
7
- const location_1 = require("../ruby/location");
8
- const { group, hardline, indent, join, line } = prettier_1.default;
9
- function containedWithin(node) {
10
- return function containedWithinNode(comment) {
11
- return ((0, location_1.getStartChar)(comment.loc) >= (0, location_1.getStartChar)(node.loc) &&
12
- (0, location_1.getEndChar)(comment.loc) <= (0, location_1.getEndChar)(node.loc));
13
- };
14
- }
15
- // Empty collections are array or hash literals that do not contain any
16
- // contents. They can, however, have comments inside the body. You can solve
17
- // this by having a child node inside the array that gets the comments attached
18
- // to it, but that requires modifying the parser. Instead, we can just manually
19
- // print out the non-leading comments here.
20
- function printEmptyCollection(path, opts, startToken, endToken) {
21
- const node = path.getValue();
22
- const containedWithinNode = containedWithin(node);
23
- // If there are no comments or only leading comments, then we can just print
24
- // out the start and end token and be done, as there are no comments inside
25
- // the body of this node.
26
- if (!node.comments || !node.comments.some(containedWithinNode)) {
27
- return `${startToken}${endToken}`;
28
- }
29
- const comments = [];
30
- const nodePath = path;
31
- // For each comment, go through its path and print it out manually.
32
- nodePath.each((commentPath) => {
33
- const comment = commentPath.getValue();
34
- if (containedWithinNode(comment)) {
35
- comment.printed = true;
36
- comments.push(opts.printer.printComment(commentPath, opts));
37
- }
38
- }, "comments");
39
- return group([
40
- startToken,
41
- indent([hardline, join(hardline, comments)]),
42
- line,
43
- endToken
44
- ]);
45
- }
46
- exports.default = printEmptyCollection;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const skippable = [
4
- "array",
5
- "dyna_symbol",
6
- "hash",
7
- "heredoc",
8
- "lambda",
9
- "qsymbols",
10
- "qwords",
11
- "regexp_literal",
12
- "symbols",
13
- "words"
14
- ];
15
- function skipAssignIndent(node) {
16
- return (skippable.includes(node.type) ||
17
- (node.type === "call" && skipAssignIndent(node.receiver)));
18
- }
19
- exports.default = skipAssignIndent;
data/dist/utils.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.skipAssignIndent = exports.printEmptyCollection = exports.noIndent = exports.makeCall = exports.literallineWithoutBreakParent = exports.inlineEnsureParens = exports.hasAncestor = exports.getChildNodes = exports.isEmptyStmts = exports.isEmptyParams = exports.isEmptyBodyStmt = exports.getTrailingComma = exports.containsAssignment = void 0;
7
- var containsAssignment_1 = require("./utils/containsAssignment");
8
- Object.defineProperty(exports, "containsAssignment", { enumerable: true, get: function () { return __importDefault(containsAssignment_1).default; } });
9
- var getTrailingComma_1 = require("./utils/getTrailingComma");
10
- Object.defineProperty(exports, "getTrailingComma", { enumerable: true, get: function () { return __importDefault(getTrailingComma_1).default; } });
11
- var isEmptyBodyStmt_1 = require("./utils/isEmptyBodyStmt");
12
- Object.defineProperty(exports, "isEmptyBodyStmt", { enumerable: true, get: function () { return __importDefault(isEmptyBodyStmt_1).default; } });
13
- var isEmptyParams_1 = require("./utils/isEmptyParams");
14
- Object.defineProperty(exports, "isEmptyParams", { enumerable: true, get: function () { return __importDefault(isEmptyParams_1).default; } });
15
- var isEmptyStmts_1 = require("./utils/isEmptyStmts");
16
- Object.defineProperty(exports, "isEmptyStmts", { enumerable: true, get: function () { return __importDefault(isEmptyStmts_1).default; } });
17
- var getChildNodes_1 = require("./utils/getChildNodes");
18
- Object.defineProperty(exports, "getChildNodes", { enumerable: true, get: function () { return __importDefault(getChildNodes_1).default; } });
19
- var hasAncestor_1 = require("./utils/hasAncestor");
20
- Object.defineProperty(exports, "hasAncestor", { enumerable: true, get: function () { return __importDefault(hasAncestor_1).default; } });
21
- var inlineEnsureParens_1 = require("./utils/inlineEnsureParens");
22
- Object.defineProperty(exports, "inlineEnsureParens", { enumerable: true, get: function () { return __importDefault(inlineEnsureParens_1).default; } });
23
- var literallineWithoutBreakParent_1 = require("./utils/literallineWithoutBreakParent");
24
- Object.defineProperty(exports, "literallineWithoutBreakParent", { enumerable: true, get: function () { return __importDefault(literallineWithoutBreakParent_1).default; } });
25
- var makeCall_1 = require("./utils/makeCall");
26
- Object.defineProperty(exports, "makeCall", { enumerable: true, get: function () { return __importDefault(makeCall_1).default; } });
27
- var noIndent_1 = require("./utils/noIndent");
28
- Object.defineProperty(exports, "noIndent", { enumerable: true, get: function () { return __importDefault(noIndent_1).default; } });
29
- var printEmptyCollection_1 = require("./utils/printEmptyCollection");
30
- Object.defineProperty(exports, "printEmptyCollection", { enumerable: true, get: function () { return __importDefault(printEmptyCollection_1).default; } });
31
- var skipAssignIndent_1 = require("./utils/skipAssignIndent");
32
- Object.defineProperty(exports, "skipAssignIndent", { enumerable: true, get: function () { return __importDefault(skipAssignIndent_1).default; } });