prettier 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -6
- data/README.md +16 -16
- data/exe/rbprettier +2 -2
- data/lib/prettier/rake/task.rb +5 -5
- data/lib/prettier.rb +11 -11
- data/package.json +9 -23
- data/rubocop.yml +6 -6
- data/{dist/parser → src}/getInfo.js +0 -1
- data/{dist/parser → src}/netcat.js +0 -1
- data/src/parseSync.js +212 -0
- data/src/plugin.js +161 -0
- data/{dist/parser → src}/server.rb +45 -31
- metadata +94 -78
- data/bin/console +0 -7
- data/dist/haml/embed.js +0 -53
- data/dist/haml/parser.js +0 -31
- data/dist/haml/parser.rb +0 -149
- data/dist/haml/printer.js +0 -336
- data/dist/parser/parseSync.js +0 -179
- data/dist/plugin.js +0 -143
- data/dist/prettier.js +0 -15
- data/dist/rbs/parser.js +0 -34
- data/dist/rbs/parser.rb +0 -155
- data/dist/rbs/printer.js +0 -525
- data/dist/ruby/embed.js +0 -115
- data/dist/ruby/location.js +0 -19
- data/dist/ruby/nodes/alias.js +0 -60
- data/dist/ruby/nodes/aref.js +0 -51
- data/dist/ruby/nodes/args.js +0 -138
- data/dist/ruby/nodes/arrays.js +0 -122
- data/dist/ruby/nodes/assign.js +0 -37
- data/dist/ruby/nodes/blocks.js +0 -90
- data/dist/ruby/nodes/calls.js +0 -263
- data/dist/ruby/nodes/case.js +0 -50
- data/dist/ruby/nodes/class.js +0 -54
- data/dist/ruby/nodes/commands.js +0 -138
- data/dist/ruby/nodes/conditionals.js +0 -246
- data/dist/ruby/nodes/constants.js +0 -35
- data/dist/ruby/nodes/flow.js +0 -59
- data/dist/ruby/nodes/hashes.js +0 -126
- data/dist/ruby/nodes/heredocs.js +0 -30
- data/dist/ruby/nodes/hooks.js +0 -35
- data/dist/ruby/nodes/ints.js +0 -27
- data/dist/ruby/nodes/lambdas.js +0 -70
- data/dist/ruby/nodes/loops.js +0 -75
- data/dist/ruby/nodes/massign.js +0 -60
- data/dist/ruby/nodes/methods.js +0 -50
- data/dist/ruby/nodes/operators.js +0 -68
- data/dist/ruby/nodes/params.js +0 -95
- data/dist/ruby/nodes/patterns.js +0 -119
- data/dist/ruby/nodes/regexp.js +0 -45
- data/dist/ruby/nodes/rescue.js +0 -86
- data/dist/ruby/nodes/return.js +0 -100
- data/dist/ruby/nodes/statements.js +0 -110
- data/dist/ruby/nodes/strings.js +0 -220
- data/dist/ruby/nodes/super.js +0 -26
- data/dist/ruby/nodes/undef.js +0 -31
- data/dist/ruby/nodes.js +0 -177
- data/dist/ruby/parser.js +0 -35
- data/dist/ruby/parser.rb +0 -9134
- data/dist/ruby/printer.js +0 -67
- data/dist/ruby/toProc.js +0 -91
- data/dist/types/haml.js +0 -4
- data/dist/types/plugin.js +0 -3
- data/dist/types/rbs.js +0 -4
- data/dist/types/ruby.js +0 -4
- data/dist/types/utils.js +0 -2
- data/dist/types.js +0 -34
- data/dist/utils/containsAssignment.js +0 -18
- data/dist/utils/getChildNodes.js +0 -305
- data/dist/utils/getTrailingComma.js +0 -6
- data/dist/utils/hasAncestor.js +0 -15
- data/dist/utils/inlineEnsureParens.js +0 -49
- data/dist/utils/isEmptyBodyStmt.js +0 -10
- data/dist/utils/isEmptyParams.js +0 -12
- data/dist/utils/isEmptyStmts.js +0 -10
- data/dist/utils/literal.js +0 -8
- data/dist/utils/literallineWithoutBreakParent.js +0 -8
- data/dist/utils/makeCall.js +0 -14
- data/dist/utils/noIndent.js +0 -11
- data/dist/utils/printEmptyCollection.js +0 -46
- data/dist/utils/skipAssignIndent.js +0 -19
- data/dist/utils.js +0 -32
data/dist/utils/makeCall.js
DELETED
@@ -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;
|
data/dist/utils/noIndent.js
DELETED
@@ -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; } });
|