Rails6にRubocopを導入する
2020/11/01
rubocop以外にrubocop-performanceとrubocop-railsも一緒に追加する。
手順
Gemfile
group :development, :test do
...省略...
+ gem 'rubocop', require: false
+ gem 'rubocop-performance', require: false
+ gem 'rubocop-rails', require: false
end$ bundle install.rubocop.yml
require:
- rubocop-rails
- rubocop-performance$ bundle exec rubocopおわり
個人的な追加設定
rails newしたばかりの状態だとこのくらいの設定になった。
NewCops: enable: 基本的に新しいCopは有効にしておきたいStyle/Documentation: これいる?
.rubocop.yml
require:
- rubocop-rails
- rubocop-performance
AllCops:
NewCops: enable
Style/Documentation:
Enabled: falseapiモードじゃなかったらnode_modules以下は無効にする
AllCops:
Exclude:
- node_modules/**/*