prettier 3.0.0 → 3.1.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 +6 -0
- data/README.md +7 -6
- data/package.json +3 -3
- data/src/parseSync.js +12 -8
- data/src/plugin.js +15 -6
- data/src/server.rb +5 -0
- 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: 5f4a11b3b694651795ea82803d2b9efaafc70bc811409eeba50a76d48aff55bd
|
4
|
+
data.tar.gz: '0039c5cd3d89db3dbff1e0b5c4cfb2f307838f77faec7c6a9c3d23781f22bb4a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73dfee52bf2aaa09c15c6dc23f167ecf20ef983b368a0bac4ad3fb8d193044bb4109469a0eae06c93909ee0a5aef6e926035c083efe4fec9c696a2286efe3470
|
7
|
+
data.tar.gz: 02bded0e2c06e9153a16391671886f695f433c0a035b00116dc9e4fdae01a309b66d8f9147431491e81979e135c1abe6e796bf5e4c0005ebd00579d85ca9df0c
|
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.0] - 2022-05-12
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- [#1224](https://github.com/prettier/plugin-ruby/pull/1224) - kddnewton - Support passing the `rubyPlugins` option to configure Syntax Tree.
|
14
|
+
|
9
15
|
## [3.0.0] - 2022-05-04
|
10
16
|
|
11
17
|
### Added
|
data/README.md
CHANGED
@@ -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 syntax_tree syntax_tree-haml syntax_tree-rbs
|
124
|
+
gem install bundler syntax_tree syntax_tree-haml syntax_tree-rbs
|
125
125
|
```
|
126
126
|
|
127
127
|
The `prettier` executable is now installed and ready for use:
|
@@ -134,11 +134,12 @@ The `prettier` executable is now installed and ready for use:
|
|
134
134
|
|
135
135
|
Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:
|
136
136
|
|
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
|
-
| `
|
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)). |
|
142
143
|
|
143
144
|
Any of these can be added to your existing [prettier configuration
|
144
145
|
file](https://prettier.io/docs/en/configuration.html). For example:
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prettier/plugin-ruby",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.1.0",
|
4
4
|
"description": "prettier plugin for the Ruby programming language",
|
5
5
|
"main": "src/plugin.js",
|
6
6
|
"scripts": {
|
@@ -22,9 +22,9 @@
|
|
22
22
|
"prettier": ">=2.3.0"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
|
-
"eslint": "^8.
|
25
|
+
"eslint": "^8.15.0",
|
26
26
|
"eslint-config-prettier": "^8.0.0",
|
27
|
-
"husky": "^
|
27
|
+
"husky": "^8.0.1",
|
28
28
|
"jest": "^28.0.1",
|
29
29
|
"pretty-quick": "^3.1.2"
|
30
30
|
},
|
data/src/parseSync.js
CHANGED
@@ -63,7 +63,7 @@ function getInfoFilepath() {
|
|
63
63
|
// server with that filepath as an argument, then spawn another process that
|
64
64
|
// will read that information in order to enable us to connect to it in the
|
65
65
|
// spawnSync function.
|
66
|
-
function spawnServer() {
|
66
|
+
function spawnServer(opts) {
|
67
67
|
const tempDir = mkdtempSync(path.join(os.tmpdir(), "prettier-plugin-ruby-"));
|
68
68
|
const filepath = getInfoFilepath();
|
69
69
|
|
@@ -114,11 +114,15 @@ function spawnServer() {
|
|
114
114
|
};
|
115
115
|
}
|
116
116
|
|
117
|
-
const server = spawn(
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
const server = spawn(
|
118
|
+
"ruby",
|
119
|
+
[serverRbPath, `--plugins=${opts.rubyPlugins}`, filepath],
|
120
|
+
{
|
121
|
+
env: Object.assign({}, process.env, { LANG: getLang() }),
|
122
|
+
detached: true,
|
123
|
+
stdio: "inherit"
|
124
|
+
}
|
125
|
+
);
|
122
126
|
|
123
127
|
server.unref();
|
124
128
|
process.on("exit", () => {
|
@@ -171,9 +175,9 @@ function runningInPnPZip() {
|
|
171
175
|
// like it) here since Prettier requires the results of `parse` to be
|
172
176
|
// synchronous and Node.js does not offer a mechanism for synchronous socket
|
173
177
|
// requests.
|
174
|
-
function parseSync(parser, source) {
|
178
|
+
function parseSync(parser, source, opts) {
|
175
179
|
if (!parserArgs) {
|
176
|
-
parserArgs = spawnServer();
|
180
|
+
parserArgs = spawnServer(opts);
|
177
181
|
}
|
178
182
|
|
179
183
|
const response = spawnSync(parserArgs.cmd, parserArgs.args, {
|
data/src/plugin.js
CHANGED
@@ -81,8 +81,8 @@ const plugin = {
|
|
81
81
|
],
|
82
82
|
parsers: {
|
83
83
|
ruby: {
|
84
|
-
parse(text) {
|
85
|
-
return parseSync("ruby", text);
|
84
|
+
parse(text, _parsers, opts) {
|
85
|
+
return parseSync("ruby", text, opts);
|
86
86
|
},
|
87
87
|
astFormat: "ruby",
|
88
88
|
hasPragma(text) {
|
@@ -96,8 +96,8 @@ const plugin = {
|
|
96
96
|
}
|
97
97
|
},
|
98
98
|
rbs: {
|
99
|
-
parse(text) {
|
100
|
-
return parseSync("rbs", text);
|
99
|
+
parse(text, _parsers, opts) {
|
100
|
+
return parseSync("rbs", text, opts);
|
101
101
|
},
|
102
102
|
astFormat: "rbs",
|
103
103
|
hasPragma(text) {
|
@@ -111,8 +111,8 @@ const plugin = {
|
|
111
111
|
}
|
112
112
|
},
|
113
113
|
haml: {
|
114
|
-
parse(text) {
|
115
|
-
return parseSync("haml", text);
|
114
|
+
parse(text, _parsers, opts) {
|
115
|
+
return parseSync("haml", text, opts);
|
116
116
|
},
|
117
117
|
astFormat: "haml",
|
118
118
|
hasPragma(text) {
|
@@ -152,6 +152,15 @@ const plugin = {
|
|
152
152
|
}
|
153
153
|
}
|
154
154
|
},
|
155
|
+
options: {
|
156
|
+
rubyPlugins: {
|
157
|
+
type: "string",
|
158
|
+
category: "Ruby",
|
159
|
+
default: "",
|
160
|
+
description: "The comma-separated list of plugins to require",
|
161
|
+
since: "3.1.0"
|
162
|
+
}
|
163
|
+
},
|
155
164
|
defaultOptions: {
|
156
165
|
printWidth: 80,
|
157
166
|
tabWidth: 2
|
data/src/server.rb
CHANGED
@@ -10,6 +10,11 @@ require "syntax_tree"
|
|
10
10
|
require "syntax_tree/haml"
|
11
11
|
require "syntax_tree/rbs"
|
12
12
|
|
13
|
+
# First, require all of the plugins that the user specified.
|
14
|
+
ARGV.shift[/^--plugins=(.*)$/, 1]
|
15
|
+
.split(",")
|
16
|
+
.each { |plugin| require "syntax_tree/#{plugin}" }
|
17
|
+
|
13
18
|
# Make sure we trap these signals to be sure we get the quit command coming from
|
14
19
|
# the parent node process
|
15
20
|
quit = false
|
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.
|
4
|
+
version: 3.1.0
|
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-
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syntax_tree
|