-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added lints for ERB templates #609
Conversation
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.
Thanks for the cleanup! Just left a few potential suggestions.
bundler-cache: true | ||
|
||
- name: Lint templates for consistent style | ||
run: ./bin/erblint ./app/**/*.erb |
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.
Could we keep this all in a single lint
job with multiple steps to lint Ruby and ERB?
Also, is there a reason we're not calling ./bin/erblint --lint-all
?
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.
@zachgoll I merged two tasks into one. I prefer calling ./bin/erblint ./app/**/*.erb
because of explicitness, but --lint-all
also makes sense, updated.
@@ -43,6 +43,7 @@ group :development, :test do | |||
gem "dotenv-rails" | |||
gem "letter_opener" | |||
gem "i18n-tasks" | |||
gem "erb_lint" |
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.
What do you think of adding a .erb-lint.yml
file for a bit more explicitness and integrating with our Rubocop setup?
EnableDefaultLinters: true
linters:
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
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.
@zachgoll Yes, I forget about the config for the erblint
. At the same time, I am completely against enabling all Rubocop rules for erblint
. I tried doing this locally, and I got about 3500 errors with only 3000 auto-correctable. Besides this, some HTML tags started to look really strange after the automatic correction.
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.
I added .erb-lint.yml
, please check.
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.
Sounds good, and very understandable on the rubocop integration. I'm all for auto checks, but not if it's going to slow us down too much.
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.
Looks good! Thanks again for the cleanup 👍
@igor-alexandrov looks like the exclude:
- '**/vendor/**/*' ?? |
|
Very nice addition with the linters growing in the CI (in the future we could have i18n-tasks, eslint etc) I usually add to my project a small utility to run them all in a single command something like that in #!/usr/bin/env bash
# Exit when any command fails
set -e
# Check Ruby code formatting
echo "Checking Ruby code formatting..."
bundle exec rubocop -A
# Check erb file formatting
echo "Checking erb file formatting..."
bundle exec erblint --lint-all --autocorrect |
@adrienpoly I will open a new PR for this. Thank you for this suggestion. |
This PR adds lints to the ERB templates. Yes,
erblint
is not perfect, however currently it is the only solution that exists and works.I fixed existing errors and added
erblint
step to the CI.