prettier 1.4.0 → 1.5.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 +318 -377
- data/package.json +1 -1
- data/src/plugin.js +1 -0
- data/src/rbs/parser.rb +8 -2
- data/src/ruby/embed.js +54 -8
- data/src/ruby/nodes/args.js +20 -6
- data/src/ruby/nodes/class.js +17 -27
- data/src/ruby/nodes/conditionals.js +1 -1
- data/src/ruby/nodes/hashes.js +28 -14
- data/src/ruby/nodes/loops.js +4 -10
- data/src/ruby/nodes/methods.js +4 -11
- data/src/ruby/nodes/statements.js +3 -5
- data/src/ruby/parser.rb +2 -1
- data/src/utils.js +1 -0
- data/src/utils/isEmptyBodyStmt.js +7 -0
- data/src/utils/isEmptyStmts.js +9 -5
- data/src/utils/printEmptyCollection.js +9 -2
- metadata +4 -3
@@ -1,5 +1,11 @@
|
|
1
1
|
const { concat, group, hardline, indent, join, line } = require("../prettier");
|
2
2
|
|
3
|
+
function containedWithin(node) {
|
4
|
+
return function containedWithinNode(comment) {
|
5
|
+
return comment.sc >= node.sc && comment.ec <= node.ec;
|
6
|
+
};
|
7
|
+
}
|
8
|
+
|
3
9
|
// Empty collections are array or hash literals that do not contain any
|
4
10
|
// contents. They can, however, have comments inside the body. You can solve
|
5
11
|
// this by having a child node inside the array that gets the comments attached
|
@@ -7,11 +13,12 @@ const { concat, group, hardline, indent, join, line } = require("../prettier");
|
|
7
13
|
// print out the non-leading comments here.
|
8
14
|
function printEmptyCollection(path, opts, startToken, endToken) {
|
9
15
|
const node = path.getValue();
|
16
|
+
const containedWithinNode = containedWithin(node);
|
10
17
|
|
11
18
|
// If there are no comments or only leading comments, then we can just print
|
12
19
|
// out the start and end token and be done, as there are no comments inside
|
13
20
|
// the body of this node.
|
14
|
-
if (!node.comments || !node.comments.some(
|
21
|
+
if (!node.comments || !node.comments.some(containedWithinNode)) {
|
15
22
|
return `${startToken}${endToken}`;
|
16
23
|
}
|
17
24
|
|
@@ -21,7 +28,7 @@ function printEmptyCollection(path, opts, startToken, endToken) {
|
|
21
28
|
const printComment = (commentPath) => {
|
22
29
|
const comment = commentPath.getValue();
|
23
30
|
|
24
|
-
if (
|
31
|
+
if (containedWithinNode(comment)) {
|
25
32
|
comment.printed = true;
|
26
33
|
comments.push(opts.printer.printComment(commentPath));
|
27
34
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Deisz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- src/utils/getTrailingComma.js
|
98
98
|
- src/utils/hasAncestor.js
|
99
99
|
- src/utils/inlineEnsureParens.js
|
100
|
+
- src/utils/isEmptyBodyStmt.js
|
100
101
|
- src/utils/isEmptyStmts.js
|
101
102
|
- src/utils/literal.js
|
102
103
|
- src/utils/literalLineNoBreak.js
|
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.2.3
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: prettier plugin for the Ruby programming language
|