prettier 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +13 -0
- data/package.json +1 -1
- data/rubocop.yml +26 -0
- data/src/prettier.js +1 -0
- data/src/ruby/embed.js +4 -0
- data/src/ruby/nodes/blocks.js +64 -59
- data/src/ruby/nodes/hooks.js +9 -19
- data/src/ruby/nodes/methods.js +4 -6
- data/src/ruby/nodes/params.js +22 -14
- data/src/ruby/nodes/patterns.js +9 -5
- data/src/ruby/nodes/return.js +0 -4
- data/src/ruby/nodes/statements.js +5 -8
- data/src/ruby/nodes/strings.js +26 -35
- data/src/ruby/parser.js +2 -1
- data/src/ruby/parser.rb +194 -193
- data/src/ruby/toProc.js +4 -8
- data/src/utils/makeCall.js +3 -0
- metadata +2 -1
data/src/ruby/toProc.js
CHANGED
@@ -12,15 +12,11 @@ const isCall = (node) => ["::", "."].includes(node) || node.type === "@period";
|
|
12
12
|
//
|
13
13
|
// This works with `do` blocks as well.
|
14
14
|
const toProc = (path, node) => {
|
15
|
-
if (!node) {
|
16
|
-
return null;
|
17
|
-
}
|
18
|
-
|
19
15
|
const [variables, blockContents] = node.body;
|
20
16
|
|
21
17
|
// Ensure that there are variables being passed to this block.
|
22
18
|
const params = variables && variables.body[0];
|
23
|
-
if (!params
|
19
|
+
if (!params) {
|
24
20
|
return null;
|
25
21
|
}
|
26
22
|
|
@@ -39,7 +35,7 @@ const toProc = (path, node) => {
|
|
39
35
|
if (blockContents.type === "bodystmt") {
|
40
36
|
// We’re in a `do` block
|
41
37
|
const blockStatements = blockContents.body[0];
|
42
|
-
const rescueElseEnsure =
|
38
|
+
const rescueElseEnsure = blockContents.body.slice(1);
|
43
39
|
|
44
40
|
// You can’t use the to_proc shortcut if you’re rescuing
|
45
41
|
if (rescueElseEnsure.some(Boolean)) {
|
@@ -84,7 +80,7 @@ const toProc = (path, node) => {
|
|
84
80
|
|
85
81
|
if (path.getValue().type === "method_add_block") {
|
86
82
|
assocNode = path.getParentNode();
|
87
|
-
} else
|
83
|
+
} else {
|
88
84
|
assocNode = path.getParentNode(2);
|
89
85
|
}
|
90
86
|
|
@@ -97,7 +93,7 @@ const toProc = (path, node) => {
|
|
97
93
|
|
98
94
|
if (
|
99
95
|
key.type === "symbol_literal" &&
|
100
|
-
["if", "unless"].includes(key.body[0].body
|
96
|
+
["if", "unless"].includes(key.body[0].body)
|
101
97
|
) {
|
102
98
|
return null;
|
103
99
|
}
|
data/src/utils/makeCall.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
function makeCall(path, opts, print) {
|
2
2
|
const operation = path.getValue().body[1];
|
3
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 */
|
4
7
|
if ([".", "&."].includes(operation)) {
|
5
8
|
return operation;
|
6
9
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Deisz
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- node_modules/prettier/index.js
|
31
31
|
- node_modules/prettier/third-party.js
|
32
32
|
- package.json
|
33
|
+
- rubocop.yml
|
33
34
|
- src/plugin.js
|
34
35
|
- src/prettier.js
|
35
36
|
- src/ruby/embed.js
|