Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

xinminlabs/plugin-ruby

 
 

Repository files navigation

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 }

About

Prettier Ruby Plugin used in awesomecode.io

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 69.4%
  • Ruby 30.6%