prettier 1.2.4 → 1.5.1
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 +351 -361
- data/README.md +11 -96
- data/node_modules/prettier/index.js +54 -54
- data/package.json +1 -2
- data/src/haml/embed.js +87 -0
- data/src/haml/nodes/comment.js +27 -0
- data/src/haml/nodes/doctype.js +34 -0
- data/src/haml/nodes/filter.js +16 -0
- data/src/haml/nodes/hamlComment.js +21 -0
- data/src/haml/nodes/plain.js +6 -0
- data/src/haml/nodes/root.js +8 -0
- data/src/haml/nodes/script.js +33 -0
- data/src/haml/nodes/silentScript.js +59 -0
- data/src/haml/nodes/tag.js +193 -0
- data/src/haml/parser.js +22 -0
- data/src/haml/parser.rb +138 -0
- data/src/haml/printer.js +28 -0
- data/src/parser/getLang.js +32 -0
- data/src/parser/getNetcat.js +50 -0
- data/src/parser/netcat.js +15 -0
- data/src/parser/parseSync.js +33 -0
- data/src/parser/requestParse.js +74 -0
- data/src/parser/server.rb +61 -0
- data/src/plugin.js +26 -4
- data/src/rbs/parser.js +39 -0
- data/src/rbs/parser.rb +94 -0
- data/src/rbs/printer.js +605 -0
- data/src/ruby/embed.js +54 -8
- data/src/ruby/nodes/args.js +20 -6
- data/src/ruby/nodes/arrays.js +36 -33
- data/src/ruby/nodes/calls.js +12 -43
- data/src/ruby/nodes/class.js +17 -27
- data/src/ruby/nodes/commands.js +8 -3
- data/src/ruby/nodes/conditionals.js +1 -1
- data/src/ruby/nodes/hashes.js +28 -14
- data/src/ruby/nodes/loops.js +4 -10
- data/src/ruby/nodes/methods.js +4 -11
- data/src/ruby/nodes/rescue.js +32 -25
- data/src/ruby/nodes/statements.js +6 -5
- data/src/ruby/nodes/strings.js +7 -6
- data/src/ruby/parser.js +2 -50
- data/src/ruby/parser.rb +113 -43
- data/src/ruby/printer.js +8 -5
- data/src/utils.js +1 -0
- data/src/utils/inlineEnsureParens.js +8 -1
- data/src/utils/isEmptyBodyStmt.js +7 -0
- data/src/utils/isEmptyStmts.js +9 -5
- data/src/utils/noIndent.js +1 -0
- data/src/utils/printEmptyCollection.js +9 -2
- metadata +25 -2
data/README.md
CHANGED
@@ -72,6 +72,12 @@ To run `prettier` with the Ruby plugin, you're going to need [`ruby`](https://ww
|
|
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
|
|
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
|
+
|
75
81
|
### Ruby gem
|
76
82
|
|
77
83
|
Add this line to your application's Gemfile:
|
@@ -95,7 +101,7 @@ gem install prettier
|
|
95
101
|
The `rbprettier` executable is now installed and ready for use:
|
96
102
|
|
97
103
|
```bash
|
98
|
-
bundle exec rbprettier --write '
|
104
|
+
bundle exec rbprettier --write '**/*'
|
99
105
|
```
|
100
106
|
|
101
107
|
### `npm` package
|
@@ -115,7 +121,7 @@ yarn add --dev prettier @prettier/plugin-ruby
|
|
115
121
|
The `prettier` executable is now installed and ready for use:
|
116
122
|
|
117
123
|
```bash
|
118
|
-
./node_modules/.bin/prettier --write '
|
124
|
+
./node_modules/.bin/prettier --write '**/*'
|
119
125
|
```
|
120
126
|
|
121
127
|
## Configuration
|
@@ -132,7 +138,7 @@ Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/pl
|
|
132
138
|
| `rubySingleQuote` | `--ruby-single-quote` | `true` | When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals. |
|
133
139
|
| `rubyToProc` | `--ruby-to-proc` | `false` | When possible, convert blocks to the more concise `Symbol#to_proc` syntax. |
|
134
140
|
| `tabWidth` | `--tab-width` | `2` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)). |
|
135
|
-
| `trailingComma` | `--trailing-comma` | `
|
141
|
+
| `trailingComma` | `--trailing-comma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-comma)). `"es5"` is equivalent to `true`. |
|
136
142
|
|
137
143
|
Any of these can be added to your existing [prettier configuration
|
138
144
|
file](https://prettier.io/docs/en/configuration.html). For example:
|
@@ -146,7 +152,7 @@ file](https://prettier.io/docs/en/configuration.html). For example:
|
|
146
152
|
Or, they can be passed to `prettier` as arguments:
|
147
153
|
|
148
154
|
```bash
|
149
|
-
prettier --ruby-single-quote false --write '
|
155
|
+
prettier --ruby-single-quote false --write '**/*'
|
150
156
|
```
|
151
157
|
|
152
158
|
### Usage with RuboCop
|
@@ -154,7 +160,7 @@ prettier --ruby-single-quote false --write '**/*.rb'
|
|
154
160
|
RuboCop and Prettier for Ruby serve different purposes, but there is overlap
|
155
161
|
with some of RuboCop's functionality.
|
156
162
|
|
157
|
-
Prettier provides a RuboCop configuration
|
163
|
+
Prettier provides a RuboCop configuration file to disable the rules which clash.
|
158
164
|
To enable, add the following config at the top of your project's `.rubocop.yml`:
|
159
165
|
|
160
166
|
```yaml
|
@@ -166,97 +172,6 @@ inherit_gem:
|
|
166
172
|
|
167
173
|
Check out our [contributing guide](CONTRIBUTING.md). Bug reports and pull requests are welcome on GitHub at https://github.com/prettier/plugin-ruby.
|
168
174
|
|
169
|
-
### Code
|
170
|
-
|
171
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
172
|
-
|
173
|
-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
174
|
-
<!-- prettier-ignore-start -->
|
175
|
-
<!-- markdownlint-disable -->
|
176
|
-
<table>
|
177
|
-
<tr>
|
178
|
-
<td align="center"><a href="https://kevindeisz.com"><img src="https://avatars2.githubusercontent.com/u/5093358?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Deisz</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=kddeisz" title="Code">💻</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=kddeisz" title="Documentation">📖</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=kddeisz" title="Tests">⚠️</a> <a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Akddeisz" title="Bug reports">🐛</a></td>
|
179
|
-
<td align="center"><a href="https://www.alanfoster.me/"><img src="https://avatars2.githubusercontent.com/u/1271782?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alan Foster</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=AlanFoster" title="Code">💻</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=AlanFoster" title="Documentation">📖</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=AlanFoster" title="Tests">⚠️</a> <a href="https://github.com/prettier/plugin-ruby/issues?q=author%3AAlanFoster" title="Bug reports">🐛</a></td>
|
180
|
-
<td align="center"><a href="https://github.com/johnschoeman"><img src="https://avatars0.githubusercontent.com/u/16049495?v=4?s=100" width="100px;" alt=""/><br /><sub><b>johnschoeman</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=johnschoeman" title="Tests">⚠️</a></td>
|
181
|
-
<td align="center"><a href="https://twitter.com/aaronjensen"><img src="https://avatars3.githubusercontent.com/u/8588?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aaron Jensen</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=aaronjensen" title="Documentation">📖</a></td>
|
182
|
-
<td align="center"><a href="http://cameronbothner.com"><img src="https://avatars1.githubusercontent.com/u/4642599?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cameron Bothner</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=cbothner" title="Code">💻</a></td>
|
183
|
-
<td align="center"><a href="https://localhost.dev"><img src="https://avatars3.githubusercontent.com/u/47308085?v=4?s=100" width="100px;" alt=""/><br /><sub><b>localhost.dev</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Alocalhostdotdev" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=localhostdotdev" title="Code">💻</a></td>
|
184
|
-
<td align="center"><a href="https://deecewan.github.io"><img src="https://avatars0.githubusercontent.com/u/4755785?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Buchan-Swanson</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Adeecewan" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=deecewan" title="Code">💻</a></td>
|
185
|
-
</tr>
|
186
|
-
<tr>
|
187
|
-
<td align="center"><a href="https://github.com/jpickwell"><img src="https://avatars1.githubusercontent.com/u/4682321?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jordan Pickwell</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajpickwell" title="Bug reports">🐛</a></td>
|
188
|
-
<td align="center"><a href="http://codingitwrong.com"><img src="https://avatars0.githubusercontent.com/u/15832198?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Josh Justice</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3ACodingItWrong" title="Bug reports">🐛</a></td>
|
189
|
-
<td align="center"><a href="https://github.com/xipgroc"><img src="https://avatars0.githubusercontent.com/u/28561131?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xipgroc</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Axipgroc" title="Bug reports">🐛</a></td>
|
190
|
-
<td align="center"><a href="http://lejeun.es"><img src="https://avatars1.githubusercontent.com/u/15168?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gregoire Lejeune</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Aglejeune" title="Bug reports">🐛</a></td>
|
191
|
-
<td align="center"><a href="https://github.com/petevk"><img src="https://avatars3.githubusercontent.com/u/5108627?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pete Van Klaveren</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Apetevk" title="Bug reports">🐛</a></td>
|
192
|
-
<td align="center"><a href="https://github.com/meleyal"><img src="https://avatars3.githubusercontent.com/u/15045?v=4?s=100" width="100px;" alt=""/><br /><sub><b>meleyal</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=meleyal" title="Documentation">📖</a></td>
|
193
|
-
<td align="center"><a href="https://lip.is"><img src="https://avatars1.githubusercontent.com/u/125676?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lipis</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=lipis" title="Documentation">📖</a></td>
|
194
|
-
</tr>
|
195
|
-
<tr>
|
196
|
-
<td align="center"><a href="https://janpiotrowski.de"><img src="https://avatars0.githubusercontent.com/u/183673?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Piotrowski</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=janpio" title="Documentation">📖</a></td>
|
197
|
-
<td align="center"><a href="https://www.andywaite.com"><img src="https://avatars1.githubusercontent.com/u/13400?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andy Waite</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=andyw8" title="Documentation">📖</a> <a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Aandyw8" title="Bug reports">🐛</a></td>
|
198
|
-
<td align="center"><a href="https://github.com/jviney"><img src="https://avatars3.githubusercontent.com/u/7051?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan Viney</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajviney" title="Bug reports">🐛</a></td>
|
199
|
-
<td align="center"><a href="https://github.com/acrewdson"><img src="https://avatars0.githubusercontent.com/u/10353074?v=4?s=100" width="100px;" alt=""/><br /><sub><b>acrewdson</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Aacrewdson" title="Bug reports">🐛</a></td>
|
200
|
-
<td align="center"><a href="https://orleans.io"><img src="https://avatars0.githubusercontent.com/u/1683595?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Louis Orleans</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Adudeofawesome" title="Bug reports">🐛</a></td>
|
201
|
-
<td align="center"><a href="https://github.com/cvoege"><img src="https://avatars2.githubusercontent.com/u/6777709?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Colton Voege</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Acvoege" title="Bug reports">🐛</a></td>
|
202
|
-
<td align="center"><a href="https://stefankracht.de"><img src="https://avatars1.githubusercontent.com/u/529711?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Kracht</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Akrachtstefan" title="Bug reports">🐛</a></td>
|
203
|
-
</tr>
|
204
|
-
<tr>
|
205
|
-
<td align="center"><a href="https://github.com/jakeprime"><img src="https://avatars1.githubusercontent.com/u/1019036?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jakeprime</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajakeprime" title="Bug reports">🐛</a></td>
|
206
|
-
<td align="center"><a href="http://mmainz.github.io"><img src="https://avatars2.githubusercontent.com/u/5417714?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mario Mainz</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ammainz" title="Bug reports">🐛</a></td>
|
207
|
-
<td align="center"><a href="http://www.cldevs.com"><img src="https://avatars3.githubusercontent.com/u/38632061?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CL Web Developers</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Acldevs" title="Bug reports">🐛</a></td>
|
208
|
-
<td align="center"><a href="https://twitter.com/github0013"><img src="https://avatars0.githubusercontent.com/u/809378?v=4?s=100" width="100px;" alt=""/><br /><sub><b>github0013</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Agithub0013" title="Bug reports">🐛</a></td>
|
209
|
-
<td align="center"><a href="https://jami.am"><img src="https://avatars1.githubusercontent.com/u/1456118?v=4?s=100" width="100px;" alt=""/><br /><sub><b>James Costian</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajamescostian" title="Bug reports">🐛</a></td>
|
210
|
-
<td align="center"><a href="https://github.com/joeyjoejoejr"><img src="https://avatars0.githubusercontent.com/u/1141502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joe Jackson</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajoeyjoejoejr" title="Bug reports">🐛</a></td>
|
211
|
-
<td align="center"><a href="http://178.is"><img src="https://avatars3.githubusercontent.com/u/134942?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Max Albrecht</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Aeins78" title="Bug reports">🐛</a></td>
|
212
|
-
</tr>
|
213
|
-
<tr>
|
214
|
-
<td align="center"><a href="https://github.com/matt-wratt"><img src="https://avatars0.githubusercontent.com/u/570030?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Amatt-wratt" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=matt-wratt" title="Code">💻</a></td>
|
215
|
-
<td align="center"><a href="http://vesalaakso.com"><img src="https://avatars2.githubusercontent.com/u/482561?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vesa Laakso</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=valscion" title="Documentation">📖</a></td>
|
216
|
-
<td align="center"><a href="https://github.com/jrdioko"><img src="https://avatars0.githubusercontent.com/u/405288?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jrdioko</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajrdioko" title="Bug reports">🐛</a></td>
|
217
|
-
<td align="center"><a href="http://gin0606.hatenablog.com"><img src="https://avatars2.githubusercontent.com/u/795891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>gin0606</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Agin0606" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=gin0606" title="Code">💻</a></td>
|
218
|
-
<td align="center"><a href="https://github.com/tobyndockerill"><img src="https://avatars1.githubusercontent.com/u/5688326?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tobyn</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=tobyndockerill" title="Code">💻</a></td>
|
219
|
-
<td align="center"><a href="http://ianks.com"><img src="https://avatars0.githubusercontent.com/u/3303032?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ian Ker-Seymer</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=ianks" title="Code">💻</a></td>
|
220
|
-
<td align="center"><a href="https://huangzhimin.com"><img src="https://avatars2.githubusercontent.com/u/66836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Richard Huang</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=flyerhzm" title="Code">💻</a></td>
|
221
|
-
</tr>
|
222
|
-
<tr>
|
223
|
-
<td align="center"><a href="https://github.com/pje"><img src="https://avatars1.githubusercontent.com/u/319655?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patrick Ellis</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Apje" title="Bug reports">🐛</a></td>
|
224
|
-
<td align="center"><a href="https://www.piesync.com/"><img src="https://avatars0.githubusercontent.com/u/161271?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peter De Berdt</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Amasqita" title="Bug reports">🐛</a></td>
|
225
|
-
<td align="center"><a href="https://github.com/hafley66"><img src="https://avatars0.githubusercontent.com/u/6750483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Hafley</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ahafley66" title="Bug reports">🐛</a></td>
|
226
|
-
<td align="center"><a href="http://fruetel.de"><img src="https://avatars1.githubusercontent.com/u/8015212?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thomas Frütel</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3AFruetel" title="Bug reports">🐛</a></td>
|
227
|
-
<td align="center"><a href="https://github.com/alse"><img src="https://avatars1.githubusercontent.com/u/1160249?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alex Serban</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=alse" title="Code">💻</a></td>
|
228
|
-
<td align="center"><a href="http://sviccari.github.io"><img src="https://avatars3.githubusercontent.com/u/4016985?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephanie</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=SViccari" title="Code">💻</a></td>
|
229
|
-
<td align="center"><a href="https://github.com/ShayDavidson"><img src="https://avatars1.githubusercontent.com/u/1366521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shay Davidson</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3AShayDavidson" title="Bug reports">🐛</a></td>
|
230
|
-
</tr>
|
231
|
-
<tr>
|
232
|
-
<td align="center"><a href="https://github.com/ryan-hunter-pc"><img src="https://avatars2.githubusercontent.com/u/13044512?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Hunter</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=ryan-hunter-pc" title="Code">💻</a></td>
|
233
|
-
<td align="center"><a href="https://www.locksteplabs.com/"><img src="https://avatars1.githubusercontent.com/u/7811733?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Klimo</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/commits?author=janklimo" title="Code">💻</a></td>
|
234
|
-
<td align="center"><a href="http://ricksullivan.net"><img src="https://avatars0.githubusercontent.com/u/3654176?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rick Sullivan</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3ARsullivan00" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=Rsullivan00" title="Code">💻</a></td>
|
235
|
-
<td align="center"><a href="https://twitter.com/steobrien"><img src="https://avatars3.githubusercontent.com/u/1694410?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephen O'Brien</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Asteobrien" title="Bug reports">🐛</a></td>
|
236
|
-
<td align="center"><a href="https://github.com/nimish-mehta"><img src="https://avatars2.githubusercontent.com/u/2488470?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nimish Mehta</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Animish-mehta" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=nimish-mehta" title="Code">💻</a></td>
|
237
|
-
<td align="center"><a href="https://joshbielick.com/"><img src="https://avatars2.githubusercontent.com/u/1413330?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Josh Bielick</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajbielick" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=jbielick" title="Code">💻</a></td>
|
238
|
-
<td align="center"><a href="https://github.com/coiti"><img src="https://avatars3.githubusercontent.com/u/27384706?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Román Coitiño</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Acoiti" title="Bug reports">🐛</a></td>
|
239
|
-
</tr>
|
240
|
-
<tr>
|
241
|
-
<td align="center"><a href="https://github.com/mmcnl"><img src="https://avatars2.githubusercontent.com/u/1498727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt McNeil</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ammcnl" title="Bug reports">🐛</a></td>
|
242
|
-
<td align="center"><a href="https://github.com/johncsnyder"><img src="https://avatars2.githubusercontent.com/u/9882099?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John Snyder</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ajohncsnyder" title="Bug reports">🐛</a></td>
|
243
|
-
<td align="center"><a href="https://github.com/rindek"><img src="https://avatars1.githubusercontent.com/u/881209?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacek Jakubik</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Arindek" title="Bug reports">🐛</a></td>
|
244
|
-
<td align="center"><a href="https://twitter.com/ykpythemind"><img src="https://avatars2.githubusercontent.com/u/22209702?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yukito Ito</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Aykpythemind" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=ykpythemind" title="Code">💻</a></td>
|
245
|
-
<td align="center"><a href="https://studyfied.com/"><img src="https://avatars2.githubusercontent.com/u/45869605?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Karan Mandal</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Akaranmandal" title="Bug reports">🐛</a></td>
|
246
|
-
<td align="center"><a href="http://nathanbeam.codes/"><img src="https://avatars3.githubusercontent.com/u/24681333?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nathan Beam</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Anathan-beam" title="Bug reports">🐛</a> <a href="https://github.com/prettier/plugin-ruby/commits?author=nathan-beam" title="Code">💻</a></td>
|
247
|
-
<td align="center"><a href="https://github.com/blampe"><img src="https://avatars3.githubusercontent.com/u/848843?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bryce Lampe</b></sub></a><br /><a href="https://github.com/prettier/plugin-ruby/issues?q=author%3Ablampe" title="Bug reports">🐛</a></td>
|
248
|
-
</tr>
|
249
|
-
</table>
|
250
|
-
|
251
|
-
<!-- markdownlint-restore -->
|
252
|
-
<!-- prettier-ignore-end -->
|
253
|
-
|
254
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
255
|
-
|
256
|
-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
257
|
-
|
258
|
-
### Financial
|
259
|
-
|
260
175
|
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.
|
261
176
|
|
262
177
|
<!-- prettier-ignore-start -->
|
@@ -5249,19 +5249,19 @@ var errors = {
|
|
5249
5249
|
UndefinedParserError
|
5250
5250
|
};
|
5251
5251
|
|
5252
|
-
/*! *****************************************************************************
|
5253
|
-
Copyright (c) Microsoft Corporation.
|
5254
|
-
|
5255
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
5256
|
-
purpose with or without fee is hereby granted.
|
5257
|
-
|
5258
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
5259
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
5260
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
5261
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
5262
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
5263
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
5264
|
-
PERFORMANCE OF THIS SOFTWARE.
|
5252
|
+
/*! *****************************************************************************
|
5253
|
+
Copyright (c) Microsoft Corporation.
|
5254
|
+
|
5255
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
5256
|
+
purpose with or without fee is hereby granted.
|
5257
|
+
|
5258
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
5259
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
5260
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
5261
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
5262
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
5263
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
5264
|
+
PERFORMANCE OF THIS SOFTWARE.
|
5265
5265
|
***************************************************************************** */
|
5266
5266
|
|
5267
5267
|
/* global Reflect, Promise */
|
@@ -14638,6 +14638,7 @@ function printAstToDoc(ast, options, alignmentSize = 0) {
|
|
14638
14638
|
} // We let JSXElement print its comments itself because it adds () around
|
14639
14639
|
// UnionTypeAnnotation has to align the child without the comments
|
14640
14640
|
|
14641
|
+
|
14641
14642
|
let res;
|
14642
14643
|
|
14643
14644
|
if (printer.willPrintOwnComments && printer.willPrintOwnComments(path, options)) {
|
@@ -14674,7 +14675,6 @@ function printPrettierIgnoredNode(node, options) {
|
|
14674
14675
|
locStart,
|
14675
14676
|
locEnd
|
14676
14677
|
} = options;
|
14677
|
-
|
14678
14678
|
const start = locStart(node);
|
14679
14679
|
const end = locEnd(node);
|
14680
14680
|
|
@@ -24808,11 +24808,11 @@ var ini = createCommonjsModule(function (module, exports) {
|
|
24808
24808
|
});
|
24809
24809
|
|
24810
24810
|
var fs = __importStar(fs__default['default']);
|
24811
|
-
/**
|
24812
|
-
* define the possible values:
|
24813
|
-
* section: [section]
|
24814
|
-
* param: key=value
|
24815
|
-
* comment: ;this is a comment
|
24811
|
+
/**
|
24812
|
+
* define the possible values:
|
24813
|
+
* section: [section]
|
24814
|
+
* param: key=value
|
24815
|
+
* comment: ;this is a comment
|
24816
24816
|
*/
|
24817
24817
|
|
24818
24818
|
|
@@ -24821,9 +24821,9 @@ var ini = createCommonjsModule(function (module, exports) {
|
|
24821
24821
|
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
|
24822
24822
|
comment: /^\s*[#;].*$/
|
24823
24823
|
};
|
24824
|
-
/**
|
24825
|
-
* Parses an .ini file
|
24826
|
-
* @param file The location of the .ini file
|
24824
|
+
/**
|
24825
|
+
* Parses an .ini file
|
24826
|
+
* @param file The location of the .ini file
|
24827
24827
|
*/
|
24828
24828
|
|
24829
24829
|
function parse(file) {
|
@@ -29644,8 +29644,8 @@ var path_1 = createCommonjsModule(function (module, exports) {
|
|
29644
29644
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
29645
29645
|
|
29646
29646
|
const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
|
29647
|
-
/**
|
29648
|
-
* Designed to work only with simple paths: `dir\\file`.
|
29647
|
+
/**
|
29648
|
+
* Designed to work only with simple paths: `dir\\file`.
|
29649
29649
|
*/
|
29650
29650
|
|
29651
29651
|
function unixify(filepath) {
|
@@ -34268,17 +34268,17 @@ var pattern = createCommonjsModule(function (module, exports) {
|
|
34268
34268
|
exports.isStaticPattern = isStaticPattern;
|
34269
34269
|
|
34270
34270
|
function isDynamicPattern(pattern, options = {}) {
|
34271
|
-
/**
|
34272
|
-
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
34273
|
-
* An empty string cannot be a dynamic pattern.
|
34274
|
-
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
34271
|
+
/**
|
34272
|
+
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
34273
|
+
* An empty string cannot be a dynamic pattern.
|
34274
|
+
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
34275
34275
|
*/
|
34276
34276
|
if (pattern === '') {
|
34277
34277
|
return false;
|
34278
34278
|
}
|
34279
|
-
/**
|
34280
|
-
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
34281
|
-
* filepath directly (without read directory).
|
34279
|
+
/**
|
34280
|
+
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
34281
|
+
* filepath directly (without read directory).
|
34282
34282
|
*/
|
34283
34283
|
|
34284
34284
|
|
@@ -34389,17 +34389,17 @@ var pattern = createCommonjsModule(function (module, exports) {
|
|
34389
34389
|
} = picomatch$1.scan(pattern, Object.assign(Object.assign({}, options), {
|
34390
34390
|
parts: true
|
34391
34391
|
}));
|
34392
|
-
/**
|
34393
|
-
* The scan method returns an empty array in some cases.
|
34394
|
-
* See micromatch/picomatch#58 for more details.
|
34392
|
+
/**
|
34393
|
+
* The scan method returns an empty array in some cases.
|
34394
|
+
* See micromatch/picomatch#58 for more details.
|
34395
34395
|
*/
|
34396
34396
|
|
34397
34397
|
if (parts.length === 0) {
|
34398
34398
|
parts = [pattern];
|
34399
34399
|
}
|
34400
|
-
/**
|
34401
|
-
* The scan method does not return an empty part for the pattern with a forward slash.
|
34402
|
-
* This is another part of micromatch/picomatch#58.
|
34400
|
+
/**
|
34401
|
+
* The scan method does not return an empty part for the pattern with a forward slash.
|
34402
|
+
* This is another part of micromatch/picomatch#58.
|
34403
34403
|
*/
|
34404
34404
|
|
34405
34405
|
|
@@ -34804,8 +34804,8 @@ var constants$5 = createCommonjsModule(function (module, exports) {
|
|
34804
34804
|
const SUPPORTED_MINOR_VERSION = 10;
|
34805
34805
|
const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
|
34806
34806
|
const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
|
34807
|
-
/**
|
34808
|
-
* IS `true` for Node.js 10.10 and greater.
|
34807
|
+
/**
|
34808
|
+
* IS `true` for Node.js 10.10 and greater.
|
34809
34809
|
*/
|
34810
34810
|
|
34811
34811
|
exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
|
@@ -35894,9 +35894,9 @@ var matcher = createCommonjsModule(function (module, exports) {
|
|
35894
35894
|
}
|
35895
35895
|
|
35896
35896
|
_fillStorage() {
|
35897
|
-
/**
|
35898
|
-
* The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
|
35899
|
-
* So, before expand patterns with brace expansion into separated patterns.
|
35897
|
+
/**
|
35898
|
+
* The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
|
35899
|
+
* So, before expand patterns with brace expansion into separated patterns.
|
35900
35900
|
*/
|
35901
35901
|
const patterns = utils$3.pattern.expandPatternsWithBraceExpansion(this._patterns);
|
35902
35902
|
|
@@ -35958,12 +35958,12 @@ var partial = createCommonjsModule(function (module, exports) {
|
|
35958
35958
|
|
35959
35959
|
for (const pattern of patterns) {
|
35960
35960
|
const section = pattern.sections[0];
|
35961
|
-
/**
|
35962
|
-
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
35963
|
-
* but only if the level has reached the end of the first group.
|
35964
|
-
*
|
35965
|
-
* fixtures/{a,b}/**
|
35966
|
-
* ^ true/false ^ always true
|
35961
|
+
/**
|
35962
|
+
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
35963
|
+
* but only if the level has reached the end of the first group.
|
35964
|
+
*
|
35965
|
+
* fixtures/{a,b}/**
|
35966
|
+
* ^ true/false ^ always true
|
35967
35967
|
*/
|
35968
35968
|
|
35969
35969
|
if (!pattern.complete && levels > section.length) {
|
@@ -36045,8 +36045,8 @@ var deep = createCommonjsModule(function (module, exports) {
|
|
36045
36045
|
}
|
36046
36046
|
|
36047
36047
|
_isSkippedByDeep(basePath, entryPath) {
|
36048
|
-
/**
|
36049
|
-
* Avoid unnecessary depth calculations when it doesn't matter.
|
36048
|
+
/**
|
36049
|
+
* Avoid unnecessary depth calculations when it doesn't matter.
|
36050
36050
|
*/
|
36051
36051
|
if (this._settings.deep === Infinity) {
|
36052
36052
|
return false;
|
@@ -36534,10 +36534,10 @@ async function FastGlob(source, options) {
|
|
36534
36534
|
function stream(source, options) {
|
36535
36535
|
assertPatternsInput(source);
|
36536
36536
|
const works = getWorks(source, stream$5.default, options);
|
36537
|
-
/**
|
36538
|
-
* The stream returned by the provider cannot work with an asynchronous iterator.
|
36539
|
-
* To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
|
36540
|
-
* This affects performance (+25%). I don't see best solution right now.
|
36537
|
+
/**
|
36538
|
+
* The stream returned by the provider cannot work with an asynchronous iterator.
|
36539
|
+
* To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
|
36540
|
+
* This affects performance (+25%). I don't see best solution right now.
|
36541
36541
|
*/
|
36542
36542
|
|
36543
36543
|
return utils$3.stream.merge(works);
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prettier/plugin-ruby",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.1",
|
4
4
|
"description": "prettier plugin for the Ruby programming language",
|
5
5
|
"main": "src/plugin.js",
|
6
6
|
"scripts": {
|
@@ -22,7 +22,6 @@
|
|
22
22
|
"prettier": ">=1.10"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
|
-
"all-contributors-cli": "^6.14.1",
|
26
25
|
"eslint": "^7.8.1",
|
27
26
|
"eslint-config-prettier": "^7.0.0",
|
28
27
|
"husky": "^4.3.5",
|
data/src/haml/embed.js
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
const {
|
2
|
+
concat,
|
3
|
+
hardline,
|
4
|
+
indent,
|
5
|
+
literalline,
|
6
|
+
markAsRoot,
|
7
|
+
mapDoc,
|
8
|
+
stripTrailingHardline
|
9
|
+
} = require("../prettier");
|
10
|
+
|
11
|
+
// Get the name of the parser that is represented by the given element node,
|
12
|
+
// return null if a matching parser cannot be found
|
13
|
+
function getParser(name, opts) {
|
14
|
+
let parser = name;
|
15
|
+
|
16
|
+
// We don't want to deal with some weird recursive parser situation, so we
|
17
|
+
// need to explicitly call out the HAML parser here and just return null
|
18
|
+
if (parser === "haml") {
|
19
|
+
return null;
|
20
|
+
}
|
21
|
+
|
22
|
+
// In HAML the name of the JS filter is :javascript, whereas in prettier the
|
23
|
+
// name of the JS parser is babel. Here we explicitly handle that conversion.
|
24
|
+
if (parser === "javascript") {
|
25
|
+
parser = "babel";
|
26
|
+
}
|
27
|
+
|
28
|
+
// If there is a plugin that has a parser that matches the name of this
|
29
|
+
// element, then we're going to assume that's correct for embedding and go
|
30
|
+
// ahead and switch to that parser
|
31
|
+
if (
|
32
|
+
opts.plugins.some(
|
33
|
+
(plugin) =>
|
34
|
+
plugin.parsers &&
|
35
|
+
Object.prototype.hasOwnProperty.call(plugin.parsers, parser)
|
36
|
+
)
|
37
|
+
) {
|
38
|
+
return parser;
|
39
|
+
}
|
40
|
+
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
|
44
|
+
// This function is in here because it handles embedded parser values. I don't
|
45
|
+
// have a test that exercises it because I'm not sure for which parser it is
|
46
|
+
// necessary, but since it's in prettier core I'm keeping it here.
|
47
|
+
/* istanbul ignore next */
|
48
|
+
function replaceNewlines(doc) {
|
49
|
+
return mapDoc(doc, (currentDoc) =>
|
50
|
+
typeof currentDoc === "string" && currentDoc.includes("\n")
|
51
|
+
? concat(
|
52
|
+
currentDoc
|
53
|
+
.split(/(\n)/g)
|
54
|
+
.map((v, i) => (i % 2 === 0 ? v : literalline))
|
55
|
+
)
|
56
|
+
: currentDoc
|
57
|
+
);
|
58
|
+
}
|
59
|
+
|
60
|
+
function embed(path, _print, textToDoc, opts) {
|
61
|
+
const node = path.getValue();
|
62
|
+
if (node.type !== "filter") {
|
63
|
+
return null;
|
64
|
+
}
|
65
|
+
|
66
|
+
const parser = getParser(node.value.name, opts);
|
67
|
+
if (!parser) {
|
68
|
+
return null;
|
69
|
+
}
|
70
|
+
|
71
|
+
return markAsRoot(
|
72
|
+
concat([
|
73
|
+
":",
|
74
|
+
node.value.name,
|
75
|
+
indent(
|
76
|
+
concat([
|
77
|
+
hardline,
|
78
|
+
replaceNewlines(
|
79
|
+
stripTrailingHardline(textToDoc(node.value.text, { parser }))
|
80
|
+
)
|
81
|
+
])
|
82
|
+
)
|
83
|
+
])
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
module.exports = embed;
|