[TxMt] Re: Ruby: Support various linters / formatters?

Jacob Carlborg doob at me.com
Thu May 23 09:26:26 UTC 2019



> On 23 May 2019, at 11:15, Stefan Daschek <stefan at daschek.net> wrote:
> 
> The Ruby bundle currently supports reformatting a file with RuboCop (“Reformat Document”), and checking the document’s syntax using `ruby -wc.
> 
> So far there is no support for automatically checking (or maybe even reformatting) a file everytime it is saved. 
> 
> For RuboCop, there are (at least) four stand-alone RuboCop bundles providing additional features:
> 
>  * https://github.com/fazibear/Rubocop.tmbundle <https://github.com/fazibear/Rubocop.tmbundle>
>  * https://github.com/mrdougal/textmate2-rubocop <https://github.com/mrdougal/textmate2-rubocop>
>  * https://github.com/goyox86/rubocop-tmbundle <https://github.com/goyox86/rubocop-tmbundle>
>  * https://github.com/noniq/RuboCop.tmbundle <https://github.com/noniq/RuboCop.tmbundle> (Disclaimer: This bundle was written by me).
> 
> Recently various alternatives to RuboCop emerged, especially:
> 
>  * https://github.com/testdouble/standard <https://github.com/testdouble/standard> (uses RuboCop internally, “No configuration“)
>  * https://github.com/samphippen/rubyfmt <https://github.com/samphippen/rubyfmt> (autoformatting only, optimized for speed)
> 
> Both tools are still pre-1.0, but actively developed.
> 
> I’d like to add support for both standardrb and rubyfmt to TextMate. However, I’m not yet sure about the following questions:
> 
>  * Should the Ruby bundle be extended to support these? Or should one or more stand-alone bundles be created?
>  * What would be the best way to tell TextMate which (if any) linting / formatting tool it should use for a given ruby file or project?

What’s the goal here? Are standard <https://github.com/testdouble/standard> or rubyfmt <https://github.com/samphippen/rubyfmt> better than RoboCop? Because it’s pretty straightforward to make an existing command executed on save.

Assuming we want to add support for these tools I would say they should live in the Ruby bundle. But at the same time if you want to support both it gets slightly more complicated.

Usually when a TextMate bundle executes a command it’s expected to be available in the PATH or it can also check for a specific environment variable, like TM_RUBY.

Since these new tools seem to not be ready for day to day use, I recommend they be turned off by default. This can be configured via another environment variable that can be placed inside .tm_properties to enable.

-- 
/Jacob Carlborg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20190523/a73628ea/attachment.html>


More information about the textmate mailing list