prettier 3.2.1 → 4.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -2
  3. data/README.md +23 -59
  4. data/lib/prettier.rb +7 -5
  5. data/node_modules/prettier/LICENSE +5205 -0
  6. data/node_modules/prettier/README.md +109 -0
  7. data/node_modules/prettier/{bin-prettier.js → bin/prettier.cjs} +10 -5
  8. data/node_modules/prettier/doc.d.ts +240 -0
  9. data/node_modules/prettier/doc.js +1257 -1309
  10. data/node_modules/prettier/doc.mjs +1312 -0
  11. data/node_modules/prettier/index.cjs +655 -0
  12. data/node_modules/prettier/index.d.ts +915 -0
  13. data/node_modules/prettier/index.mjs +21845 -0
  14. data/node_modules/prettier/internal/cli.mjs +6978 -0
  15. data/node_modules/prettier/internal/internal.mjs +6531 -0
  16. data/node_modules/prettier/package.json +179 -6
  17. data/node_modules/prettier/plugins/acorn.d.ts +6 -0
  18. data/node_modules/prettier/plugins/acorn.js +13 -0
  19. data/node_modules/prettier/plugins/acorn.mjs +13 -0
  20. data/node_modules/prettier/plugins/angular.d.ts +8 -0
  21. data/node_modules/prettier/plugins/angular.js +2 -0
  22. data/node_modules/prettier/plugins/angular.mjs +2 -0
  23. data/node_modules/prettier/plugins/babel.d.ts +17 -0
  24. data/node_modules/prettier/plugins/babel.js +16 -0
  25. data/node_modules/prettier/plugins/babel.mjs +16 -0
  26. data/node_modules/prettier/plugins/estree.d.ts +0 -0
  27. data/node_modules/prettier/plugins/estree.js +35 -0
  28. data/node_modules/prettier/plugins/estree.mjs +35 -0
  29. data/node_modules/prettier/plugins/flow.d.ts +5 -0
  30. data/node_modules/prettier/plugins/flow.js +21 -0
  31. data/node_modules/prettier/plugins/flow.mjs +21 -0
  32. data/node_modules/prettier/plugins/glimmer.d.ts +5 -0
  33. data/node_modules/prettier/plugins/glimmer.js +30 -0
  34. data/node_modules/prettier/plugins/glimmer.mjs +30 -0
  35. data/node_modules/prettier/plugins/graphql.d.ts +5 -0
  36. data/node_modules/prettier/plugins/graphql.js +29 -0
  37. data/node_modules/prettier/plugins/graphql.mjs +29 -0
  38. data/node_modules/prettier/plugins/html.d.ts +8 -0
  39. data/node_modules/prettier/plugins/html.js +19 -0
  40. data/node_modules/prettier/plugins/html.mjs +19 -0
  41. data/node_modules/prettier/plugins/markdown.d.ts +7 -0
  42. data/node_modules/prettier/plugins/markdown.js +59 -0
  43. data/node_modules/prettier/plugins/markdown.mjs +59 -0
  44. data/node_modules/prettier/plugins/meriyah.d.ts +5 -0
  45. data/node_modules/prettier/plugins/meriyah.js +5 -0
  46. data/node_modules/prettier/plugins/meriyah.mjs +5 -0
  47. data/node_modules/prettier/plugins/postcss.d.ts +7 -0
  48. data/node_modules/prettier/plugins/postcss.js +52 -0
  49. data/node_modules/prettier/plugins/postcss.mjs +52 -0
  50. data/node_modules/prettier/plugins/typescript.d.ts +5 -0
  51. data/node_modules/prettier/plugins/typescript.js +27 -0
  52. data/node_modules/prettier/plugins/typescript.mjs +27 -0
  53. data/node_modules/prettier/plugins/yaml.d.ts +5 -0
  54. data/node_modules/prettier/plugins/yaml.js +161 -0
  55. data/node_modules/prettier/plugins/yaml.mjs +161 -0
  56. data/node_modules/prettier/standalone.d.ts +33 -0
  57. data/node_modules/prettier/standalone.js +34 -0
  58. data/node_modules/prettier/standalone.mjs +34 -0
  59. data/package.json +15 -10
  60. data/src/plugin.js +210 -14
  61. data/src/server.rb +50 -85
  62. metadata +60 -28
  63. data/CONTRIBUTING.md +0 -185
  64. data/node_modules/prettier/cli.js +0 -15085
  65. data/node_modules/prettier/index.js +0 -37282
  66. data/node_modules/prettier/parser-angular.js +0 -2
  67. data/node_modules/prettier/parser-babel.js +0 -27
  68. data/node_modules/prettier/parser-espree.js +0 -26
  69. data/node_modules/prettier/parser-flow.js +0 -35
  70. data/node_modules/prettier/parser-glimmer.js +0 -27
  71. data/node_modules/prettier/parser-graphql.js +0 -15
  72. data/node_modules/prettier/parser-html.js +0 -36
  73. data/node_modules/prettier/parser-markdown.js +0 -76
  74. data/node_modules/prettier/parser-meriyah.js +0 -19
  75. data/node_modules/prettier/parser-postcss.js +0 -76
  76. data/node_modules/prettier/parser-typescript.js +0 -280
  77. data/node_modules/prettier/parser-yaml.js +0 -150
  78. data/node_modules/prettier/third-party.js +0 -8978
  79. data/src/getInfo.js +0 -23
  80. data/src/netcat.js +0 -13
  81. data/src/parseSync.js +0 -227
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32366c0f21ecd68aa457ffa258101c877877a7154f3603eb2f26c7d51865937f
4
- data.tar.gz: 06f87e22a36daf12111981b031a63d120c50ec24c30be2056f73b96d2b4a4e96
3
+ metadata.gz: f48ed0363e8410a6e7fb2c3c8bc95ed8a87f8fac28546429571b71bdd3225e19
4
+ data.tar.gz: b7a8dd5700deda01c743c926890eb977660445a06ca057540ab347b27126ff4b
5
5
  SHA512:
