Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

standard

> 数据库
Open source

Ruby's bikeshed-proof linter and formatter

2.9K stars0 likes3 views
WebsiteGitHub

About

Ruby's bikeshed-proof linter and formatter

The standard gem brings the ethos of StandardJS to Ruby. It's a linter & formatter built on RuboCop and provides an unconfigurable configuration to all of RuboCop's built-in rules as well as those included in rubocop-performance. It also supports plugins built with lint_roller, like standard-rails and standard-sorbet.

Standard Ruby was created and is maintained by the team at Test Double, because we appreciate the importance of balancing predictable, consistent code with preserving developer autonomy.

Topics covered in this README:

  • Wait, what?!
  • Basic usage
  • Editor & CI integrations
  • Ignoring errors
  • Configuration options
  • Plugins and extensions
  • Community

Wait, did you say unconfigurable configuration?

Yes, Standard is unconfigurable. See, pretty much every developer can agree that automatically identifying and fixing slow, insecure, and error-prone code is a good idea. People also agree it's easier to work in codebases that exhibit a consistent style and format. So, what's the problem? No two developers will ever agree on what all the rules and format should be.

This has resulted in innumerable teams arguing about how to configure their linters and formatters over literal decades. Some teams routinely divert time and energy from whatever they're building to reach consensus on where commas should go. Other teams have an overzealous tech lead who sets up everything his favorite way and then imposes his will on others. It's not uncommon to witness passive-aggressive programmers change a contentious rule back-and-forth, resulting in both acrimony and git churn (and acrimony about git churn). Still, most developers give way to whoever cares more, often resulting in an inconsistent configuration that nobody understands and isn't kept up-to-date with changes to their linter and its target language. Whatever the approach, time spent bikeshedding is time wasted.

But you can't configure Standard Ruby. You can take it or leave it. If this seems presumptive, constraining, and brusque: you're right, it usually does feel that way at first. But since 2018, the Ruby community has debated Standard Ruby's ruleset, ultimately landing us on a sensible set of defaults that—while no one person's favorite way to format Ruby—seems to be good enough for most of the ways people use Ruby, most of the time.

If you adopt Standard Ruby, what's in it for you? Time saved that would've been spent arguing over how to set things up. Also, seamless upgrades: we stay on top of each new RuboCop rule and update our configuration on a monthly release cadence. But the best part of adopting Standard as your linter and formatter? You'll spend a whole lot less time thinking about linters and formatters.

So please, give Standard Ruby a try. If you're like these folks, you'll soon realize that the value of a linter is in using one at all and not in the particulars of how it's configured.

Usage

Install

Getting started is as easy as gem install standard or throwing it in your project's Gemfile and running bundle install:

ruby
gem "standard"

Running Standard Ruby

Once installed, you can run Standard from the command line via its built-in executable or as a Rake task.

Standard Ruby's binary is named standardrb to distinguish it from StandardJS:

$ standardrb

And the Rake task can be run if your Rakefile includes require "standard/rake". This will load the standard task, allowing you to run:

$ rake standard

Either way, Standard will inspect any Ruby files found in the current directory tree. If any errors are found, it'll report them. If your code is standard-compliant, it will get out of your way by quietly exiting code 0.

Fixing errors

A majority of Standard's rules can be safely fixed automatically.

# CLI
$ standardrb --fix

# Rake
$ rake standard:fix

Because we're confident Standard's fixes won't change the behavior of our code, we typically run with fix enabled all the time because it saves us from having to look at and think about problems the computer can solve for us.

Applying unsafe fixes

There are a number of other rules that can be automatically remedied, but not without the risk of changing your code's behavior. While we wouldn't recommend running it all the time, if the CLI suggests that additional errors can be fixed unsafely, here's how to do that:

# CLI
$ standardrb --fix-unsafely

# Rake
$ rake standard:fix_unsafely

So long as your code is checked into source control, there's no mortal harm in running with unsafe fixes enabled. If the changes look good to you and your tests pass, then it's probably no more error prone than manually editing every change by hand.

