• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    JavaScript
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Prettier for ruby

Please Check the official repo here prettier-plugin-ruby

This repo is deprecated


Prettier Ruby Plugin

All Contributors

๐Ÿšง Work in Progress! ๐Ÿšง

WORK IN PROGRESS

Please note that this plugin is under active development, and might not be ready to run on production code yet.

How it works

Prettier-Ruby relies on Ripper, the official parser of Ruby to understand your code. Once your code has been read and parsed, it is then reformatted using the formatting commands provided by Prettier.

Contributing

If you're interested in contributing to the development of Prettier for Ruby:

  • Clone this repository
  • Run yarn to install dependencies
  • Ensure all tests run with yarn run test

You will find it useful to read the CONTRIBUTING guide from Prettier, as it all applies to this repository too.

Development

Prettier-Ruby makes use of Ruby's official lexer and parser, Ripper. You can see the output of Ripper's tokens, sexpressions, the intermediate representation that prettier-ruby uses, as well as the final prettier-ruby result by appending DEBUG=true when running tests:

DEBUG=true yarn run test --watch

You should now see some useful debug output in your console:

Debug mode enabled, showing the parsed Ruby tokens and more

You can run the Ruby AST Exporter directly with a given string too:

$ ruby vendor/ruby/astexport.rb "puts 'hello world'"

To run an individual test folder:

DEBUG=true yarn run test tests/defs --watch

Usage

Until this package is officially released to npm you must clone it yourself, and run it directly:

  • Clone this repository
  • Run yarn to install dependencies
  • Run yarn prettier test.rb to check the output of a single file
  • Run on multiple files with yarn prettier your_folder/**/*.rb
  • Save the result with yarn prettier your_folder/**/*.rb --write

Contributors

Thanks goes to these wonderful people (emoji key):


Alan Foster

๐Ÿ“– ๐Ÿ› ๐Ÿ’ป ๐Ÿค”

Amit Solanki

๐Ÿ“– ๐Ÿ› ๐Ÿ’ป ๐Ÿค” ๐Ÿ’ก ๐Ÿ‘€ โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!