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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -2
- data/README.md +23 -59
- data/lib/prettier.rb +7 -5
- data/node_modules/prettier/LICENSE +5205 -0
- data/node_modules/prettier/README.md +109 -0
- data/node_modules/prettier/{bin-prettier.js → bin/prettier.cjs} +10 -5
- data/node_modules/prettier/doc.d.ts +240 -0
- data/node_modules/prettier/doc.js +1257 -1309
- data/node_modules/prettier/doc.mjs +1312 -0
- data/node_modules/prettier/index.cjs +655 -0
- data/node_modules/prettier/index.d.ts +915 -0
- data/node_modules/prettier/index.mjs +21845 -0
- data/node_modules/prettier/internal/cli.mjs +6978 -0
- data/node_modules/prettier/internal/internal.mjs +6531 -0
- data/node_modules/prettier/package.json +179 -6
- data/node_modules/prettier/plugins/acorn.d.ts +6 -0
- data/node_modules/prettier/plugins/acorn.js +13 -0
- data/node_modules/prettier/plugins/acorn.mjs +13 -0
- data/node_modules/prettier/plugins/angular.d.ts +8 -0
- data/node_modules/prettier/plugins/angular.js +2 -0
- data/node_modules/prettier/plugins/angular.mjs +2 -0
- data/node_modules/prettier/plugins/babel.d.ts +17 -0
- data/node_modules/prettier/plugins/babel.js +16 -0
- data/node_modules/prettier/plugins/babel.mjs +16 -0
- data/node_modules/prettier/plugins/estree.d.ts +0 -0
- data/node_modules/prettier/plugins/estree.js +35 -0
- data/node_modules/prettier/plugins/estree.mjs +35 -0
- data/node_modules/prettier/plugins/flow.d.ts +5 -0
- data/node_modules/prettier/plugins/flow.js +21 -0
- data/node_modules/prettier/plugins/flow.mjs +21 -0
- data/node_modules/prettier/plugins/glimmer.d.ts +5 -0
- data/node_modules/prettier/plugins/glimmer.js +30 -0
- data/node_modules/prettier/plugins/glimmer.mjs +30 -0
- data/node_modules/prettier/plugins/graphql.d.ts +5 -0
- data/node_modules/prettier/plugins/graphql.js +29 -0
- data/node_modules/prettier/plugins/graphql.mjs +29 -0
- data/node_modules/prettier/plugins/html.d.ts +8 -0
- data/node_modules/prettier/plugins/html.js +19 -0
- data/node_modules/prettier/plugins/html.mjs +19 -0
- data/node_modules/prettier/plugins/markdown.d.ts +7 -0
- data/node_modules/prettier/plugins/markdown.js +59 -0
- data/node_modules/prettier/plugins/markdown.mjs +59 -0
- data/node_modules/prettier/plugins/meriyah.d.ts +5 -0
- data/node_modules/prettier/plugins/meriyah.js +5 -0
- data/node_modules/prettier/plugins/meriyah.mjs +5 -0
- data/node_modules/prettier/plugins/postcss.d.ts +7 -0
- data/node_modules/prettier/plugins/postcss.js +52 -0
- data/node_modules/prettier/plugins/postcss.mjs +52 -0
- data/node_modules/prettier/plugins/typescript.d.ts +5 -0
- data/node_modules/prettier/plugins/typescript.js +27 -0
- data/node_modules/prettier/plugins/typescript.mjs +27 -0
- data/node_modules/prettier/plugins/yaml.d.ts +5 -0
- data/node_modules/prettier/plugins/yaml.js +161 -0
- data/node_modules/prettier/plugins/yaml.mjs +161 -0
- data/node_modules/prettier/standalone.d.ts +33 -0
- data/node_modules/prettier/standalone.js +34 -0
- data/node_modules/prettier/standalone.mjs +34 -0
- data/package.json +15 -10
- data/src/plugin.js +210 -14
- data/src/server.rb +50 -85
- metadata +60 -28
- data/CONTRIBUTING.md +0 -185
- data/node_modules/prettier/cli.js +0 -15085
- data/node_modules/prettier/index.js +0 -37282
- data/node_modules/prettier/parser-angular.js +0 -2
- data/node_modules/prettier/parser-babel.js +0 -27
- data/node_modules/prettier/parser-espree.js +0 -26
- data/node_modules/prettier/parser-flow.js +0 -35
- data/node_modules/prettier/parser-glimmer.js +0 -27
- data/node_modules/prettier/parser-graphql.js +0 -15
- data/node_modules/prettier/parser-html.js +0 -36
- data/node_modules/prettier/parser-markdown.js +0 -76
- data/node_modules/prettier/parser-meriyah.js +0 -19
- data/node_modules/prettier/parser-postcss.js +0 -76
- data/node_modules/prettier/parser-typescript.js +0 -280
- data/node_modules/prettier/parser-yaml.js +0 -150
- data/node_modules/prettier/third-party.js +0 -8978
- data/src/getInfo.js +0 -23
- data/src/netcat.js +0 -13
- data/src/parseSync.js +0 -227
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f48ed0363e8410a6e7fb2c3c8bc95ed8a87f8fac28546429571b71bdd3225e19
|
4
|
+
data.tar.gz: b7a8dd5700deda01c743c926890eb977660445a06ca057540ab347b27126ff4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
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/
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
138
|
-
|
|
139
|
-
| `printWidth`
|
140
|
-
| `requirePragma`
|
141
|
-
| `
|
142
|
-
| `
|
143
|
-
| `
|
144
|
-
| `
|
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
|
-
###
|
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
|
-
|
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
|
-
|
172
|
-
inherit_gem:
|
173
|
-
prettier: rubocop.yml
|
174
|
-
```
|
136
|
+
### Usage with RuboCop
|
175
137
|
|
176
|
-
|
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
|
-
|
166
|
+
Thanks so much for your interest in contributing! You can contribute in many ways, including:
|
205
167
|
|
206
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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.
|