prettier 0.18.2 → 0.19.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 +9 -1
- data/package.json +3 -3
- data/src/nodes/args.js +1 -1
- data/src/nodes/calls.js +1 -1
- data/src/ruby.js +7 -0
- data/src/toProc.js +29 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 358b5350f0d237d510b4da937cf34a1aac4af594929f8b1799b2da05fce6a755
|
4
|
+
data.tar.gz: add73454d3a6e45214e568940551182313334ff4d43bf93196d1637b946e5866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5277fec090d225d2aff51abb198c3b61580f0304252a088bc574868dd2d122b666dabf627faadf50f9e8b066de3fd8593a149a61b9609e605acaae54f73e2de6
|
7
|
+
data.tar.gz: 4571eed09e3a0e492b8b1c7a8dd157ca45db4fb617e17dada815f29beb598c23cfe0008a21d1dff329c4e19c659b2fa8751a339901d59ec156b7c37d75c9afe1
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.19.0] - 2020-07-03
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- [@ryan-hunter-pc] - Add the option to disable the `Symbol#to_proc` transform.
|
14
|
+
- [@ryan-hunter-pc], [@SViccari], [@kddeisz] - Disable `Symbol#to_proc` transform when used as a key inside of a hash where the key is either `:if` or `:unless`.
|
15
|
+
|
9
16
|
## [0.18.2] - 2020-05-01
|
10
17
|
|
11
18
|
### Changed
|
@@ -803,7 +810,8 @@ would previously result in `array[]`, but now prints properly.
|
|
803
810
|
|
804
811
|
- Initial release 🎉
|
805
812
|
|
806
|
-
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v0.
|
813
|
+
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v0.19.0...HEAD
|
814
|
+
[0.19.0]: https://github.com/prettier/plugin-ruby/compare/v0.18.2...v0.19.0
|
807
815
|
[0.18.2]: https://github.com/prettier/plugin-ruby/compare/v0.18.1...v0.18.2
|
808
816
|
[0.18.1]: https://github.com/prettier/plugin-ruby/compare/v0.18.0...v0.18.1
|
809
817
|
[0.18.0]: https://github.com/prettier/plugin-ruby/compare/v0.17.0...v0.18.0
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prettier/plugin-ruby",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.0",
|
4
4
|
"description": "prettier plugin for the Ruby programming language",
|
5
5
|
"main": "src/ruby.js",
|
6
6
|
"scripts": {
|
@@ -23,10 +23,10 @@
|
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
25
|
"all-contributors-cli": "^6.14.1",
|
26
|
-
"eslint": "^
|
26
|
+
"eslint": "^7.1.0",
|
27
27
|
"eslint-config-prettier": "^6.10.1",
|
28
28
|
"husky": "^4.2.5",
|
29
|
-
"jest": "^
|
29
|
+
"jest": "^26.0.0",
|
30
30
|
"pretty-quick": "^2.0.1"
|
31
31
|
},
|
32
32
|
"eslintConfig": {
|
data/src/nodes/args.js
CHANGED
@@ -72,7 +72,7 @@ module.exports = {
|
|
72
72
|
return blockNode;
|
73
73
|
});
|
74
74
|
|
75
|
-
const proc = blockNode && toProc(blockNode);
|
75
|
+
const proc = blockNode && toProc(path, opts, blockNode);
|
76
76
|
|
77
77
|
// If we have a successful to_proc transformation, but we're part of an aref
|
78
78
|
// node, that means it's something to the effect of
|
data/src/nodes/calls.js
CHANGED
data/src/ruby.js
CHANGED
@@ -142,6 +142,13 @@ module.exports = {
|
|
142
142
|
default: true,
|
143
143
|
description:
|
144
144
|
"When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals."
|
145
|
+
},
|
146
|
+
toProcTransform: {
|
147
|
+
type: "boolean",
|
148
|
+
category: "Global",
|
149
|
+
default: true,
|
150
|
+
description:
|
151
|
+
"When possible, convert blocks to the more concise Symbol#to_proc syntax."
|
145
152
|
}
|
146
153
|
},
|
147
154
|
defaultOptions: {
|
data/src/toProc.js
CHANGED
@@ -11,8 +11,8 @@ const isCall = (node) => ["::", "."].includes(node) || node.type === "@period";
|
|
11
11
|
// [1, 2, 3].map(&:to_s)
|
12
12
|
//
|
13
13
|
// This works with `do` blocks as well.
|
14
|
-
const toProc = (node) => {
|
15
|
-
if (!node) {
|
14
|
+
const toProc = (path, opts, node) => {
|
15
|
+
if (!node || !opts.toProcTransform) {
|
16
16
|
return null;
|
17
17
|
}
|
18
18
|
|
@@ -76,6 +76,33 @@ const toProc = (node) => {
|
|
76
76
|
return null;
|
77
77
|
}
|
78
78
|
|
79
|
+
// Ensure that we're not inside of a hash that is being passed to a key that
|
80
|
+
// corresponds to `:if` or `:unless` to avoid problems with callbacks with
|
81
|
+
// Rails. For more context, see:
|
82
|
+
// https://github.com/prettier/plugin-ruby/issues/449
|
83
|
+
let assocNode = null;
|
84
|
+
|
85
|
+
if (path.getValue().type === "method_add_block") {
|
86
|
+
assocNode = path.getParentNode();
|
87
|
+
} else if (path.getValue().type === "args") {
|
88
|
+
assocNode = path.getParentNode(2);
|
89
|
+
}
|
90
|
+
|
91
|
+
if (assocNode && assocNode.type === "assoc_new") {
|
92
|
+
const [key] = assocNode.body;
|
93
|
+
|
94
|
+
if (key.type === "@label" && ["if:", "unless:"].includes(key.body)) {
|
95
|
+
return null;
|
96
|
+
}
|
97
|
+
|
98
|
+
if (
|
99
|
+
key.type === "symbol_literal" &&
|
100
|
+
["if", "unless"].includes(key.body[0].body[0].body)
|
101
|
+
) {
|
102
|
+
return null;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
79
106
|
return `&:${method.body}`;
|
80
107
|
};
|
81
108
|
|
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: 0.
|
4
|
+
version: 0.19.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: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|