prettier 3.1.1 → 3.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 967c98f2226d3ae025e0fe136f8cddd80115480baaa375a4906a8b7729cf5549
4
- data.tar.gz: 31c55db39cdeb5e423ddd89d5000217d7dd226ada3a854e6a36b5ddf0274b807
3
+ metadata.gz: 69429c1f7b0cc5b82babb8463afcdacbb30026b0c9a77afcf8f6c4dbddd5b545
4
+ data.tar.gz: f81d934981c3086071371a9013184fbb19543dd7a86ca4258addd5870defbe73
5
5
  SHA512:
6
- metadata.gz: 4411eeaefa1cc33f118a6f4660801cd1da8341f1954e8993a9b5e20f5c3a148b220899bde756fa359080f393b567d5312cb0774571b9ec859af0d1cba1a9e2da
7
- data.tar.gz: fda90238c9d58046c394ba09b11671ba0d617efff319a21077638ac86ed18f2cd2bfbf81192e92f0b0c62fd48987290276ca114202fcd5e00136512622d6ffe3
6
+ metadata.gz: e6e612eb427b6c244c365b4595d1cefb0987e43255a541accd4843cadd4c73c0c5dd96268cf6ed8444afe2c2008e4792e3ad3155474d6ec20ffb880f65c23fb7
7
+ data.tar.gz: f825fb2f339e52c9c9dae9b287b5f21436fadaaea29ed0e93b14ee0ebb97bfaaac9aa1e16eaa2549b4a66e513c1007a3f48e1aa587efe6032568f77afd85d77f
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.1.2] - 2022-05-13
10
+
11
+ ### Changed
12
+
13
+ - [#1127](https://github.com/prettier/plugin-ruby/issues/1227) - mscrivo, kddnewton - Support passing the `printWidth` option.
14
+
9
15
  ## [3.1.1] - 2022-05-12
10
16
 
11
17
  ### Changed
@@ -1237,7 +1243,10 @@ would previously result in `array[]`, but now prints properly.
1237
1243
 
1238
1244
  - Initial release 🎉
1239
1245
 
1240
- [unreleased]: https://github.com/prettier/plugin-ruby/compare/v3.0.0...HEAD
1246
+ [unreleased]: https://github.com/prettier/plugin-ruby/compare/v3.1.2...HEAD
1247
+ [3.1.2]: https://github.com/prettier/plugin-ruby/compare/v3.1.1...v3.1.2
1248
+ [3.1.1]: https://github.com/prettier/plugin-ruby/compare/v3.1.0...v3.1.1
1249
+ [3.1.0]: https://github.com/prettier/plugin-ruby/compare/v3.0.0...v3.1.0
1241
1250
  [3.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.1.0...v3.0.0
1242
1251
  [2.1.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0...v2.1.0
1243
1252
  [2.0.0]: https://github.com/prettier/plugin-ruby/compare/v2.0.0-rc4...v2.0.0
data/README.md CHANGED
@@ -68,7 +68,7 @@ end
68
68
 
69
69
  ## Getting started
70
70
 
71
- To run `prettier` with the Ruby plugin, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.5` or newer) and [`node`](https://nodejs.org/en/download/) (version `8.3` or newer). If you're integrating with a project that is not already using `prettier`, you should use the Ruby gem. Otherwise you can use the `npm` package directly.
71
+ To run `prettier` with the Ruby plugin, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.7.3` or newer) and [`node`](https://nodejs.org/en/download/) (version `8.3` or newer). If you're integrating with a project that is not already using `prettier`, you should use the Ruby gem. Otherwise you can use the `npm` package directly.
72
72
 
73
73
  Note that currently the editor integrations work best with the `npm` package, as most of the major editor plugins expect a `node_modules` directory. You can get them to work with the Ruby gem, but it requires manually configuring the paths.
74
74
 
@@ -121,7 +121,7 @@ yarn add --dev prettier @prettier/plugin-ruby
121
121
  You'll also need to add the necessary Ruby dependencies. You can do this by running:
122
122
 
123
123
  ```bash
124
- gem install bundler syntax_tree syntax_tree-haml syntax_tree-rbs
124
+ gem install bundler prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs
125
125
  ```
126
126
 
127
127
  The `prettier` executable is now installed and ready for use:
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prettier/plugin-ruby",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "prettier plugin for the Ruby programming language",
5
5
  "main": "src/plugin.js",
6
6
  "scripts": {
data/src/parseSync.js CHANGED
@@ -181,7 +181,7 @@ function parseSync(parser, source, opts) {
181
181
  }
182
182
 
183
183
  const response = spawnSync(parserArgs.cmd, parserArgs.args, {
184
- input: `${parser}|${source}`,
184
+ input: `${parser}|${opts.printWidth}|${source}`,
185
185
  maxBuffer: 15 * 1024 * 1024
186
186
  });
187
187
 
data/src/server.rb CHANGED
@@ -6,6 +6,7 @@ require "json"
6
6
  require "fileutils"
7
7
  require "open3"
8
8
 
9
+ require "prettier_print"
9
10
  require "syntax_tree"
10
11
  require "syntax_tree/haml"
11
12
  require "syntax_tree/rbs"
@@ -73,7 +74,8 @@ listener =
73
74
 
74
75
  # Start up a new thread that will handle each successive connection.
75
76
  Thread.new(server.accept_nonblock) do |socket|
76
- parser, source = socket.read.force_encoding("UTF-8").split("|", 2)
77
+ parser, width, source =
78
+ socket.read.force_encoding("UTF-8").split("|", 3)
77
79
 
78
80
  source.each_line do |line|
79
81
  case line
@@ -90,16 +92,25 @@ listener =
90
92
  end
91
93
  end
92
94
 
95
+ maxwidth = width.to_i
93
96
  response =
94
97
  case parser
95
98
  when "ping"
96
99
  "pong"
97
100
  when "ruby"
98
- SyntaxTree.format(source)
101
+ formatter = SyntaxTree::Formatter.new(source, [], maxwidth)
102
+ SyntaxTree.parse(source).format(formatter)
103
+ formatter.flush
104
+ formatter.output.join
99
105
  when "rbs"
100
- SyntaxTree::RBS.format(source)
106
+ formatter = SyntaxTree::RBS::Formatter.new(source, [], maxwidth)
107
+ SyntaxTree::RBS.parse(source).format(formatter)
108
+ formatter.flush
109
+ formatter.output.join
101
110
  when "haml"
102
- SyntaxTree::Haml.format(source)
111
+ PrettierPrint.format(+"", maxwidth) do |q|
112
+ SyntaxTree::Haml.parse(source).format(q)
113
+ end
103
114
  end
104
115
 
105
116
  if response
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: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syntax_tree