ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sublime​Linter-contrib-standardrb

by testdouble ST3

SublimeLinter 3 plugin for Ruby, using Standard, a wrapper for Rubocop.

Details

Installs

  • Total 529
  • Win 100
  • Mac 345
  • Linux 84
Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10
Windows 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Mac 0 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 1 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 2 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

SublimeLinter-contrib-standardrb

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.

Installation

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:

Install SublimeLinter

Refer to the SublimeLinter Docs for installation instructions.

Install StandardRB

Before using this plugin, you must ensure that standard is installed on your system. To install standard, do the following:

  1. Install Ruby.

  2. Install standard by typing the following in a terminal:

    gem install standard
    
  3. If you are using rvm or rbenv, ensure that they are loaded in your shell’s correct startup file. See here for more information.

PATH Configuration

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.

Settings

To understand SublimeLinter settings in general, check out:

Bundler

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
    }
}

Playing Nice With SublimeLinter-Rubocop

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.

Option 1: Manually Toggle Between 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.

Option 2: Using .sublime-project Files

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).

Option 3: Using The prefer_standard setting to check for config files

(👆 - 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.

Help Us Improve

If you run into problems, please open an Issue or a Pull Request.

Code of Conduct

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