Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prettier/plugin-ruby

Package Overview
Dependencies
Maintainers
9
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prettier/plugin-ruby - npm Package Versions

1
8

0.15.1

Diff

Changelog

Source

[0.15.1] - 2019-11-05

Changed

  • AlanFoster - Add bin/lex for viewing the tokenized result of Ripper on Ruby code.
  • jakeprime, kddnewton - When predicates from within an if, unless, while, or until loop break the line, they should be aligned together. For example,
<!-- prettier-ignore -->
if foooooo || barrrrrr
  baz
end

If the line was set to very short, the binary node should be aligned to 3 spaces from the left of the file (which aligns with the if, it would be more for unless). So it would look like:

<!-- prettier-ignore -->
if foooooo ||
     barrrrrr
  baz
end
  • jamescostian], [@AlanFoster - Empty if, and unless conditionals are now handled gracefully:
<!-- prettier-ignore -->
if foo?
end
  • mmainz, kddnewton - Hash keys are not converted to keyword syntax if they would make invalid symbols. For example,
<!-- prettier-ignore -->
{ :[] => nil }

cannot be translated into []: as that is an invalid symbol. Instead, it stays with the hash rocket syntax.

  • cldevs, kddnewton - Do not attempt to format the insides of xstring literals (string that get sent to the command line surrounded by backticks or %x).
  • cldevs, kddnewton - When predicates for if, unless, while, or until nodes contain an assignment, we can't know for sure that it doesn't modify the body. In this case we need to always break and form a multi-line block.
  • MarcManiez, kddnewton - When the return value of if, unless, while, or until nodes are assigned to anything other than a local variable, we need to wrap them in parentheses if we're changing to the modifier form. This is because the following expressions have different semantic meaning:
<!-- prettier-ignore -->
hash[:key] = break :value while false
hash[:key] = while false do break :value end

The first one will not result in an empty hash, whereas the second one will result in { key: nil }. In this case what we need to do for the first expression to align is wrap it in parens, as in:

<!-- prettier-ignore -->
hash[:key] = (break :value while false)

That will guarantee that the expressions are equivalent.

  • AlanFoster - Fix crashes that were happening with ignored_nl nodes.
kddeisz
published 0.15.0 •

Changelog

Source

[0.15.0] - 2019-08-06

Changed

  • dudeofawesome, kddnewton - If xstring literals (command line calls surrounded by backticks) break, then we indent and place the command on a new line. Previously, this was resulting in new lines getting added each time the code was formatted. Now this happens correctly.
  • krachtstefan, kddnewton - When a while or until loop modifies a begin...end statement, it must remain in the modifier form or else it changes sematic meaning. For example,
<!-- prettier-ignore -->
begin
  foo
end while bar

cannot be transformed into:

<!-- prettier-ignore -->
while bar
  foo
end

because that would never execute foo if bar is falsy, whereas in the initial example it would have.

  • jviney], kddnewton - When transforming a block into the Symbol#to_proc syntax from within a list of arguments inside of an aref node (i.e., foo[:bar.each), we can't put the block syntax inside the brackets.
  • jakeprime, kddnewton - Values for the return keyword that broke the line were previously just printed as they were, which breaks if you have a block expression like an if or while. For example,
<!-- prettier-ignore -->
return foo ? bar : baz

if the line was set to very short would be printed as:

<!-- prettier-ignore -->
return if foo
  bar
else
  baz
end

which wouldn't work. Instead, they now get printed with parentheses around the value, as in:

<!-- prettier-ignore -->
return(
  if foo
    bar
  else
    baz
  end
)
  • jakeprime, kddnewton - When switching from a double-quoted string to a single-quoted string that contained escaped double quotes, the backslashes would stay in the string. As in:
<!-- prettier-ignore -->
"Foo \"Bar\" Baz"

would get formatted as:

<!-- prettier-ignore -->
'Foo \"Bar\" Baz'

but now gets formatted as:

<!-- prettier-ignore -->
'Foo "Bar" Baz'
kddeisz
published 0.14.0 •

Changelog

Source

[0.14.0] - 2019-07-17

Added

  • kddnewton - Support for pattern matching for variables and array patterns. Currently waiting on Ripper support for hash patterns. For examples, check out the test/js/patterns.test.js file.

Changed

  • jviney, kddnewton - if/else blocks that had method calls on the end of them that were also transformed into ternaries need to have parens added to them. For example,
<!-- prettier-ignore -->
if foo
  1
else
  2
end.to_s

now correctly gets transformed into:

<!-- prettier-ignore -->
(foo ? 1 : 2).to_s
  • acrewdson, kddnewton - Fixed a bug where multiple newlines at the end of the file would cause a crash.
  • jviney, kddnewton - If a variable is assigned inside of the predicate of a conditional, then we can't change it into the single-line version as this breaks. For example,
<!-- prettier-ignore -->
if foo = 1
  foo
end

must stay the same.

kddeisz
published 0.13.0 •

Changelog

Source

[0.13.0] - 2019-07-05

