rails / rubocop-rails-omakase

Omakase Ruby styling for Rails
444 stars 15 forks source link

Adding rubocop-md to default RuboCop Rails linters #10

Closed viktorianer closed 10 months ago

viktorianer commented 10 months ago

I would love to use https://rubygems.org/gems/rubocop-md for MD files.

Run Rubocop against your Markdown files to make sure that code examples follow style guidelines.

Why I think it is a good addition? Because, every developer should write better README and docs.

In a lot of projects, you can find a lot of MD files in doc folder. Having linter for this, would be nice addition to support more and better docs.

koic commented 10 months ago

As indicated in reason #4, I think that it's better not to include rubocop-md in rubocop-rails-omakase to keep it lightweight.

IMHO, new runtime dependencies (rubocop-packaging and rubocop-md) might be unnecessary for most Rails applications. While rubocop-packaging could be useful in cases where Rails application will be packaged, its context is quite limited, I think. And, rubocop-md is a specialized cop gem and seems redundant as a minimal configuration for Rails applications. This is left as practice feedback in https://github.com/toshimaru/rubocop-rails_config/pull/166. By making these runtime dependencies optional for users to add, this rubocop-rails-omakase can be kept lightweight.

viktorianer commented 10 months ago

I think I get the point of removing it in https://github.com/toshimaru/rubocop-rails_config, where indeed rubocop-md will not be used as expected. That's why removing it there make sens to me too.

But in this gem we do not include Style/FrozenStringLiteralComment: and Layout/IndentationConsistency is Enabled: false. So, to make rubocop-md working in new Rails project, we need to add just this:

require:
  ...
  - rubocop-md
...
Markdown:
  # Whether to run RuboCop against non-valid snippets
  WarnInvalid: false
  # Whether to lint codeblocks without code attributes
  Autodetect: false

And we are good to go. rubocop-md will just do the job as expected.

Or, I do not understand your point :).

koic commented 10 months ago

Allow me to shift the perspective slightly. According to the contribution guide, it seems that new configuration proposals are not expected: https://github.com/rails/rubocop-rails-omakase#contributing

As of now (v1.0), there is no configuration for rubocop-md in rubocop-rails-omakase's rubocop.yml. Therefore, it's not necessary to add rubocop-md to the runtime dependencies, and it seems sufficient for users who want to use rubocop-md to simply add it to their Gemfile.

viktorianer commented 10 months ago

Ok, if it is not expected to extend it, I am fine :). Even, I think it is some kind of inconsistency, if you check Ruby code in all files except MD files, which are really common in Rails projects too.

obvious inconsistencies that remain in the spirit of the omakase collection