Need help with prettier-ruby?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

iamsolankiamit
196 Stars 6 Forks 107 Commits 6 Opened issues

Description

Prettier for ruby

Services available

!
?

Need anything else?

Contributors list

# 139,041
React
TypeScr...
nextjs
HTML
49 commits
# 248,557
Markdow...
GraphQL
Rails
Webpack
27 commits
# 144,627
nodemai...
email-s...
elm
vscode
2 commits

Please Check the official repo here prettier-plugin-ruby

This repo is deprecated


Prettier Ruby Plugin

All Contributors

:construction: Work in Progress! :construction:

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

📖 🐛 💻 🤔 💡 👀 ⚠️ | | :---: | :---: | <!-- ALL-CONTRIBUTORS-LIST:END -->

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.