This linter plugin for SublimeLinter provides an interface to StandardRB. It will be used with files that have the ruby
, ruby on rails
, rspec
, betterruby
, better rspec
, ruby experimental
or cucumber steps
syntaxes.
You need to have SublimeLinter and StandardRB installed in order to use this plugin.
If you you already have those requirements met, great! 🎉. You can use Package Control to install the SublimeLinter-contrib-standardrb
plugin.
If you haven't installed SublimeLinter and StandardRB, see below:
Refer to the SublimeLinter Docs for installation instructions.
Before using this plugin, you must ensure that standard
is installed on your system. To install standard
, do the following:
-
Install Ruby.
-
Install
standard
by typing the following in a terminal:``` gem install standard ```
-
If you are using
rvm
orrbenv
, ensure that they are loaded in your shell’s correct startup file. See here for more information.
In order for standard
to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. The SublimeLinter docs cover troubleshooting PATH configuration.
To understand SublimeLinter settings in general, check out:
If you are using Bundler and would like to use the locked version of StandardRB, you will need to set use_bundle_exec
to true:
{
"settings": {
"SublimeLinter.linters.standardrb.use_bundle_exec": true
}
}
Assuming you also have the SublimeLinter-Rubocop plugin enabled...
It's likely that you'll want to use Standard as your linter for some projects and Rubocop directly for others. Since Standard is a wrapper on top of Rubocop and both linters will lint the same files, having both enabled can give you some conflicting results (such as allowing neither single nor double quoted string literals). There are a couple of ways to prevent conflicts between the two linters.
You can use "Disable Package" / "Enable Package" from the command palette to turn linter plugins on or off. You can also use your settings file to enable or disable linter plugins globally. Both of these are pretty terrible user experiences and you really should use one of the other options below.
One option for dealing with linter conflicts is to disable one linter in your global settings file and then override the setting on a per-project basis. For example, assuming you want to enable StandardRB globally and use Rubocop only on specific projects, you would first globally disable the rubocop linter in your Preferences.sublime-settings
file:
{
"SublimeLinter.linters.rubocop.disable": true
}
This will prevent SiblimeLinter from using the Rubocop linter while continuing to allow the SublimeRB linter.
Then, for any project you'd like to lint with Rubocop instead of StandardRB, you can then add the following to your *.sublime-project
settings:
{
"settings": {
"SublimeLinter.linters.rubocop.disable": false,
"SublimeLinter.linters.standardrb.disable": true
}
}
The above settings will disable the StandardRB linter and enable Rubocop instead.
This approach works well if you are a heavy user of .sublime-project
files. The drawback to this approach is that it may not select the linter you want if the project is opened without using the *.sublime-project
file (e.g. executing subl ~/path/to/ruby/project
from a terminal prompt).
(👆 - Hint: This is probably the one you want.)
A more intelligent (and opinionated) option is to use the prefer_standard
option. Enabling this option will cause the StanrdardRB linter plugin to selectively enable either the StandardRB or Rubocop linter based on the presence of a corresponding linter config file. The project directory (first folder in the project) and each of it's parent directories are searched first for a .standard.yml
file, and then for a .rubocop.yml
file. The corresponding linter will be activated for the first config file found. If no config file is found, StandardRB will be used.
To use the prefer_standard
option, you'll need to add the following to your global preferences:
{
"settings": {
"SublimeLinter.linters.rubocop.disable": null,
"SublimeLinter.linters.standardrb.disable": null,
"SublimeLinter.linters.standardrb.prefer_standard": true,
}
}
Note that both linters have their disable
setting set to null
, not false
. true
and false
are explicit decisions which prefer_standard
will gladly honor. null
means you're OK with making no decision and letting prefer_standard
decide for you.
If you run into problems, please open an Issue or a Pull Request.
This project follows Test Double's code of conduct for all community interactions, including (but not limited to) one-on-one communications, public posts/comments, code reviews, pull requests, and GitHub issues. If violations occur, Test Double will take any action they deem appropriate for the infraction, up to and including blocking a user from the organization's repositories.
This plugin is largely based on SublimeLinter-Rubocop