From 248be5fc8f6cd1f94983260a3b38c3c76d4a6429 Mon Sep 17 00:00:00 2001 From: Jess Sully <45972923+JM-Sully@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:10:47 +0000 Subject: [PATCH 1/5] Add linters --- Gemfile | 6 ++++++ Gemfile.lock | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) 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 From 2180542072e0104ef9ba833b8fc4087e8d91af36 Mon Sep 17 00:00:00 2001 From: Jess Sully <45972923+JM-Sully@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:11:10 +0000 Subject: [PATCH 2/5] Add erb-lint to the CI/CD pipeline --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) 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 From 239e28a7f48435c9042b00756e58e7870e14a60a Mon Sep 17 00:00:00 2001 From: Jess Sully <45972923+JM-Sully@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:21:20 +0000 Subject: [PATCH 3/5] add yml file for erb-lint --- .erb-lint.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .erb-lint.yml diff --git a/.erb-lint.yml b/.erb-lint.yml new file mode 100644 index 0000000..b735dba --- /dev/null +++ b/.erb-lint.yml @@ -0,0 +1,9 @@ +glob: "**/*.{html,text,js}{+*,}.erb" +linters: + ErbSafety: + enabled: false + Rubocop: + enabled: true + rubocop_config: + inherit_from: + - .rubocop.yml From cbb9c83c30e86960f5f56b042d8da39942f011ca Mon Sep 17 00:00:00 2001 From: Jess Sully <45972923+JM-Sully@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:22:41 +0000 Subject: [PATCH 4/5] fixup --- .erb-lint.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.erb-lint.yml b/.erb-lint.yml index b735dba..dcd1676 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -1,7 +1,8 @@ -glob: "**/*.{html,text,js}{+*,}.erb" +EnableDefaultLinters: true linters: ErbSafety: - enabled: false + enabled: true + better_html_config: .better-html.yml Rubocop: enabled: true rubocop_config: From 3fb8278f96ee7bdc7c5a91cedc3dc828609e3247 Mon Sep 17 00:00:00 2001 From: Jess Sully <45972923+JM-Sully@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:41:19 +0000 Subject: [PATCH 5/5] fixup --- .erb-lint.yml => .erb_lint.yml | 2 +- .rubocop.yml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) rename .erb-lint.yml => .erb_lint.yml (79%) diff --git a/.erb-lint.yml b/.erb_lint.yml similarity index 79% rename from .erb-lint.yml rename to .erb_lint.yml index dcd1676..6e94774 100644 --- a/.erb-lint.yml +++ b/.erb_lint.yml @@ -1,8 +1,8 @@ +glob: "**/*.{html,text,js}{+*,}.erb" EnableDefaultLinters: true linters: ErbSafety: enabled: true - better_html_config: .better-html.yml Rubocop: enabled: true rubocop_config: 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}'