Added

  • kddnewton - Added locStart and locEnd functions to support --cursor-offset.

Changed

  • xipgroc, kddnewton - Comments inside of do...end blocks that preceeded call nodes were associating the comment with the var_ref instead of the call itself. For example,
<!-- prettier-ignore -->
foo.each do |bar|
  # comment
  bar.baz
  bar.baz
end

would get printed as

<!-- prettier-ignore -->
foo.each do |bar|
  # comment
  bar
    .baz
  bar.baz
end

but now gets printed correctly.

  • petevk, kddnewton - Double splats inside a hash were previously failing to print. For example,
<!-- prettier-ignore -->
{ foo: "bar", **baz }

would fail to print, but now works.

kddeisz
published 0.12.3 •

Changelog

Source

[0.12.3] - 2019-05-16

Changed

  • kddnewton - Move arg, assign, constant, flow, massign, operator, scope, and statement nodes into their own files.
  • kddnewton - Move @int, access_ctrl, assocsplat, block_var, else, number_arg, super, undef, var_ref, and var_ref as well as various call and symbol nodes into appropriate files.
  • kddnewton - Better support for excessed commas in block args. Previously proc { |x,| } would add an extra space, but now it does not.
  • kddnewton - Add a lot more documentation to the parser.
  • glejeune, kddnewton - Previously, the unary not operator inside a ternary (e.g., a ? not(b) : c) would break because it wouldn't add parentheses, but now it adds them.
  • kddnewton - if and unless nodes used to not be able to handle if a comment was the only statement in the body. For example,
<!-- prettier-ignore -->
if foo
  # comment
end

would get printed as

<!-- prettier-ignore -->
# comment if foo

Now the if and unless printers check for the presence of single comments.

  • JoshuaKGoldberg, kddnewton - Fixes an error where command nodes within def nodes would fail to format if it was only a single block argument. For example,
<!-- prettier-ignore -->
def curry(&block)
  new &block
end

would fail, but now works.

  • xipgroc, kddnewton - Comments on lines with array references were previously deleting the array references entirely. For example,
<!-- prettier-ignore -->
array[index] # comment

would previously result in array[], but now prints properly.

kddeisz
published 0.12.2 •

Changelog

Source

[0.12.2] - 2019-04-30

Changed

  • kddnewton - When symbol literal hash keys end with =, they cannot be transformed into hash labels.
  • xipgroc, kddnewton - Fixed when blocks on methods with no arguments are transformed into to_proc syntax.
kddeisz
published 0.12.1 •

Changelog

Source

[0.12.1] - 2019-04-22

Changed

  • kddnewton - If a lambda literal is nested under a command or command_call node anywhere in the heirarchy, then it needs to use the higher-precedence { ... } braces as opposed to the do ... end delimiters.
  • jpickwell, kddnewton - Calling super with a block and no args was causing the parser to fail when attempting to inspect lambda nodes.
  • kddnewton - Support better breaking within interpolation by grouping the interpolated content.
kddeisz
published 0.12.0 •

Changelog

Source

[0.12.0] - 2019-04-18

Added

  • kddnewton - Automatically convert lambda { ... } method calls into -> { ... } literals.
kddeisz
published 0.11.0 •

Changelog

Source

[0.11.0] - 2019-04-18

Added

  • kddnewton - Support for parsing things with a ruby shebang (e.g., #!/usr/bin/env ruby or #!/usr/bin/ruby).
  • kddnewton - Big tests refactor.
  • kddnewton - Make multiple when predicates break at 80 chars and then wrap to be inline with the other predicates.
  • kddnewton - Automatically add underscores in large numbers that aren't already formatted.
  • AlanFoster - Better support for inline access control modifiers.
  • jpickwell, kddnewton - Better support for heredocs in hash literals.
  • kddnewton - Better support for heredocs in array literals.
  • kddnewton - Support automatically transforming def/begin/rescue/end/end into def/rescue/end.

Changed

  • deecewan - Fixed support for dynamic string hash keys.
  • kddnewton - Moved case/when into its own file and added better documentation.
  • kddnewton - Moved begin/rescue into its own file.
  • AlanFoster - Automatically add newlines around access modifiers.
  • kddnewton - Alignment of command calls with arguments is fixed.
  • aaronjensen, kddnewton - Alignment of to is explicitly allowed to not indent to better support rspec.
  • kddnewton - Fix up the to_proc transform so that it works with other argument handling appropriately.
  • kddnewton - Fixed regression on regexp comments.
  • CodingItWrong, kddnewton - Fix up block delimiters when nested inside a command or command_call node.
  • kddnewton - Moved hashes into its own file.
kddeisz
published 0.10.0 •

Changelog

Source

[0.10.0] - 2019-03-25

Added

  • kddnewton - Support for block-local variables.
  • kddnewton - Support for dyna-symbols that are using single quotes.

Changed

  • kddnewton - Force method calls after arrays, blocks, hashes, and xstrings to hang onto the end of the previous nodes.
  • kddnewton - Check before anything else for an invalid ruby version.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc