prettier 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69429c1f7b0cc5b82babb8463afcdacbb30026b0c9a77afcf8f6c4dbddd5b545
4
- data.tar.gz: f81d934981c3086071371a9013184fbb19543dd7a86ca4258addd5870defbe73
3
+ metadata.gz: 1a60ee62443799f6fdd3380700b4091b75e1f50658e01cad2cdf1ade440917f4
4
+ data.tar.gz: 4c95bb8ae2916d965e12cc376aa2c8df0ce985420e78edc45554c6412a4e3469
5
5
  SHA512:
6
- metadata.gz: e6e612eb427b6c244c365b4595d1cefb0987e43255a541accd4843cadd4c73c0c5dd96268cf6ed8444afe2c2008e4792e3ad3155474d6ec20ffb880f65c23fb7
7
- data.tar.gz: f825fb2f339e52c9c9dae9b287b5f21436fadaaea29ed0e93b14ee0ebb97bfaaac9aa1e16eaa2549b4a66e513c1007a3f48e1aa587efe6032568f77afd85d77f
6
+ metadata.gz: f449363349b3476457419d8374dd1127ac8bcfb7faf2afa1f20eb49b21968c2cd5301ad26731bde90e8de64f5604534f375ffcf7ef60bdb21b0fb3f95c160439
7
+ data.tar.gz: 27fde34295c91d167f693d5ab4c8e67c639d9302854a7ef2423552b978a9611615b94fa07b3dae6d20c611fc7bc9764820570555a88faf61450235c467ee757e
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ 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.2.0] - 2022-07-22
10
+
11
+ ### Added
12
+
13
+ - [#1250](https://github.com/prettier/plugin-ruby/issues/1250) - alexf101, kddnewton - Respect the `tabWidth` option.
14
+
15
+ ### Changed
16
+
17
+ - [#1255](https://github.com/prettier/plugin-ruby/pull/1255) - soberstadt - The rake task now runs check if write is false.
18
+ - [#1237](https://github.com/prettier/plugin-ruby/issues/1237) - boris-petrov - Disable the style rules associated with quotes.
19
+ - [#1248](https://github.com/prettier/plugin-ruby/pull/1248) - mhssmnn - Fix process waiting on STDIN.
20
+
9
21
  ## [3.1.2] - 2022-05-13
10
22
 
11
23
  ### Changed
@@ -49,7 +49,7 @@ module Prettier
49
49
  end
50
50
 
51
51
  def run_task
52
- Prettier.run([("--write" if write), source_files].compact)
52
+ Prettier.run([write ? "--write" : "--check", source_files].compact)
53
53
  exit($?.exitstatus) if $?&.exited?
54
54
  end
55
55
  end
data/lib/prettier.rb CHANGED
@@ -11,9 +11,10 @@ module Prettier
11
11
  def self.run(args)
12
12
  quoted = args.map { |arg| arg.start_with?("-") ? arg : "\"#{arg}\"" }
13
13
  command = "node #{BINARY} --plugin \"#{PLUGIN}\" #{quoted.join(" ")}"
14
+ opts = STDIN.tty? ? {} : { stdin_data: STDIN }
14
15
 
15
16
  stdout, stderr, status =
16
- Open3.capture3({ "RBPRETTIER" => "1" }, command, stdin_data: STDIN)
17
+ Open3.capture3({ "RBPRETTIER" => "1" }, command, opts)
17
18
  STDOUT.puts(stdout)
18
19
 
19
20
  # If we completed successfully, then just exit out.
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prettier/plugin-ruby",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "prettier plugin for the Ruby programming language",
5
5
  "main": "src/plugin.js",
6
6
  "scripts": {
data/rubocop.yml CHANGED
@@ -32,16 +32,16 @@ Style/Lambda:
32
32
  Style/MultilineBlockChain:
33
33
  Enabled: false
34
34
 
35
- # Syntax Tree by default uses double quotes, so changing the configuration here
36
- # to match that.
35
+ # Disable the single- vs double-quotes rules as these depend on whether the user
36
+ # has added or not `plugin/single_quotes` for `syntax_tree`
37
37
  Style/StringLiterals:
38
- EnforcedStyle: double_quotes
38
+ Enabled: false
39
39
 
40
40
  Style/StringLiteralsInInterpolation:
41
- EnforcedStyle: double_quotes
41
+ Enabled: false
42
42
 
43
43
  Style/QuotedSymbols:
44
- EnforcedStyle: double_quotes
44
+ Enabled: false
45
45
 
46
46
  # We let users have a little more freedom with symbol and words arrays. If the
47
47
  # user only has an individual item like ["value"] then we don't bother
@@ -52,8 +52,8 @@ Style/SymbolArray:
52
52
  Style/WordArray:
53
53
  Enabled: false
54
54
 
55
- # We don't support trailing commas in Syntax Tree by default, so just turning
56
- # these off for now.
55
+ # Disable the trailing-comma rules as these depend on whether the user has added
56
+ # or not `plugin/trailing_comma` for `syntax_tree`
57
57
  Style/TrailingCommaInArguments:
58
58
  Enabled: false
59
59
 
data/src/parseSync.js CHANGED
@@ -181,7 +181,7 @@ function parseSync(parser, source, opts) {
181
181
  }
182
182
 
183
183
  const response = spawnSync(parserArgs.cmd, parserArgs.args, {
184
- input: `${parser}|${opts.printWidth}|${source}`,
184
+ input: `${parser}|${opts.printWidth}|${opts.tabWidth}|${source}`,
185
185
  maxBuffer: 15 * 1024 * 1024
186
186
  });
187
187
 
data/src/server.rb CHANGED
@@ -74,8 +74,8 @@ listener =
74
74
 
75
75
  # Start up a new thread that will handle each successive connection.
76
76
  Thread.new(server.accept_nonblock) do |socket|
77
- parser, width, source =
78
- socket.read.force_encoding("UTF-8").split("|", 3)
77
+ parser, maxwidth_string, tabwidth_string, source =
78
+ socket.read.force_encoding("UTF-8").split("|", 4)
79
79
 
80
80
  source.each_line do |line|
81
81
  case line
@@ -92,25 +92,40 @@ listener =
92
92
  end
93
93
  end
94
94
 
95
- maxwidth = width.to_i
95
+ # At the moment, we're not going to support odd tabwidths. It's going to
96
+ # have to be a multiple of 2, because of the way that the prettyprint
97
+ # gem functions. So we're going to just use integer division here.
98
+ scalar = tabwidth_string.to_i / 2
99
+ genspace = ->(n) { " " * n * scalar }
100
+
101
+ maxwidth = maxwidth_string.to_i
96
102
  response =
97
103
  case parser
98
104
  when "ping"
99
105
  "pong"
100
106
  when "ruby"
101
- formatter = SyntaxTree::Formatter.new(source, [], maxwidth)
107
+ formatter =
108
+ SyntaxTree::Formatter.new(source, [], maxwidth, "\n", &genspace)
102
109
  SyntaxTree.parse(source).format(formatter)
103
110
  formatter.flush
104
111
  formatter.output.join
105
112
  when "rbs"
106
- formatter = SyntaxTree::RBS::Formatter.new(source, [], maxwidth)
113
+ formatter =
114
+ SyntaxTree::RBS::Formatter.new(
115
+ source,
116
+ [],
117
+ maxwidth,
118
+ "\n",
119
+ &genspace
120
+ )
107
121
  SyntaxTree::RBS.parse(source).format(formatter)
108
122
  formatter.flush
109
123
  formatter.output.join
110
124
  when "haml"
111
- PrettierPrint.format(+"", maxwidth) do |q|
112
- SyntaxTree::Haml.parse(source).format(q)
113
- end
125
+ formatter = PrettierPrint.new(+"", maxwidth, "\n", &genspace)
126
+ SyntaxTree::Haml.parse(source).format(formatter)
127
+ formatter.flush
128
+ formatter.output
114
129
  end
115
130
 
116
131
  if response
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.1.2
4
+ version: 3.2.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-14 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syntax_tree
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.1
19
+ version: 2.7.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.1
26
+ version: 2.7.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: syntax_tree-haml
29
29
  requirement: !ruby/object:Gem::Requirement