From bb8dde3b3e5f799c7b115e241dade0127078fcda Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 25 Oct 2023 12:24:49 +0200 Subject: [PATCH] Add ERB lint checks using erb-formatter --- .circleci/config.yml | 10 +++++++++- .format-erb-ignore | 6 ++++++ Gemfile | 1 + .../solidus_admin/ui/table/component.html.erb | 2 +- .../app/views/spree/admin/images/_image_row.html.erb | 6 +----- .../order_mailer/inventory_cancellation_email.html.erb | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .format-erb-ignore diff --git a/.circleci/config.yml b/.circleci/config.yml index 8aa7c7ccc9..d21be2dc60 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -234,9 +234,17 @@ jobs: - checkout - run: 'bundle install' - run: - name: Check with rubocop + name: Check Ruby command: | bundle exec rubocop --parallel --format junit --out "$PWD/test-results/rubocop-results.xml" --format progress + - run: + name: Check ERB + command: | + # enable recursive globbing with "**" + shopt -s globstar + + # we're only interested in errors + bundle exec erb-format **/*.html.erb > /dev/null - run: name: Check JavaScript command: | diff --git a/.format-erb-ignore b/.format-erb-ignore new file mode 100644 index 0000000000..699c0c0594 --- /dev/null +++ b/.format-erb-ignore @@ -0,0 +1,6 @@ +sandbox/** +tmp/** +**/generators/** + +# this file is using tail `if` checks which are not supported by erb-formatter +backend/app/views/spree/admin/shared/_product_tabs.html.erb diff --git a/Gemfile b/Gemfile index 4ea27540d5..cc686abe52 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,7 @@ group :admin do end group :utils do + gem 'erb-formatter', require: false gem 'pry' gem 'launchy', require: false gem 'rubocop', '~> 1', require: false diff --git a/admin/app/components/solidus_admin/ui/table/component.html.erb b/admin/app/components/solidus_admin/ui/table/component.html.erb index 736c2ae1ec..241ce89aa0 100644 --- a/admin/app/components/solidus_admin/ui/table/component.html.erb +++ b/admin/app/components/solidus_admin/ui/table/component.html.erb @@ -103,7 +103,7 @@ content_tag(:span, "0", "data-#{stimulus_id}-target": "selectedRowsCount"), " #{t('.rows_selected')}.", ])), colspan: @columns.count - 1) %> - + <% end %> diff --git a/backend/app/views/spree/admin/images/_image_row.html.erb b/backend/app/views/spree/admin/images/_image_row.html.erb index 2b92012fc1..bb7b2d5809 100644 --- a/backend/app/views/spree/admin/images/_image_row.html.erb +++ b/backend/app/views/spree/admin/images/_image_row.html.erb @@ -13,11 +13,7 @@ "spree/admin/shared/modal", target: "modal-image-#{image.id}", title: image.alt, - content: %{ -
- #{image_tag(image.url(:large))} -
- }.html_safe + content: tag.div(image_tag(image.url(:large)), class: 'align-center') ) %> diff --git a/core/app/views/spree/order_mailer/inventory_cancellation_email.html.erb b/core/app/views/spree/order_mailer/inventory_cancellation_email.html.erb index ea3acaa31c..2404d12f76 100644 --- a/core/app/views/spree/order_mailer/inventory_cancellation_email.html.erb +++ b/core/app/views/spree/order_mailer/inventory_cancellation_email.html.erb @@ -19,7 +19,7 @@ <% end %> -

+