prettier 1.0.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -1
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +6 -1
  5. data/lib/prettier.rb +2 -2
  6. data/node_modules/prettier/index.js +54 -54
  7. data/package.json +4 -2
  8. data/src/{ruby.js → plugin.js} +2 -2
  9. data/src/{embed.js → ruby/embed.js} +2 -2
  10. data/src/{nodes.js → ruby/nodes.js} +0 -0
  11. data/src/{nodes → ruby/nodes}/alias.js +1 -1
  12. data/src/{nodes → ruby/nodes}/aref.js +8 -1
  13. data/src/{nodes → ruby/nodes}/args.js +2 -2
  14. data/src/{nodes → ruby/nodes}/arrays.js +2 -3
  15. data/src/{nodes → ruby/nodes}/assign.js +12 -4
  16. data/src/{nodes → ruby/nodes}/blocks.js +3 -3
  17. data/src/{nodes → ruby/nodes}/calls.js +54 -11
  18. data/src/ruby/nodes/case.js +65 -0
  19. data/src/{nodes → ruby/nodes}/class.js +1 -1
  20. data/src/ruby/nodes/commands.js +126 -0
  21. data/src/{nodes → ruby/nodes}/conditionals.js +3 -3
  22. data/src/{nodes → ruby/nodes}/constants.js +2 -2
  23. data/src/{nodes → ruby/nodes}/flow.js +2 -2
  24. data/src/{nodes → ruby/nodes}/hashes.js +32 -10
  25. data/src/{nodes → ruby/nodes}/heredocs.js +2 -2
  26. data/src/{nodes → ruby/nodes}/hooks.js +2 -2
  27. data/src/{nodes → ruby/nodes}/ints.js +0 -0
  28. data/src/{nodes → ruby/nodes}/lambdas.js +2 -2
  29. data/src/ruby/nodes/loops.js +104 -0
  30. data/src/{nodes → ruby/nodes}/massign.js +8 -1
  31. data/src/{nodes → ruby/nodes}/methods.js +34 -6
  32. data/src/{nodes → ruby/nodes}/operators.js +2 -2
  33. data/src/{nodes → ruby/nodes}/params.js +9 -2
  34. data/src/{nodes → ruby/nodes}/patterns.js +45 -10
  35. data/src/ruby/nodes/regexp.js +56 -0
  36. data/src/{nodes → ruby/nodes}/rescue.js +2 -2
  37. data/src/ruby/nodes/return.js +98 -0
  38. data/src/{nodes → ruby/nodes}/statements.js +1 -1
  39. data/src/{nodes → ruby/nodes}/strings.js +1 -1
  40. data/src/{nodes → ruby/nodes}/super.js +2 -2
  41. data/src/{nodes → ruby/nodes}/undef.js +1 -1
  42. data/src/{parser.js → ruby/parser.js} +2 -2
  43. data/src/{parser.rb → ruby/parser.rb} +323 -317
  44. data/src/{printer.js → ruby/printer.js} +46 -1
  45. data/src/{toProc.js → ruby/toProc.js} +0 -0
  46. data/src/utils.js +10 -93
  47. data/src/utils/containsAssignment.js +11 -0
  48. data/src/utils/getTrailingComma.js +5 -0
  49. data/src/utils/hasAncestor.js +17 -0
  50. data/src/utils/literal.js +7 -0
  51. data/src/utils/makeCall.js +11 -0
  52. data/src/utils/noIndent.js +10 -0
  53. data/src/utils/skipAssignIndent.js +10 -0
  54. metadata +48 -41
  55. data/src/nodes/case.js +0 -61
  56. data/src/nodes/commands.js +0 -91
  57. data/src/nodes/loops.js +0 -101
  58. data/src/nodes/regexp.js +0 -49
  59. data/src/nodes/return.js +0 -72
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b3f385a13ce2aae0cef657abc5d33e5d3d2fbfb59edf1fb39193ded2828cf87
4
- data.tar.gz: 1049cb733eb60e3221a7df64110f5841f39288f8e91cb589f08cc1c23a0ddfbe
3
+ metadata.gz: '0630719fd8b07b6f6fc180db0c88a5d2d2f0aad3d4cdeef4f14aeba83a87d2f1'
4
+ data.tar.gz: 925d6a78992ae155cb65ccd336ec34c3cda7538421151d91952a31461718be2b
5
5
  SHA512:
