prettier 2.0.0.pre.rc4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -10
- data/README.md +16 -16
- data/exe/rbprettier +2 -2
- data/lib/prettier/rake/task.rb +5 -5
- data/lib/prettier.rb +12 -11
- data/node_modules/prettier/bin-prettier.js +48 -18924
- data/node_modules/prettier/cli.js +12335 -0
- data/node_modules/prettier/doc.js +1306 -4755
- data/node_modules/prettier/index.js +37468 -57614
- data/node_modules/prettier/package.json +3 -2
- data/node_modules/prettier/parser-angular.js +2 -66
- data/node_modules/prettier/parser-babel.js +27 -22
- data/node_modules/prettier/parser-espree.js +26 -22
- data/node_modules/prettier/parser-flow.js +26 -22
- data/node_modules/prettier/parser-glimmer.js +27 -1
- data/node_modules/prettier/parser-graphql.js +15 -1
- data/node_modules/prettier/parser-html.js +21 -117
- data/node_modules/prettier/parser-markdown.js +61 -19
- data/node_modules/prettier/parser-meriyah.js +19 -22
- data/node_modules/prettier/parser-postcss.js +76 -22
- data/node_modules/prettier/parser-typescript.js +280 -22
- data/node_modules/prettier/parser-yaml.js +150 -15
- data/node_modules/prettier/third-party.js +8660 -11030
- data/package.json +10 -24
- data/rubocop.yml +14 -8
- data/src/getInfo.js +23 -0
- 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 -27
- metadata +97 -77
- 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 -143
- data/dist/haml/printer.js +0 -336
- data/dist/parser/getInfo.js +0 -17
- 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 -98
- data/dist/rbs/printer.js +0 -517
- data/dist/ruby/embed.js +0 -110
- data/dist/ruby/nodes/alias.js +0 -59
- data/dist/ruby/nodes/aref.js +0 -53
- data/dist/ruby/nodes/args.js +0 -165
- data/dist/ruby/nodes/arrays.js +0 -126
- data/dist/ruby/nodes/assign.js +0 -41
- data/dist/ruby/nodes/blocks.js +0 -87
- data/dist/ruby/nodes/calls.js +0 -260
- data/dist/ruby/nodes/case.js +0 -50
- data/dist/ruby/nodes/class.js +0 -54
- data/dist/ruby/nodes/commands.js +0 -124
- data/dist/ruby/nodes/conditionals.js +0 -242
- data/dist/ruby/nodes/constants.js +0 -38
- data/dist/ruby/nodes/flow.js +0 -66
- data/dist/ruby/nodes/hashes.js +0 -130
- 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 -69
- data/dist/ruby/nodes/loops.js +0 -73
- data/dist/ruby/nodes/massign.js +0 -73
- data/dist/ruby/nodes/methods.js +0 -70
- data/dist/ruby/nodes/operators.js +0 -70
- data/dist/ruby/nodes/params.js +0 -89
- data/dist/ruby/nodes/patterns.js +0 -109
- data/dist/ruby/nodes/regexp.js +0 -45
- data/dist/ruby/nodes/rescue.js +0 -85
- data/dist/ruby/nodes/return.js +0 -75
- data/dist/ruby/nodes/statements.js +0 -111
- data/dist/ruby/nodes/strings.js +0 -218
- data/dist/ruby/nodes/super.js +0 -30
- data/dist/ruby/nodes/undef.js +0 -26
- data/dist/ruby/nodes.js +0 -151
- data/dist/ruby/parser.js +0 -34
- data/dist/ruby/parser.rb +0 -3636
- data/dist/ruby/printer.js +0 -129
- data/dist/ruby/toProc.js +0 -93
- 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 -30
- data/dist/utils/containsAssignment.js +0 -15
- 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/isEmptyStmts.js +0 -10
- data/dist/utils/literal.js +0 -8
- data/dist/utils/literallineWithoutBreakParent.js +0 -8
- data/dist/utils/makeCall.js +0 -13
- data/dist/utils/noIndent.js +0 -11
- data/dist/utils/printEmptyCollection.js +0 -44
- data/dist/utils/skipAssignIndent.js +0 -15
- data/dist/utils.js +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edc974795ef0adb86312682bdedfa30cca29905f660b97334326494b8623144f
|
4
|
+
data.tar.gz: 9dcdc7ecb78e7ee4fa333b45e9f2e4b5ea5df4615869ce6b172377bf21126560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0166367d99fc0af3135d76c47dae06bcddd92eaf9a7d3d680726d403a2eed16f08af8fe410c527113bf00d1a0fe11b4c6743820e4c907b2de2707884655ef3
|
7
|
+
data.tar.gz: c8fa9abb2ecf3561c913f9505f7d07c56e322c6f3031d44b9725c314bfb1576c0dc68c7c7e28f8a15f9d876c4307c0c90549e1db83a4c94b184e0a872413208d
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,52 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
## [
|
9
|
+
## [3.0.0] - 2022-05-04
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Encoding for source files is now guessed in a much better way.
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- [#1198](https://github.com/prettier/plugin-ruby/issues/1198) - pas-f, kddnewton - Fix crashes on JRuby with do blocks.
|
18
|
+
- [#1131](https://github.com/prettier/plugin-ruby/issues/1131) - hyrious, kddnewton - Ensure zombie processes are not left around when the server exits.
|
19
|
+
- [#1206](https://github.com/prettier/plugin-ruby/pull/1206) - kddnewton - Switch back to plain JavaScript for development.
|
20
|
+
- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Switch over to using Syntax Tree for the backend.
|
21
|
+
|
22
|
+
### Removed
|
23
|
+
|
24
|
+
- [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - The configuration options have been removed. Instead, configuration is to be done through modifying Syntax Tree.
|
25
|
+
|
26
|
+
## [2.1.0] - 2022-04-04
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- [#1065](https://github.com/prettier/plugin-ruby/issues/1065) - langalex, kddnewton - The ability to set the `PRETTIER_RUBY_TIMEOUT_MS` environment variable to control how long to wait for the parser server to spin up.
|
31
|
+
- [#1173](https://github.com/prettier/plugin-ruby/pull/1173) - dleavitt - Support for RBS 2.x on Ruby 3.1.
|
32
|
+
|
33
|
+
### Changed
|
34
|
+
|
35
|
+
- [#1028](https://github.com/prettier/plugin-ruby/issues/1028) - levymetal, kddnewton - Fix up some nested formatting with very complicated RSpec assertions.
|
36
|
+
- [#1035](https://github.com/prettier/plugin-ruby/issues/1035) - qcn, kddnewton - Ensure we don't try to print `return` incorrectly when multiple statements are contained within parentheses.
|
37
|
+
- [#1048](https://github.com/prettier/plugin-ruby/pull/1048) - kddnewton - Completely refactor the Ruby parser to use classes instead of hashes. Also remove a lot of the `body` keys are replace them with actual names.
|
38
|
+
- [#1042](https://github.com/prettier/plugin-ruby/issues/1042) - JoshuaKGoldberg, kddnewton - Ensure blocks are printed correctly when there are trailing comments on the `do` keyword.
|
39
|
+
- [#1134](https://github.com/prettier/plugin-ruby/pull/1134) - mhssmnn - Fix piping for STDIN to the gem process.
|
40
|
+
- [#1167](https://github.com/prettier/plugin-ruby/pull/1167) - dleavitt - More consistent assignment indentation.
|
41
|
+
- [#1074](https://github.com/prettier/plugin-ruby/issues/1074) - wagenet, kddnewton - Fix up `return` when nodes return arrays of docs.
|
42
|
+
|
43
|
+
### Removed
|
44
|
+
|
45
|
+
- [#1048](https://github.com/prettier/plugin-ruby/pull/1048) - kddnewton - Drop support for Ruby 2.5.
|
46
|
+
|
47
|
+
## [2.0.0] - 2021-10-28
|
48
|
+
|
49
|
+
### Changed
|
50
|
+
|
51
|
+
- [#1018](https://github.com/prettier/plugin-ruby/issues/1018) - rindek, kddnewton - Ensure brackets are used when matching an array pattern with a single element.
|
52
|
+
- [#906](https://github.com/prettier/plugin-ruby/issues/906) - Hansenq, kddnewton - Turn off the `Style/MultilineBlockChain` rubocop rule in our shipped configuration because multiple chained method calls with blocks can potentially conflict with rubocop's desired output.
|
53
|
+
|
54
|
+
## [2.0.0-rc4] - 2021-10-18
|
10
55
|
|
11
56
|
### Added
|
12
57
|
|
@@ -17,14 +62,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
17
62
|
|
18
63
|
- [#1000](https://github.com/prettier/plugin-ruby/pull/1000) - nbudin, kddnewton - Fix for rescuing single top-level exceptions in `rescue` clauses.
|
19
64
|
|
20
|
-
## [2.0.0-rc3]
|
65
|
+
## [2.0.0-rc3] - 2021-10-01
|
21
66
|
|
22
67
|
### Changed
|
23
68
|
|
24
69
|
- [#987](https://github.com/prettier/plugin-ruby/pull/9870) - valscion - Ignore stderr when checking for node <-> ruby connection clients, restoring the behavior of v1.x
|
25
70
|
- [#989](https://github.com/prettier/plugin-ruby/issues/989) - hubertjakubiak, kddnewton - Make sure comments after the keyword/lbrace are not moved inside the body of the statements of do and brace blocks.
|
26
71
|
|
27
|
-
## [2.0.0-rc2]
|
72
|
+
## [2.0.0-rc2] - 2021-09-30
|
28
73
|
|
29
74
|
### Added
|
30
75
|
|
@@ -35,7 +80,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
35
80
|
|
36
81
|
- [#943](https://github.com/prettier/plugin-ruby/issues/943) - valscion, kddnewton - Trailing call operators that are followed by comments should stay on the first line.
|
37
82
|
|
38
|
-
## [2.0.0-rc1]
|
83
|
+
## [2.0.0-rc1] - 2021-09-30
|
39
84
|
|
40
85
|
### Added
|
41
86
|
|
@@ -288,7 +333,6 @@ The comment in the above example should stay in place.
|
|
288
333
|
|
289
334
|
```ruby
|
290
335
|
begin
|
291
|
-
|
292
336
|
rescue Foo, Bar
|
293
337
|
# comment
|
294
338
|
end
|
@@ -444,7 +488,8 @@ return (a or b) if c?
|
|
444
488
|
- kddnewton - Support for the `nokw_param` node for specifying when methods should no accept keywords, as in:
|
445
489
|
|
446
490
|
```ruby
|
447
|
-
def foo(**nil)
|
491
|
+
def foo(**nil)
|
492
|
+
end
|
448
493
|
```
|
449
494
|
|
450
495
|
- kddnewton - Support for the `args_forward` node for forwarding all types of arguments, as in:
|
@@ -490,9 +535,9 @@ will now be printed as:
|
|
490
535
|
|
491
536
|
```ruby
|
492
537
|
Config::Download.new(
|
493
|
-
|
494
|
-
filename:
|
495
|
-
url:
|
538
|
+
"prettier",
|
539
|
+
filename: "prettier.yml",
|
540
|
+
url: "https://raw.githubusercontent.com/..."
|
496
541
|
).perform
|
497
542
|
```
|
498
543
|
|
@@ -1180,7 +1225,10 @@ would previously result in `array[]`, but now prints properly.
|
|
1180
1225
|
|
1181
1226
|
- Initial release 🎉
|
1182
1227
|
|
1183
|
-
[unreleased]: https://github.com/prettier/plugin-ruby/compare/
|
1228
|
+
[unreleased]: https://github.com/prettier/plugin-ruby/compare/v3.0.0...HEAD
|
1229
|
+
[3.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.1.0...v3.0.0
|
1230
|
+
[2.1.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0...v2.1.0
|
1231
|
+
[2.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc4...v2.0.0
|
1184
1232
|
[2.0.0-rc4]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc3...v2.0.0-rc4
|
1185
1233
|
[2.0.0-rc3]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc2...v2.0.0-rc3
|
1186
1234
|
[2.0.0-rc2]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc1...v2.0.0-rc2
|
data/README.md
CHANGED
@@ -59,9 +59,9 @@ d = [
|
|
59
59
|
30_643_069_058
|
60
60
|
]
|
61
61
|
a, s = [], $*[0]
|
62
|
-
s.each_byte { |b| a << (
|
62
|
+
s.each_byte { |b| a << ("%036b" % d[b.chr.to_i]).scan(/\d{6}/) }
|
63
63
|
a.transpose.each do |a|
|
64
|
-
a.join.each_byte { |i| print i == 49 ? ($*[1] ||
|
64
|
+
a.join.each_byte { |i| print i == 49 ? ($*[1] || "#") : 32.chr }
|
65
65
|
puts
|
66
66
|
end
|
67
67
|
```
|
@@ -83,7 +83,7 @@ This plugin currently supports formatting the following kinds of files:
|
|
83
83
|
Add this line to your application's Gemfile:
|
84
84
|
|
85
85
|
```ruby
|
86
|
-
gem
|
86
|
+
gem "prettier"
|
87
87
|
```
|
88
88
|
|
89
89
|
And then execute:
|
@@ -118,6 +118,12 @@ Or if you're using `yarn`, then add the plugin by:
|
|
118
118
|
yarn add --dev prettier @prettier/plugin-ruby
|
119
119
|
```
|
120
120
|
|
121
|
+
You'll also need to add the necessary Ruby dependencies. You can do this by running:
|
122
|
+
|
123
|
+
```bash
|
124
|
+
gem install syntax_tree syntax_tree-haml syntax_tree-rbs
|
125
|
+
```
|
126
|
+
|
121
127
|
The `prettier` executable is now installed and ready for use:
|
122
128
|
|
123
129
|
```bash
|
@@ -128,31 +134,25 @@ The `prettier` executable is now installed and ready for use:
|
|
128
134
|
|
129
135
|
Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:
|
130
136
|
|
131
|
-
| API Option
|
132
|
-
|
|
133
|
-
| `printWidth`
|
134
|
-
| `requirePragma`
|
135
|
-
| `
|
136
|
-
| `rubyHashLabel` | `--ruby-hash-label` | `true` | When possible, uses the shortened hash key syntax, as opposed to hash rockets. |
|
137
|
-
| `rubyModifier` | `--ruby-modifier` | `true` | When it fits on one line, allows while and until statements to use the modifier form. |
|
138
|
-
| `rubySingleQuote` | `--ruby-single-quote` | `true` | When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals. |
|
139
|
-
| `rubyToProc` | `--ruby-to-proc` | `false` | When possible, convert blocks to the more concise `Symbol#to_proc` syntax. |
|
140
|
-
| `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
|
141
|
-
| `trailingComma` | `--trailing-comma` | `"none"` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-comma)). `"es5"` is equivalent to `true`. |
|
137
|
+
| API Option | CLI Option | Default | Description |
|
138
|
+
| --------------- | ------------------ | :-----: | --------------------------------------------------------------------------------------------------- |
|
139
|
+
| `printWidth` | `--print-width` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)). |
|
140
|
+
| `requirePragma` | `--require-pragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)). |
|
141
|
+
| `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
|
142
142
|
|
143
143
|
Any of these can be added to your existing [prettier configuration
|
144
144
|
file](https://prettier.io/docs/en/configuration.html). For example:
|
145
145
|
|
146
146
|
```json
|
147
147
|
{
|
148
|
-
"
|
148
|
+
"tabWidth": 4
|
149
149
|
}
|
150
150
|
```
|
151
151
|
|
152
152
|
Or, they can be passed to `prettier` as arguments:
|
153
153
|
|
154
154
|
```bash
|
155
|
-
bundle exec rbprettier --
|
155
|
+
bundle exec rbprettier --tab-width 4 --write '**/*'
|
156
156
|
```
|
157
157
|
|
158
158
|
### Usage with RuboCop
|
data/exe/rbprettier
CHANGED
data/lib/prettier/rake/task.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "rake"
|
4
|
+
require "rake/tasklib"
|
5
5
|
|
6
6
|
module Prettier
|
7
7
|
module Rake
|
@@ -35,7 +35,7 @@ module Prettier
|
|
35
35
|
def initialize(name = :prettier)
|
36
36
|
@name = name
|
37
37
|
@write = true
|
38
|
-
@source_files =
|
38
|
+
@source_files = "lib/**/*.rb"
|
39
39
|
|
40
40
|
yield self if block_given?
|
41
41
|
define_task
|
@@ -44,12 +44,12 @@ module Prettier
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def define_task
|
47
|
-
desc
|
47
|
+
desc "Runs prettier over source files"
|
48
48
|
task(name) { run_task }
|
49
49
|
end
|
50
50
|
|
51
51
|
def run_task
|
52
|
-
Prettier.run([(
|
52
|
+
Prettier.run([("--write" if write), source_files].compact)
|
53
53
|
exit($?.exitstatus) if $?&.exited?
|
54
54
|
end
|
55
55
|
end
|
data/lib/prettier.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "json" unless defined?(JSON)
|
4
|
+
require "open3"
|
5
5
|
|
6
6
|
module Prettier
|
7
|
-
PLUGIN = -File.expand_path(
|
8
|
-
BINARY = -File.join(PLUGIN,
|
9
|
-
VERSION = -JSON.parse(File.read(File.join(PLUGIN,
|
7
|
+
PLUGIN = -File.expand_path("..", __dir__)
|
8
|
+
BINARY = -File.join(PLUGIN, "node_modules", "prettier", "bin-prettier.js")
|
9
|
+
VERSION = -JSON.parse(File.read(File.join(PLUGIN, "package.json")))["version"]
|
10
10
|
|
11
11
|
def self.run(args)
|
12
|
-
quoted = args.map { |arg| arg.start_with?(
|
13
|
-
command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(
|
12
|
+
quoted = args.map { |arg| arg.start_with?("-") ? arg : "\"#{arg}\"" }
|
13
|
+
command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(" ")}"
|
14
14
|
|
15
|
-
stdout, stderr, status =
|
15
|
+
stdout, stderr, status =
|
16
|
+
Open3.capture3({ "RBPRETTIER" => "1" }, command, stdin_data: STDIN)
|
16
17
|
STDOUT.puts(stdout)
|
17
18
|
|
18
19
|
# If we completed successfully, then just exit out.
|
@@ -29,11 +30,11 @@ module Prettier
|
|
29
30
|
If you installed this dependency through git instead of from rubygems,
|
30
31
|
it does not install the necessary files by default. To fix this you can
|
31
32
|
either install them yourself by cd-ing into the directory where this gem
|
32
|
-
is located (#{File.expand_path(
|
33
|
+
is located (#{File.expand_path("..", __dir__)}) and running:
|
33
34
|
|
34
|
-
`yarn
|
35
|
+
`yarn install`
|
35
36
|
or
|
36
|
-
`npm install
|
37
|
+
`npm install`
|
37
38
|
or
|
38
39
|
you can change the source in your Gemfile to point directly to rubygems.
|
39
40
|
MSG
|