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 578
  • Win 108
  • Mac 368
  • Linux 102
Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7
Windows 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 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 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 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 0 0 1 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