6
- metadata.gz: ef14696b55d0dd1a544bba5fd45d88e3ab322ab9d2ae34d89b4b6bf84748ac35100022d5e050ed4ef0e5cf5ad93049c1782243cda27e4bae5b7dc87a2f951614
7
- data.tar.gz: 1bedee0f2b091bc7b7b10ceb645d183271dcea847f8b843c79cd6db5ebf078bb94d7d91fd255127f77c71eb9edd185dcfa166ffe9c442f315f64beb9ba57f4ee
6
+ metadata.gz: b8e07ba6fd2839a1c055ec42b08c2f35a92b912a555c227bb644ea91afec560feaa27318df72dfda1023ffbe7a65c446f4ea1ba97ec6202a617d4622abcdbb4b
7
+ data.tar.gz: 7ef40ccd4d7bc5f3b521070402b1a592706d60cb19edfc3072ab45c9086e954f0f4b801a260e8ccb76efbede4b227ca07e4a6e7c1bd670b230b56b0ff01c3496
@@ -6,6 +6,58 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.3] - 2021-01-02
10
+
11
+ ### Changed
12
+
13
+ - [@lukyth], [@kddeisz] - Ensure if a ternary breaks into an `if..else..end` within a `command_call` node that parentheses are added.
14
+ - [@AlanFoster], [@kddeisz] - Ensure you consume the optional `do` keyword on `while` and `until` loops so that it doesn't confuse the parser.
15
+ - [@AlanFoster], [@kddeisz] - Ensure key-value pairs split on line when the key has a comment attached within a hash.
16
+ - [@AlanFoster], [@kddeisz] - Fix for `for` loops that have multiple index variables.
17
+ - [@AlanFoster], [@kddeisz] - Fix parsing very large files by reducing the size of the JSON output from the parser.
18
+ - [@AlanFoster], [@kddeisz] - Ensure you don't skip parentheses if you're returning a value with the `not` unary operator.
19
+
20
+ ## [1.2.2] - 2021-01-01
21
+
22
+ ### Changed
23
+
24
+ - [@nathan-beam] - Gem does not work with CMD/Powershell.
25
+ - [@blampe], [@kddeisz] - Comments inside keyword parameters in method declarations are not printed.
26
+ - [@blampe], [@kddeisz] - `command_call` nodes with unary operators incorrectly parse their operator.
27
+ - [@blampe], [@kddeisz] - Returning multiple values where the first has parentheses was incorrectly removing the remaining values.
28
+ - [@johncsnyder], [@kddeisz] - Call chains whose left-most receiver is a no-indent expression should not indent their entire chain.
29
+
30
+ ## [1.2.1] - 2020-12-27
31
+
32
+ ### Changed
33
+
34
+ - [@kddeisz] - Handle single-line method definitions with parameters.
35
+ - [@kddeisz] - Handle hash and array patterns nested within find patterns.
36
+ - [@kddeisz] - Handle rightward assignment.
37
+ - [@kddeisz] - Handle find patterns with named boundaries.
38
+ - [@kddeisz] - Handle rightward assignment in conditionals.
39
+
40
+ ## [1.2.0] - 2020-12-26
41
+
42
+ ### Added
43
+
44
+ - [@kddeisz] - Support for the `fndptn` node for Ruby 3.0 pattern matching.
45
+ - [@kddeisz] - Support for Ruby 3.0+ single-line method definitions.
46
+
47
+ ## [1.1.0] - 2020-12-20
48
+
49
+ ### Added
50
+
51
+ - [@kddeisz] - Now that the comments are all fixed up, we can support `# prettier-ignore` comments.
52
+
53
+ ### Changed
54
+
55
+ - [@rindek], [@kddeisz] - Do not remove parentheses when receiver looks like a constant.
56
+ - [@rindek], [@kddeisz] - Do not remove parentheses when using the special `call` syntax with no arguments.
57
+ - [@ykpythemind] - Do not change regexp bounds if the body has certain content.
58
+ - [@karanmandal], [@kddeisz] - Correctly print for loops.
59
+ - [@rafbm], [@kddeisz] - If there are method chains with arguments only at the end, we should group the method chain and the method args.
60
+
9
61
  ## [1.0.1] - 2020-12-12