Integrating Standard into your workflow

Because code formatting is so integral to programming productivity and linter violations risk becoming bugs if released into production, tools like Standard Ruby are only as useful as their integration into code editors and continuous integration systems.

Editor support

We've added a number of editing guides for getting started:

  • Atom
  • emacs
  • Helix
  • neovim
  • Nova
  • RubyMine
  • vim
  • VS Code
  • Zed
  • Sublime Text

If you'd like to help by creating a guide, please draft one in an issue and we'll get it added!

Language Server Protocol support

If you don't see your preferred editor above, Standard Ruby also offers robust language server support, in two ways, both included with the standard gem:

  1. A Ruby LSP add-on, which (if the standard gem is in your Gemfile) will be loaded automatically
  2. A language server executable, which can be run from the command line with standardrb --lsp
Capability Ruby LSP Add-on Internal Server
Diagnostics (Linting) ✅ (Pull) ✅ (Push)
Formatting ✅ ✅
Code Actions ✅ ❌
Everything else ❌ ❌

Due to the advantages of Pull diagnostics and its inclusion of Code Actions ("Quick Fixes" in VS Code parlance), we recommend using Standard's Ruby LSP add-on where possible.

Regardless of which language server you use, many editors have added LSP support, with each bringing their own approach to configuration. Many LSP features should "just work", but when in doubt, please consult our editor guides above as well as your editor's own documentation on how to configure LSP formatters and linters.

CI support

Various continuous integration and quality-checking tools have been made to support Standard Ruby, as well.

  • GitHub Actions
  • Code Climate
  • Pronto
  • Danger

Of course, no special plugin is necessary to run Standard Ruby in a CI environment, as standardrb and rake standard work just fine on their own!

Other tools

These tool integrations are also available:

  • Guard
  • Spring

Ignoring errors

While Standard is very strict in how each formatting and linting rule is configured, it's mercifully flexible when you need to ignore a violation to focus on a higher priority (like, say, keeping the build running). There are a number of ways to ignore any errors, with the right answer depending on the situation.

Ignoring a line with a comment

Individual lines can be ignored with a comment directive at the end of the line. As an example, the line text = 'hi' violates two rules, Lint/UselessAssignment and Style/StringLiterals.

You could ignore one, both, or all errors with the following comments:

ruby
# Disable one error but keep Lint/UselessAssignment
text = 'hi' # standard:disable Style/StringLiterals

# Disable both errors explicitly
text = 'hi' # standard:disable Style/StringLiterals, Lint/UselessAssignment

# Disable all errors on the line with "all"
text = "hi" # standard:disable all

Ignoring multiple lines with comments

Similarly to individual lines, you can also disable multiple lines by wrapping them in comments that disable and re-enable them:

ruby
# standard:disable Style/StringLiterals, Lint/UselessAssignment
text = "hi"
puts 'bye'
# standard:enable Style/StringLiterals, Lint/UselessAssignment

Ignoring entire files and globs

You can ignore entire files and file patterns by adding them to ignore: in your project's .standard.yml file:

yaml
ignore:
  - 'some/file/in/particular.rb'
  - 'a/whole/directory/**/*'

Ignoring specific rules in files and globs

For a given file or glob, you can even ignore only specific rules by nesting an array of the rules you'd like to ignore:

yaml
ignore:
  - 'test/**/*':
    - Layout/AlignHash

Ignoring every violation and converting them into a todo list

If you're adopting Standard in a large codebase and you don't want to convert everything all at once, you can work incrementally by generating a "todo" file which will cause Standard to ignore every violation present in each file of the codebase.

This way, you can gradually work through the todo list, removing ignore directives and fixing any associated errors, while also being alerted to any regressions if they're introduced into the project.

Here are the commands you might run to get started:

# Start by clearing any auto-fixable errors:
$ standardrb --fix

# Generate a `.standard_todo.yml' to work from
$ standardrb --generate-todo

Co

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyformatterlinterrubocopruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库