Skip to content

Commit

Permalink
Chore: Add ERB Linter
Browse files Browse the repository at this point in the history
Because:
* To ensure consistent style with Erb files.

This commit:
* Adds the erb linter gem and config.
* Fixes linting issues on static pages.
  • Loading branch information
KevinMulhern committed Jan 24, 2022
1 parent 71805ac commit c5d40a6
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .better-html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
allow_single_quoted_attributes: false
allow_unquoted_attributes: false
82 changes: 82 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
EnableDefaultLinters: true
linters:
ErbSafety:
enabled: true
better_html_config: .better-html.yml
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
---
exclude:
- '*vendor/*'
- '*app/views/svg/*'
linters:
AllowedScriptType:
enabled: true
ClosingErbTagIndent:
enabled: true
DeprecatedClasses: # See https://github.com/Shopify/erb-lint#deprecatedclasses
enabled: true
ErbSafety: # Need to fix the remaining issues before this can be enabled
enabled: false
better_html_config: .better-html.yml
ExtraNewline:
enabled: true
FinalNewline:
enabled: true
HardCodedString:
enabled: false
NoJavascriptTagHelper:
enabled: true
ParserErrors:
enabled: true
RightTrim: # Disable closing tag trim
enabled: false
RequireInputAutocomplete:
enabled: false
RubocopText:
enabled: true
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
Layout/InitialIndentation:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: false
Layout/TrailingWhitespace:
Enabled: false
Naming/FileName:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Layout/LineLength: # This should be enabled eventually
Enabled: false
Lint/UselessAssignment:
Enabled: false
Rails/OutputSafety:
Enabled: false
Rails/Presence:
Enabled: false
Layout/LeadingEmptyLines:
Enabled: false
Style/RedundantCondition:
Enabled: false
Layout/HashAlignment:
Enabled: false
Rails/LinkToBlank:
Enabled: false

SelfClosingTag:
enabled: false
SpaceAroundErbTag:
enabled: true
SpaceInHtmlTag:
enabled: true
SpaceIndentation:
enabled: true
TrailingWhitespace:
enabled: true
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ group :development, :test, :docker do
gem 'climate_control'
gem 'cuprite'
gem 'dotenv-rails'
gem 'erb_lint', require: false
gem 'factory_bot'
gem 'factory_bot_rails', '~> 6'
gem 'pry', '~> 0.14.1'
Expand Down
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ GEM
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
better_html (1.0.16)
actionview (>= 4.0)
activesupport (>= 4.0)
ast (~> 2.0)
erubi (~> 1.4)
html_tokenizer (~> 0.0.6)
parser (>= 2.4)
smart_properties
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
Expand Down Expand Up @@ -165,6 +173,14 @@ GEM
railties (>= 3.2)
dry-initializer (3.1.0)
enumerable-statistics (2.0.1)
erb_lint (0.1.1)
activesupport
better_html (~> 1.0.7)
html_tokenizer
parser (>= 2.7.1.4)
rainbow
rubocop
smart_properties
erubi (1.10.0)
execjs (2.7.0)
factory_bot (6.2.0)
Expand Down Expand Up @@ -233,6 +249,7 @@ GEM
hashie (3.6.0)
heapy (0.2.0)
thor
html_tokenizer (0.0.7)
htmlentities (4.3.4)
http (5.0.4)
addressable (~> 2.8)
Expand Down Expand Up @@ -508,6 +525,7 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
smart_properties (1.17.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -580,6 +598,7 @@ DEPENDENCIES
discordrb-webhooks
dotenv-rails
dry-initializer (~> 3.1.0)
erb_lint
factory_bot
factory_bot_rails (~> 6)
friendly_id (~> 5.4)
Expand Down
3 changes: 1 addition & 2 deletions app/views/static_pages/about.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
<%= render 'shared/bottom_cta',
button: contribute_button,
heading: 'Help the Odin Project stay current and meaningful to all future students, please contribute!',
sub_heading: ''
%>
sub_heading: '' %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/static_pages/before_asking.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<% f.close %>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/static_pages/contributing/_hall_of_fame.erb
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
heading: 'Have a question?',
sub_heading: 'Chat with our friendly Odin community in our Discord chatrooms!'
%>
</div
</div>
5 changes: 2 additions & 3 deletions app/views/static_pages/faq.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<div class="row">
<div class="col-md-10 offset-md-1">
<h1 class="text-center page-heading-title mb-16">Frequently Asked Questions</h1>
<%= render 'static_pages/faq/faq_accordion'%>
<%= render 'static_pages/faq/faq_accordion' %>
</div>
</div> <!-- /.row -->

<%= render 'shared/bottom_cta',
button: chat_button,
heading: 'Have a question?',
sub_heading: 'Chat with our friendly Odin community in our Discord server!'
%>
sub_heading: 'Chat with our friendly Odin community in our Discord server!' %>
</div> <!-- /.container -->
</div> <!-- /.StaticPagesController -->
4 changes: 2 additions & 2 deletions app/views/static_pages/home/_how_it_works.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<% how_it_works_tiles.each do |tile| %>
<div class="tile">
<%= image_tag tile[:image], class: 'how-it-works-image inline', alt: 'how-it-works illustration' %>
<h4 class='font-bold text-xl mt-8 mb-4'><%= tile[:subtitle]%></h4>
<h4 class='font-bold text-xl mt-8 mb-4'><%= tile[:subtitle] %></h4>
<div class="description">
<p><%= tile[:description]%></p>
<p><%= tile[:description] %></p>
</div>
</div>
<% end %>
Expand Down
7 changes: 3 additions & 4 deletions app/views/static_pages/home/_success_stories.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div class="photo"> <%= image_tag "success_stories/#{story.avatar_path_name}", alt: "#{story.student_name}'s avatar" %> </div>

<div class="success-content">
<div class="details">
<div class="details">
<p><%= link_to story.student_name, story.social_media_link, class: 'accent' %></p>
</div>
</div>
<p><%= story.story_content.truncate_words(30) %></p>
</div>
</div>
Expand All @@ -25,7 +25,6 @@
<%= render 'shared/bottom_cta',
button: sign_in_or_view_curriculum_button,
heading: 'Start learning for free now!',
sub_heading: ''
%>
sub_heading: '' %>

</div> <!-- /.success-stories -->
5 changes: 2 additions & 3 deletions app/views/static_pages/success_stories.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<%= render 'shared/bottom_cta',
button: sign_in_or_view_curriculum_button,
heading: 'Start learning for free now!',
sub_heading: ''
%>
sub_heading: '' %>
</div>
</div>
</div
</div>

0 comments on commit c5d40a6

Please sign in to comment.