10
62
 
11
63
  ### Changed
@@ -957,7 +1009,12 @@ would previously result in `array[]`, but now prints properly.
957
1009
 
958
1010
  - Initial release 🎉
959
1011
 
960
- [unreleased]: https://github.com/prettier/plugin-ruby/compare/v1.0.1...HEAD
1012
+ [unreleased]: https://github.com/prettier/plugin-ruby/compare/v1.2.3...HEAD
1013
+ [1.2.3]: https://github.com/prettier/plugin-ruby/compare/v1.2.2...v1.2.3
1014
+ [1.2.2]: https://github.com/prettier/plugin-ruby/compare/v1.2.1...v1.2.2
1015
+ [1.2.1]: https://github.com/prettier/plugin-ruby/compare/v1.2.0...v1.2.1
1016
+ [1.2.0]: https://github.com/prettier/plugin-ruby/compare/v1.1.0...v1.2.0
1017
+ [1.1.0]: https://github.com/prettier/plugin-ruby/compare/v1.0.1...v1.1.0
961
1018
  [1.0.1]: https://github.com/prettier/plugin-ruby/compare/v1.0.0...v1.0.1
962
1019
  [1.0.0]: https://github.com/prettier/plugin-ruby/compare/v1.0.0-rc2...v1.0.0
963
1020
  [1.0.0-rc2]: https://github.com/prettier/plugin-ruby/compare/v1.0.0-rc1...v1.0.0-rc2
@@ -1017,6 +1074,7 @@ would previously result in `array[]`, but now prints properly.
1017
1074
  [@andyw8]: https://github.com/andyw8
1018
1075
  [@ashfurrow]: https://github.com/ashfurrow
1019
1076
  [@awinograd]: https://github.com/awinograd
1077
+ [@blampe]: https://github.com/blampe
1020
1078
  [@bugthing]: https://github.com/bugthing
1021
1079
  [@cbothner]: https://github.com/cbothner
1022
1080
  [@christoomey]: https://github.com/christoomey
@@ -1045,20 +1103,25 @@ would previously result in `array[]`, but now prints properly.
1045
1103
  [@jpickwell]: https://github.com/jpickwell
1046
1104
  [@jrdioko]: https://github.com/jrdioko
1047
1105
  [@jviney]: https://github.com/jviney
1106
+ [@karanmandal]: https://github.com/karanmandal
1048
1107
  [@kddeisz]: https://github.com/kddeisz
1049
1108
  [@kmcq]: https://github.com/kmcq
1050
1109
  [@krachtstefan]: https://github.com/krachtstefan
1051
1110
  [@localhostdotdev]: https://github.com/localhostdotdev
1111
+ [@lukyth]: https://github.com/lukyth
1052
1112
  [@marcmaniez]: https://github.com/MarcManiez
1053
1113
  [@masqita]: https://github.com/masqita
1054
1114
  [@matt-wratt]: https://github.com/matt-wratt
1055
1115
  [@meleyal]: https://github.com/meleyal
1056
1116
  [@mmainz]: https://github.com/mmainz
1057
1117
  [@mmcnl]: https://github.com/mmcnl
1118
+ [@nathan-beam]: https://github.com/nathan-beam
1058
1119
  [@noahtheduke]: https://github.com/NoahTheDuke
