{"id":13483506,"url":"https://github.com/prettier/plugin-ruby","last_synced_at":"2025-05-13T00:18:40.033Z","repository":{"id":37885860,"uuid":"134440972","full_name":"prettier/plugin-ruby","owner":"prettier","description":"Prettier Ruby Plugin","archived":false,"fork":false,"pushed_at":"2025-03-06T18:34:35.000Z","size":7121,"stargazers_count":1476,"open_issues_count":15,"forks_count":100,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-13T00:18:30.136Z","etag":null,"topics":["prettier","prettier-plugin","ruby"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prettier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"prettier","open_collective":"prettier","thanks_dev":"u/gh/prettier","tidelift":"npm/prettier"}},"created_at":"2018-05-22T16:07:20.000Z","updated_at":"2025-05-09T16:30:10.000Z","dependencies_parsed_at":"2023-12-21T17:13:59.942Z","dependency_job_id":"54425c13-c603-4645-849d-40475f21f4d6","html_url":"https://github.com/prettier/plugin-ruby","commit_stats":{"total_commits":1973,"total_committers":54,"mean_commits":36.53703703703704,"dds":"0.45970603142422706","last_synced_commit":"ed8a2577f5f739365662a64d669ed0e340a40453"},"previous_names":["kddeisz/prettier-ruby"],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prettier%2Fplugin-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prettier","download_url":"https://codeload.github.com/prettier/plugin-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843249,"owners_count":21972881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prettier","prettier-plugin","ruby"],"created_at":"2024-07-31T17:01:12.113Z","updated_at":"2025-05-13T00:18:40.002Z","avatar_url":"https://github.com/prettier.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"Prettier Ruby\" height=\"256px\" src=\"./docs/logo.png\"\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003ePrettier for Ruby\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gitter.im/jlongster/prettier\"\u003e\n    \u003cimg alt=\"Gitter\" src=\"https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/prettier/plugin-ruby/actions\"\u003e\n    \u003cimg alt=\"GitHub Actions\" src=\"https://img.shields.io/github/actions/workflow/status/prettier/plugin-ruby/main.yml?branch=main\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@prettier/plugin-ruby\"\u003e\n    \u003cimg alt=\"NPM Version\" src=\"https://img.shields.io/npm/v/@prettier/plugin-ruby.svg?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"#badge\"\u003e\n    \u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/PrettierCode\"\u003e\n    \u003cimg alt=\"Follow+Prettier+on+Twitter\" src=\"https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n`@prettier/plugin-ruby` is a [prettier](https://prettier.io/) plugin for the Ruby programming language and its ecosystem. `prettier` is an opinionated code formatter that supports multiple languages and integrates with most editors. The idea is to eliminate discussions of style in code review and allow developers to get back to thinking about code design instead.\n\nFor example, the below [code segment](http://www.rubyinside.com/advent2006/4-ruby-obfuscation.html):\n\n\u003c!-- prettier-ignore --\u003e\n```ruby\n        d=[30644250780,9003106878,\n    30636278846,66641217692,4501790980,\n 671_24_603036,131_61973916,66_606629_920,\n   30642677916,30643069058];a,s=[],$*[0]\n      s.each_byte{|b|a\u003c\u003c(\"%036b\"%d[b.\n         chr.to_i]).scan(/\\d{6}/)}\n          a.transpose.each{ |a|\n            a.join.each_byte{\\\n             |i|print i==49?\\\n               ($*[1]||\"#\")\\\n                 :32.chr}\n                   puts\n                    }\n```\n\nwhen run through `@prettier/plugin-ruby` will generate:\n\n```ruby\nd = [\n  30_644_250_780,\n  9_003_106_878,\n  30_636_278_846,\n  66_641_217_692,\n  4_501_790_980,\n  671_24_603036,\n  131_61973916,\n  66_606629_920,\n  30_642_677_916,\n  30_643_069_058\n]\na, s = [], $*[0]\ns.each_byte { |b| a \u003c\u003c (\"%036b\" % d[b.chr.to_i]).scan(/\\d{6}/) }\na.transpose.each do |a|\n  a.join.each_byte { |i| print i == 49 ? ($*[1] || \"#\") : 32.chr }\n  puts\nend\n```\n\n## Getting started\n\nThe `@prettier/plugin-ruby` plugin for `prettier` is a small wrapper around the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem that provides a Ruby formatter for `prettier`. It does this by keeping a Ruby server running in that background that `prettier` can communicate with when it needs to format a Ruby file. This means that in order to function, you will need to have both the requisite `node` and `ruby` dependencies installed. Because of this configuration, there are a couple of ways that you can get setup to use this plugin.\n\n- If you're already using `prettier` in your project to format other files in your project and want to install this as a plugin, you can install it using `npm`.\n- If you're not using `prettier` yet in your project, then we recommend using the [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) gem directly instead of using this plugin.\n- Note that this plugin also ships a gem named `prettier` which is a wrapper around the `prettier` CLI and includes this plugin by default, but _we no longer recommend its use_. If you're using that gem, you should migrate to using [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) instead.\n\nTo run `prettier` with the Ruby plugin as an `npm` package, you're going to need [`ruby`](https://www.ruby-lang.org/en/documentation/installation/) (version `2.7` or newer) and [`node`](https://nodejs.org/en/download/) (version `16` or newer).\n\nIf you're using the `npm` CLI, then add the plugin by:\n\n```bash\nnpm install --save-dev prettier @prettier/plugin-ruby\n```\n\nOr if you're using `yarn`, then add the plugin by:\n\n```bash\nyarn add --dev prettier @prettier/plugin-ruby\n```\n\nYou'll also need to add the necessary Ruby dependencies. You can do this by running:\n\n```bash\ngem install bundler prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs\n```\n\nThe `prettier` executable is now installed and ready for use:\n\n```bash\n./node_modules/.bin/prettier --plugin=@prettier/plugin-ruby --write '**/*'\n```\n\n### Using Prettier \u003e= 3.0\n\nYou need to tell Prettier to use the plugin, add the following to your existing [prettier configuration\nfile](https://prettier.io/docs/en/configuration.html).\n\n```json\n{\n  \"plugins\": [\"@prettier/plugin-ruby\"]\n}\n```\n\n## Configuration\n\nBelow are the options (from [`src/plugin.js`](src/plugin.js)) that `@prettier/plugin-ruby` currently supports:\n\n| API Option           | CLI Option            |                      Default                       | Description                                                                                                                                         |\n| -------------------- | --------------------- | :------------------------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `printWidth`         | `--print-width`       |                        `80`                        | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)).                                                    |\n| `requirePragma`      | `--require-pragma`    |                      `false`                       | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)).                                                 |\n| `rubyExecutablePath` | `\"ruby\"`              | Allows you to configure your Ruby executable path. |\n| `rubyPlugins`        | `--ruby-plugins`      |                        `\"\"`                        | The comma-separated list of plugins to require. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins).                         |\n| `rubySingleQuote`    | `--ruby-single-quote` |                      `false`                       | Whether or not to default to single quotes for Ruby code. See [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree#plugins).               |\n| `tabWidth`           | `--tab-width`         |                        `2`                         | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)).                                                      |\n| `trailingComma`      | `--trailing-comma`    |                       `es5`                        | Almost same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#trailing-commas)). Will be on for any value except `none`. |\n\nAny of these can be added to your existing [prettier configuration\nfile](https://prettier.io/docs/en/configuration.html). For example:\n\n```json\n{\n  \"tabWidth\": 4\n}\n```\n\nOr, they can be passed to `prettier` as arguments:\n\n```bash\nbundle exec rbprettier --tab-width 4 --write '**/*'\n```\n\n### Ignoring code\n\nSometimes you want to leave your formatting in place and have `prettier` not format it, but continue to format the rest of the file. `prettier` has the ability to do this with `prettier-ignore` comments, but because the underlying formatter for this plugin is [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree), you instead would use a `stree-ignore` comment.\n\n### Usage with RuboCop\n\nRuboCop and Prettier for Ruby serve different purposes, but there is overlap with some of RuboCop's functionality. Prettier provides a RuboCop configuration file to disable the rules which would clash. To enable this file, add the following configuration at the top of your project's `.rubocop.yml`:\n\n```yaml\ninherit_from:\n  - node_modules/@prettier/plugin-ruby/rubocop.yml\n```\n\n### Usage with an editor\n\nFor [supported editor integrations](https://github.com/prettier/prettier/blob/main/website/data/editors.yml), you should follow the instructions for installing the integration, then install the npm version of this plugin as a development dependency of your project. For most integrations, that should be sufficient. For convenience, the instructions for integrating with VSCode are used as an example below:\n\n- Install the [Prettier - Code Formatter](https://github.com/prettier/prettier-vscode) extension.\n- Add the npm `@prettier/plugin-ruby` package to your project as described above.\n- Configure in your `settings.json` (`formatOnSave` is optional):\n\n```json\n{\n  \"[ruby]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n    \"editor.formatOnSave\": true\n  }\n}\n```\n\nRefer to [this issue](https://github.com/prettier/plugin-ruby/issues/113#issuecomment-783426539) if you're having difficulties.\n\n## Contributing\n\nThanks so much for your interest in contributing! You can contribute in many ways, including:\n\n- Contributing code to fix any bugs on [GitHub](https://github.com/prettier/plugin-ruby).\n- Reporting issues on [GitHub](https://github.com/prettier/plugin-ruby/issues/new).\n- Supporting `prettier/plugin-ruby` on [OpenCollective](https://opencollective.com/prettier-ruby/contribute). Your organization's logo will show up here with a link to your website.\n\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/prettier-ruby/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/prettier-ruby/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n## License\n\nThe package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":["https://github.com/sponsors/prettier","https://opencollective.com/prettier","https://thanks.dev/u/gh/prettier","https://tidelift.com/funding/github/npm/prettier","https://opencollective.com/prettier-ruby/contribute","https://opencollective.com/prettier-ruby/organization/0/website","https://opencollective.com/prettier-ruby/organization/1/website","https://opencollective.com/prettier-ruby/organization/2/website","https://opencollective.com/prettier-ruby/organization/3/website","https://opencollective.com/prettier-ruby/organization/4/website","https://opencollective.com/prettier-ruby/organization/5/website","https://opencollective.com/prettier-ruby/organization/6/website","https://opencollective.com/prettier-ruby/organization/7/website","https://opencollective.com/prettier-ruby/organization/8/website","https://opencollective.com/prettier-ruby/organization/9/website"],"categories":["Developer Tools","JavaScript","Code Formatting"],"sub_categories":["Ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fplugin-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprettier%2Fplugin-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprettier%2Fplugin-ruby/lists"}