/plugin-ruby

Prettier Ruby Plugin used in awesomecode.io

Primary LanguageJavaScriptMIT LicenseMIT

awesomecode-plugin-ruby

This is a fork of prettier plugin-ruby, which is used in Awesome Code

How to use

npm install prettier awesomecode-plugin-ruby
npx prettier *.rb

What changed comparing to the official plugin ruby?

It removes the following configurations

  • rubyArrayLiteral
  • rubyHashLabel
  • rubyModifier
  • rubyToProc

It contains the following changes

do not add line break for array index

longarrayname[index]

won't be transformed to

longarrayname[index]

do not transform regexp

/abc/

won't be transformed to

%r{abc}

do not transform to proc

array.each { |element| element.to_s }

won't be transformed to

array.each(&:to_s)

do not transform array literal

['foo']
[:bar]

won't be transformed to

%w[foo]
%i[bar]

do not transform conditions

e.g.

if result
  'foo'
else
  'bar'
end

won't be transformed to

result ? 'foo' : 'bar'

do not transform loops

e.g.

while true
  break :value
end

won't be transformed to

break :value while true

do not transform blocks

e.g.

included do
  has_many :build_items, dependent: :destroy
end

won't be transformed to

included { has_many :build_items, dependent: :destroy }