1059
1120
  [@overload119]: https://github.com/Overload119
1060
1121
  [@petevk]: https://github.com/petevk
1061
1122
  [@pje]: https://github.com/pje
1123
+ [@rafbm]: https://github.com/rafbm
1124
+ [@rindek]: https://github.com/rindek
1062
1125
  [@rosskinsella]: https://github.com/RossKinsella
1063
1126
  [@rsullivan00]: https://github.com/Rsullivan00
1064
1127
  [@ryan-hunter-pc]: https://github.com/ryan-hunter-pc
@@ -1068,4 +1131,5 @@ would previously result in `array[]`, but now prints properly.
1068
1131
  [@tobyndockerill]: https://github.com/tobyndockerill
1069
1132
  [@uri]: https://github.com/uri
1070
1133
  [@xipgroc]: https://github.com/xipgroc
1134
+ [@ykpythemind]: https://github.com/ykpythemind
1071
1135
  [@yuki24]: https://github.com/yuki24
@@ -22,7 +22,7 @@ In order to get printed, the code goes through a couple of transformations. The
22
22
 
23
23
  ### Text to AST
24
24
 
25
- When the prettier process first spins up, it examines which files it's going to print and selects an appropriate plugin for each one. Once selected, it runs that plugin's `parse` function, seen [here](src/parser.js). For the case of the Ruby plugin, that entails spawning a Ruby process that runs [parser.rb](src/parser.rb) with the input code preloaded on stdin.
25
+ When the prettier process first spins up, it examines which files it's going to print and selects an appropriate plugin for each one. Once selected, it runs that plugin's `parse` function, seen [here](src/ruby/parser.js). For the case of the Ruby plugin, that entails spawning a Ruby process that runs [parser.rb](src/ruby/parser.rb) with the input code preloaded on stdin.
26
26
 
27
27
  `parser.rb` will read the text off of stdin and then feed it to a new `Ripper` instance, which is a Ruby standard library recursive-descent parser. Briefly, the way that `Ripper` works is by tokenizing the input and then matching those tokens against a grammar to form s-expressions. To extend `Ripper`, you overwrite the methods that control how those s-expressions are formed, e.g., to modify the s-expression that is formed when `Ripper` encounters a string literal, you would override the `#on_string_literal` method. Below is an example for seeing that in action.
28
28
 
