diff --git a/.erb_lint.yml b/.erb_lint.yml new file mode 100644 index 0000000..6e94774 --- /dev/null +++ b/.erb_lint.yml @@ -0,0 +1,10 @@ +glob: "**/*.{html,text,js}{+*,}.erb" +EnableDefaultLinters: true +linters: + ErbSafety: + enabled: true + Rubocop: + enabled: true + rubocop_config: + inherit_from: + - .rubocop.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abb548b..3a01b9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,9 @@ jobs: - name: Lint code for consistent style run: bin/rubocop -f github + - name: Lint ERB templates + run: bundle exec erb_lint . + test: runs-on: ubuntu-latest diff --git a/.rubocop.yml b/.rubocop.yml index f9d86d4..ba8f4de 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,6 @@ # Omakase Ruby styling for Rails inherit_gem: { rubocop-rails-omakase: rubocop.yml } -# Overwrite or add rules to create your own house style -# -# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` -# Layout/SpaceInsideArrayLiteralBrackets: -# Enabled: false +AllCops: + Exclude: + - 'app/views/**/*.{html,erb}' diff --git a/Gemfile b/Gemfile index ce68203..c7e62c2 100644 --- a/Gemfile +++ b/Gemfile @@ -62,6 +62,12 @@ end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" + + # linters + gem "erb_lint" + gem "rubocop", require: false + gem "rubocop-rails", require: false + gem "rubocop-rspec", require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index d751a19..0e95c94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,6 +80,13 @@ GEM bcrypt_pbkdf (1.1.1-arm64-darwin) bcrypt_pbkdf (1.1.1-x86_64-darwin) benchmark (0.4.0) + better_html (2.1.1) + actionview (>= 6.0) + activesupport (>= 6.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.18.4) @@ -113,6 +120,13 @@ GEM dotenv (3.1.7) drb (2.2.1) ed25519 (1.3.0) + erb_lint (0.7.0) + activesupport + better_html (>= 2.0.1) + parser (>= 2.7.1.4) + rainbow + rubocop (>= 1) + smart_properties erubi (1.13.1) et-orbi (1.2.11) tzinfo @@ -300,6 +314,8 @@ GEM rubocop-minitest rubocop-performance rubocop-rails + rubocop-rspec (3.3.0) + rubocop (~> 1.61) ruby-progressbar (1.13.0) rubyzip (2.3.2) securerandom (0.4.1) @@ -309,6 +325,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + smart_properties (1.17.0) solid_cable (3.0.5) actioncable (>= 7.2) activejob (>= 7.2) @@ -405,6 +422,7 @@ DEPENDENCIES capybara database_cleaner debug + erb_lint factory_bot_rails importmap-rails jbuilder @@ -413,7 +431,10 @@ DEPENDENCIES puma (>= 5.0) rails (~> 8.0.1) rspec-rails + rubocop + rubocop-rails rubocop-rails-omakase + rubocop-rspec selenium-webdriver solid_cable solid_cache