6
- metadata.gz: ccede4bd64194b7ca7de7b08e9957b78635813cacdad577b1a2c9e0041cde2281ef6175175d3c100086fe2895394437828cb52e79ac9ca534c32c486ca400935
7
- data.tar.gz: 5b54c65167a99225f69569e3537e7a74d800ef675bc9b2a5c2eca69f126d937ba7c80b1909c7dfc68c1027d6537db765496810aa8b594b1686cb2409a34ad7d8
6
+ metadata.gz: 81880c36ea2a6493552c0af368c61e7cc1f587af9ddfde72e9cdbe484a3cd855c30d1cad7ddfdb629e15f2c54998d822fbab75b35f31ce33fb555b14f9f1255b
7
+ data.tar.gz: 21213157b04d8f7e801fd9e0e90ee8351f723223caa8672bd2e00e152a1e2111bb85f6caa35400fb7fa6d3e19b75a36b1c176fb6ebf02f567796ad4ea0472930
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [4.0.0] - 2023-07-06
10
+
11
+ ### Added
12
+
13
+ - [#1283](https://github.com/prettier/plugin-ruby/pull/1283) - oriolgual - Use `process.execPath` instead of `"node"`.
14
+ - [#1358](https://github.com/prettier/plugin-ruby/pull/1358) - davidalejandroaguilar - Add the `rubyExecutablePath` option.
15
+ - [#1359](https://github.com/prettier/plugin-ruby/pull/1359) - kddnewton - Inherit stderr from the parser process in order to provide better error messages when failing to spawn parser server. This will put out missing gem errors, for example.
16
+
17
+ ### Changed
18
+
19
+ - [#1360](https://github.com/prettier/plugin-ruby/pull/1360) - kddnewton - Require prettier v3.0.0+.
20
+
21
+ ## [3.2.2] - 2022-09-20
22
+
23
+ ### Changed
24
+
25
+ - [#1276](https://github.com/prettier/plugin-ruby/pull/1276) - kddnewton - Fix the parsing for options being passed to the server process.
26
+
9
27
  ## [3.2.1] - 2022-09-19
10
28
 
11
29
  ### Changed
@@ -53,7 +71,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
53
71
  - [#1198](https://github.com/prettier/plugin-ruby/issues/1198) - pas-f, kddnewton - Fix crashes on JRuby with do blocks.
54
72
  - [#1131](https://github.com/prettier/plugin-ruby/issues/1131) - hyrious, kddnewton - Ensure zombie processes are not left around when the server exits.
55
73
  - [#1206](https://github.com/prettier/plugin-ruby/pull/1206) - kddnewton - Switch back to plain JavaScript for development.
56
- - [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Switch over to using Syntax Tree for the backend.
74
+ - [#1190](https://github.com/prettier/plugin-ruby/pull/1190) - kddnewton - Switch over to using Syntax Tree for the backend. This now requires that users install the necessary gems.
57
75
 
58
76
  ### Removed
59
77
 
@@ -1261,7 +1279,9 @@ would previously result in `array[]`, but now prints properly.
1261
1279
 
1262
1280
  - Initial release 🎉
1263
1281
 
1264
- [unreleased]: https://github.com/prettier/plugin-ruby/compare/v3.2.1...HEAD
1282
+ [unreleased]: https://github.com/prettier/plugin-ruby/compare/v4.0.0...HEAD
1283
+ [4.0.0]: https://github.com/prettier/plugin-ruby/compare/v3.2.2...v4.0.0
1284
+ [3.2.2]: https://github.com/prettier/plugin-ruby/compare/v3.2.1...v3.2.2
1265
1285
  [3.2.1]: https://github.com/prettier/plugin-ruby/compare/v3.2.0...v3.2.1
1266
1286
  [3.2.0]: https://github.com/prettier/plugin-ruby/compare/v3.1.2...v3.2.0
1267
1287
  [3.1.2]: https://github.com/prettier/plugin-ruby/compare/v3.1.1...v3.1.2
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  <img alt="Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
10
10
  </a>
11
11
  <a href="https://github.com/prettier/plugin-ruby/actions">
12
- <img alt="GitHub Actions" src="https://img.shields.io/github/workflow/status/prettier/plugin-ruby/Main?style=flat-square">
12
+ <img alt="GitHub Actions" src="https://img.shields.io/github/actions/workflow/status/prettier/plugin-ruby/main.yml?branch=main&style=flat-square">
13
13
  </a>
14
14
  <a href="https://www.npmjs.com/package/@prettier/plugin-ruby">
15
15
  <img alt="NPM Version" src="https://img.shields.io/npm/v/@prettier/plugin-ruby.svg?style=flat-square">
@@ -68,43 +68,13 @@ 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.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.
71
+ The `@prettier/plugin-ruby` plugin for `prettier` is a small wrapper around the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem that provides a Ruby formatter for `prettier`. It does this by keeping a Ruby server running in that background that `prettier` can communicate with when it needs to format a Ruby file. This means that in order to function, you will need to have both the requisite `node` and `ruby` dependencies installed. Because of this configuration, there are a couple of ways that you can get setup to use this plugin.
72
72
 
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.
73
+ - If you're already using `prettier` in your project to format other files in your project and want to install this as a plugin, you can install it using `npm`.
74
+ - If you're not using `prettier` yet in your project, then we recommend using the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem directly instead of using this plugin.
75
+ - Note that this plugin also ships a gem named `prettier` which is a wrapper around the `prettier` CLI and includes this plugin by default, but _we no longer recommend its use_. If you're using that gem, you should migrate to using [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) instead.
74
76
 
75
- This plugin currently supports formatting the following kinds of files:
76
-
77
- - All varieties of Ruby source files (e.g., `*.rb`, `*.gemspec`, `Gemfile`, etc.)
78
- - [RBS type language](https://github.com/ruby/rbs) files - requires having the `rbs` gem in your gem path
79
- - [HAML template language](https://haml.info/) files - requires having the `haml` gem in your gem path
80
-
81
- ### Ruby gem
82
-
83
- Add this line to your application's Gemfile:
84
-
85
- ```ruby
86
- gem "prettier"
87
- ```
88
-
89
- And then execute:
90
-
91
- ```bash
92
- bundle
93
- ```
94
-
95
- Or install it yourself as:
96
-
97
- ```bash
98
- gem install prettier
99
- ```
100
-
101
- The `rbprettier` executable is now installed and ready for use:
102
-
103
- ```bash
104
- bundle exec rbprettier --write '**/*'
105
- ```
106
-
107
- ### `npm` package
77
+ To run `prettier` with the Ruby plugin as an `npm` package, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.7` or newer) and [`node`](https://nodejs.org/en/download/) (version `16` or newer).
108
78
 
109
79
  If you're using the `npm` CLI, then add the plugin by:
110
80
 
@@ -134,14 +104,15 @@ The `prettier` executable is now installed and ready for use:
134
104
 
135
105
  Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:
136
106
 
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
- | `rubyPlugins` | `--ruby-plugins` | `""` | The comma-separated list of plugins to require. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). |
142
- | `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
143
- | `singleQuote` | `--single-quote` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#quotes)). |
144
- | `trailingComma` | `--trailing-comma` | `es5` | Almost same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-commas)). Will be on for any value except `none`. |
107
+ | API Option | CLI Option | Default | Description |
108
+ | -------------------- | --------------------- | :------------------------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `printWidth` | `--print-width` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)). |
110
+ | `requirePragma` | `--require-pragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)). |
111
+ | `rubyExecutablePath` | `"ruby"` | Allows you to configure your Ruby executable path. |
112
+ | `rubyPlugins` | `--ruby-plugins` | `""` | The comma-separated list of plugins to require. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). |
113
+ | `rubySingleQuote` | `--ruby-single-quote` | `false` | Whether or not to default to single quotes for Ruby code. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins). |
114
+ | `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
115
+ | `trailingComma` | `--trailing-comma` | `es5` | Almost same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-commas)). Will be on for any value except `none`. |
145
116
 
146
117
  Any of these can be added to your existing [prettier configuration
147
118
  file](https://prettier.io/docs/en/configuration.html). For example:
@@ -158,22 +129,13 @@ Or, they can be passed to `prettier` as arguments:
158
129
  bundle exec rbprettier --tab-width 4 --write '**/*'
159
130
  ```
160
131
 
161
- ### Usage with RuboCop
162
-
163
- RuboCop and Prettier for Ruby serve different purposes, but there is overlap
164
- with some of RuboCop's functionality.
165
-
166
- Prettier provides a RuboCop configuration file to disable the rules which clash.
167
- To enable, add the following config at the top of your project's `.rubocop.yml`:
132
+ ### Ignoring code
168
133
 
169
- #### Ruby gem
134
+ Sometimes you want to leave your formatting in place and have `prettier` not format it, but continue to format the rest of the file. `prettier` has the ability to do this with `prettier-ignore` comments, but because the underlying formatter for this plugin is [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree), you instead would use a `stree-ignore` comment.
170
135
 
171
- ```yaml
172
- inherit_gem:
173
- prettier: rubocop.yml
174
- ```
136
+ ### Usage with RuboCop
175
137
 
176
- #### `npm` package
138
+ RuboCop and Prettier for Ruby serve different purposes, but there is overlap with some of RuboCop's functionality. Prettier provides a RuboCop configuration file to disable the rules which would clash. To enable this file, add the following configuration at the top of your project's `.rubocop.yml`:
177
139
 
178
140
  ```yaml
179
141
  inherit_from:
@@ -201,9 +163,11 @@ Refer to [this issue](https://github.com/prettier/plugin-ruby/issues/113#issueco
201
163
 
202
164
  ## Contributing
203
165
 
204
- Check out our [contributing guide](CONTRIBUTING.md). Bug reports and pull requests are welcome on GitHub at https://github.com/prettier/plugin-ruby.
166
+ Thanks so much for your interest in contributing! You can contribute in many ways, including:
205
167
 
206
- You can support `prettier/plugin-ruby` [on OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website.
168
+ - Contributing code to fix any bugs on [GitHub](https://github.com/prettier/plugin-ruby).
169
+ - Reporting issues on [GitHub](https://github.com/prettier/plugin-ruby/issues/new).
170
+ - Supporting `prettier/plugin-ruby` on [OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website.
207
171
 
208
172
  <!-- prettier-ignore-start -->
209
173
  <!-- markdownlint-disable -->
data/lib/prettier.rb CHANGED
@@ -4,17 +4,19 @@ require "json" unless defined?(JSON)
4
4
  require "open3"
5
5
 
6
6
  module Prettier
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"]
7
+ directory = -File.expand_path("..", __dir__)
8
+ package = File.read(File.join(directory, "package.json"))
9
+
10
+ PLUGIN = -File.join(directory, "src/plugin.js")
11
+ BINARY = -File.join(directory, "node_modules/prettier/bin/prettier.cjs")
12
+ VERSION = -JSON.parse(package)["version"]
10
13
 
11
14
  def self.run(args)
12
15
  quoted = args.map { |arg| arg.start_with?("-") ? arg : "\"#{arg}\"" }
13
16
  command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(" ")}"
14
17
  opts = STDIN.tty? ? {} : { stdin_data: STDIN }
15
18
 
16
- stdout, stderr, status =
17
- Open3.capture3({ "RBPRETTIER" => "1" }, command, opts)
19
+ stdout, stderr, status = Open3.capture3({}, command, opts)
18
20
  STDOUT.puts(stdout)
19
21
 
20
22
  # If we completed successfully, then just exit out.