@@ -71,7 +71,7 @@ Now that the text has been transformed into an AST that we can work with, `parse
71
71
 
72
72
  ### AST to Doc
73
73
 
74
- Once prettier has a working AST, it will take it and call the selected plugin's [`printNode` function](src/printer.js), whose purpose is to convert that AST into prettier's intermediate representation called Docs. It does this by handing the print function a `FastPath` object that keeps track of the state of the printing as it goes, and allows accessing various parts of the AST quickly.
74
+ Once prettier has a working AST, it will take it and call the selected plugin's [`printNode` function](src/ruby/printer.js), whose purpose is to convert that AST into prettier's intermediate representation called Docs. It does this by handing the print function a `FastPath` object that keeps track of the state of the printing as it goes, and allows accessing various parts of the AST quickly.
75
75
 
76
76
  Effectively, it walks the AST in the reverse direction from the way `Ripper` built it (top-down instead of bottom-up). The first node that gets passed into the `print` function is the `program` node as that's always on top. Then it is the `program` node's responsibility to recursively call print on its child nodes as it best sees fit.
77
77
 
data/README.md CHANGED
@@ -120,7 +120,7 @@ The `prettier` executable is now installed and ready for use:
120
120
 
121
121
  ## Configuration
122
122
 
123
- Below are the options (from [`src/ruby.js`](src/ruby.js)) that `@prettier/plugin-ruby` currently supports:
123
+ Below are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:
124
124
 
125
125
  | API Option | CLI Option | Default | Description |
126
126
  | ------------------ | ---------------------- | :-----: | ------------------------------------------------------------------------------------------------------------------------------------ |
@@ -227,6 +227,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
227
227
  <tr>
228
228
  <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>
229
229
  <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>
230
+ <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>
231
+ <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>
232
+ <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>
233
+ <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>
234
+ <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>
230
235
  </tr>
231
236
  </table>
232
237
 
@@ -9,8 +9,8 @@ module Prettier
9
9
 
10
10
  class << self
11
11
  def run(args)
12
- quoted = args.map { |arg| arg.start_with?('-') ? arg : "'#{arg}'" }
13
- command = "node #{BINARY} --plugin '#{PLUGIN}' #{quoted.join(' ')}"
12
+ quoted = args.map { |arg| arg.start_with?('-') ? arg : "\"#{arg}\"" }
13
+ command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(' ')}"
14
14
 
15
15
  system({ 'RBPRETTIER' => '1' }, command)
16
16
  end
@@ -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,7 +14638,6 @@ 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
-
14642
14641
  let res;
14643
14642
 
14644
14643
  if (printer.willPrintOwnComments && printer.willPrintOwnComments(path, options)) {
@@ -14675,6 +14674,7 @@ function printPrettierIgnoredNode(node, options) {
14675
14674
  locStart,
14676
14675
  locEnd
14677
14676
  } = 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);
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@prettier/plugin-ruby",
3
- "version": "1.0.1",
3
+ "version": "1.2.3",
4
4
  "description": "prettier plugin for the Ruby programming language",
5
- "main": "src/ruby.js",
5
+ "main": "src/plugin.js",
6
6
  "scripts": {
7
7
  "check-format": "prettier --check '**/*'",
8
8
  "lint": "eslint --cache .",
@@ -50,6 +50,8 @@
50
50
  }
51
51
  },
52
52
  "jest": {
53
+ "globalSetup": "./test/js/globalSetup.js",
54
+ "globalTeardown": "./test/js/globalTeardown.js",
53
55
  "setupFilesAfterEnv": [
54
56
  "./test/js/setupTests.js"
55
57
  ],
@@ -1,5 +1,5 @@
1
- const printer = require("./printer");
2
- const parser = require("./parser");
1
+ const printer = require("./ruby/printer");
2
+ const parser = require("./ruby/parser");
3
3
 
4
4
  /*
5
5
  * metadata mostly pulled from linguist and rubocop:
@@ -6,9 +6,9 @@ const {
6
6
  mapDoc,
7
7
  markAsRoot,
8
8
  stripTrailingHardline
9
- } = require("./prettier");
9
+ } = require("../prettier");
10
10
 
11
- const { literalLineNoBreak } = require("./utils");
11
+ const { literalLineNoBreak } = require("../utils");
12
12
 
13
13
  const parsers = {
14
14
  css: "css",
File without changes
@@ -5,7 +5,7 @@ const {
5
5
  group,
6
6
  hardline,
7
7
  line
8
- } = require("../prettier");
8
+ } = require("../../prettier");
9
9
 
10
10
  // In general, return the printed doc of the argument at the provided index.
11
11
  // Special handling is given for symbol literals that are not bare words, as we
@@ -1,4 +1,11 @@
1
- const { concat, group, indent, join, line, softline } = require("../prettier");
1
+ const {
2
+ concat,
3
+ group,
4
+ indent,
5
+ join,
6
+ line,
7
+ softline
8
+ } = require("../../prettier");
2
9
 
3
10
  // `aref` nodes are when you're pulling a value out of a collection at a
4
11
  // specific index. Put another way, it's any time you're calling the method
@@ -6,10 +6,10 @@ const {
6
6
  join,
7
7
  line,
8
8
  softline
9
- } = require("../prettier");
9
+ } = require("../../prettier");
10
+ const { getTrailingComma } = require("../../utils");
10
11
 
11
12
  const toProc = require("../toProc");
12
- const { getTrailingComma } = require("../utils");
13
13
 
14
14
  function printArgParen(path, opts, print) {
15
15
  const argsNode = path.getValue().body[0];