-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explore plugin configs #498
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
"config change": rubocop.yml | ||
"config change": rubocop*.yml | ||
"hq": rubocop.yml | ||
"graphql": rubocop.graphql.yml | ||
"minitest": rubocop.minitest.yml | ||
"performance": rubocop.performance.yml | ||
"rails": rubocop.rails.yml | ||
"rake": rubocop.rake.yml | ||
"rspec": rubocop.rspec.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,12 @@ gem "diffy" | |
gem "minitest" | ||
gem "pry-byebug" | ||
gem "rake" | ||
|
||
group :plugins do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could use this to skip installing these in one of our CI runs, so we can ensure everything still works for consumers only using RuboCop. |
||
gem "rubocop-graphql" | ||
gem "rubocop-minitest" | ||
gem "rubocop-performance" | ||
gem "rubocop-rails" | ||
gem "rubocop-rake" | ||
gem "rubocop-rspec" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% | ||
# Identify installed RuboCop plugins to configure | ||
plugin_configs = { | ||
"rubocop" => "rubocop.yml", | ||
"rubocop-graphql" => "rubocop.graphql.yml", | ||
"rubocop-minitest" => "rubocop.minitest.yml", | ||
"rubocop-performance" => "rubocop.performance.yml", | ||
"rubocop-rails" => "rubocop.rails.yml", | ||
"rubocop-rake" => "rubocop.graphql.yml", | ||
"rubocop-rspec" => "rubocop.rspec.yml", | ||
}.select { |plugin_name, _| Gem.loaded_specs.include?(plugin_name) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tricky part is that this checks if the gem is installed in the computer, not in the bundler right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The way it would work is that if a consumer has # .rubocop.yml
inherit_gem:
rubocop-shopify: rubocop.infer.yml then when they run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if the app doesn't have rubocop-minitest for example but the person has it installed globally we should not use it. We should be using what is on the Gemfile.lock of the application, not what is on the gem paths. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good point. I should have said "in their Gemfile" not "installed". I just confirmed % cat Gemfile
source 'https://rubygems.org'
% bundle exec ruby -e 'puts Gem.loaded_specs.key?("rubocop-minitest")'
false
% gem install rubocop-minitest
Successfully installed rubocop-minitest-0.32.2
Parsing documentation for rubocop-minitest-0.32.2
Installing ri documentation for rubocop-minitest-0.32.2
Done installing documentation for rubocop-minitest after 0 seconds
1 gem installed
% bundle exec ruby -e 'puts Gem.loaded_specs.key?("rubocop-minitest")'
false
% bundle add rubocop-minitest > /dev/null && cat Gemfile
source 'https://rubygems.org'
gem "rubocop-minitest", "~> 0.32.2"
% bundle exec ruby -e 'puts Gem.loaded_specs.key?("rubocop-minitest")'
true
% bundle exec ruby -e 'puts Gem.loaded_specs.key?("rubocop")'
true |
||
%> | ||
|
||
require: <%= plugin_configs.keys.to_json %> | ||
|
||
inherit_from: <%= plugin_configs.values.to_json %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Minitest: | ||
Enabled: true | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't bothered filling out most of these files, but presumably they'd look like: PluginName:
Enabled: true
# ...config for cops where we want to diverge from the default... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could alternatively call these after the gem names (e.g. I just went with what we use in Core. 🤷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to not use defaults. Let's always curate cops. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't sure of a good label name, so I went with the "cop" analogy of headquarters. 🤷