Skip to content

Commit

Permalink
Merge pull request #1782 from alphagov/erb-lint-update
Browse files Browse the repository at this point in the history
Erb lint update
  • Loading branch information
ellohez authored Sep 4, 2024
2 parents f843d55 + ff5caa6 commit 7fa691e
Show file tree
Hide file tree
Showing 56 changed files with 316 additions and 243 deletions.
40 changes: 40 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
EnableDefaultLinters: false
glob: "**/*.{html,text,js}{+*,}.erb"
exclude:
- '**/vendor/**/*'
- '**/node_modules/**/*'
linters:
SpaceAroundErbTag:
enabled: true
Rubocop:
enabled: true
exclude:
- "**/vendor/**/*"
- "**/vendor/**/.*"
- "bin/**"
- "db/**/*"
- "spec/**/*"
- "config/**/*"
- "node_modules/**/*"
rubocop_config:
inherit_from:
- .rubocop.yml
AllCops:
DisabledByDefault: true
Layout/InitialIndentation:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: false
Layout/TrailingWhitespace:
Enabled: false
Naming/FileName:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Layout/LineLength:
Enabled: false
Lint/UselessAssignment:
Enabled: false
Layout/FirstHashElementIndentation:
Enabled: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gem "rails", "7.1.3.4"
gem "bootsnap", require: false
gem "bootstrap-kaminari-views"
gem "dartsass-rails"
gem "erb_lint", require: false
gem "govuk_app_config"
gem "hashdiff"
gem "jquery-ui-rails"
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ GEM
erubi (>= 1.0.0)
rack (>= 0.9.0)
rouge (>= 1.0.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)
Expand Down Expand Up @@ -125,6 +132,13 @@ GEM
docile (1.4.0)
domain_name (0.6.20240107)
drb (2.2.1)
erb_lint (0.6.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop (>= 1)
smart_properties
erubi (1.13.0)
execjs (2.9.1)
factory_bot (6.4.6)
Expand Down Expand Up @@ -692,6 +706,7 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
Expand Down Expand Up @@ -748,6 +763,7 @@ DEPENDENCIES
bootsnap
bootstrap-kaminari-views
dartsass-rails
erb_lint
factory_bot_rails
fakefs
gds-api-adapters
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_aggregated_tag_mappings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% aggregated_tagging.links.each do |tag_link| %>
<%= link_to tag_link.link_title, taxon_path(tag_link.link_content_id) %> (<%= tag_link.link_type %>)
<br />
<% end%>
<% end %>

<% if aggregated_tagging.errored? %>
<hr />
Expand Down
6 changes: 3 additions & 3 deletions app/views/application/_tag_update_preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
locals: {
completed_tag_mappings: completed_tag_mappings,
total_tag_mappings: total_tag_mappings,
progress_path: progress_path
progress_path: progress_path,
} %>
<% end %>
</div>
Expand All @@ -21,11 +21,11 @@
<th></th>
</tr>

<%= render partial: 'shared/table_filter' %>
<%= render partial: "shared/table_filter" %>
</thead>

<tbody>
<%= render partial: 'aggregated_tag_mappings',
<%= render partial: "aggregated_tag_mappings",
locals: { aggregated_tag_mappings: aggregated_tag_mappings } %>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions app/views/application/_tag_update_progress_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="js-tag-update-progress" data-progress-path="<%= progress_path %>">

<div class="progress">
<div class="progress-bar <%= 'progress-bar-striped active' unless percentage_complete == 100 %>"
<div class="progress-bar <%= "progress-bar-striped active" unless percentage_complete == 100 %>"
role="progressbar"
aria-valuenow="<%= completed_tag_mappings %>"
aria-valuemin="0"
Expand All @@ -14,7 +14,7 @@

<div class="progress-counter">
<p>
<%= I18n.t('views.tag_update_progress_bar', completed: completed_tag_mappings, total: total_tag_mappings)%>
<%= I18n.t("views.tag_update_progress_bar", completed: completed_tag_mappings, total: total_tag_mappings) %>
</p>
</div>

Expand Down
14 changes: 7 additions & 7 deletions app/views/bulk_tags/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= display_header title: t('bulk_tagging.title'), breadcrumbs: [t('navigation.bulk_tag')] do %>
<%= link_to t('navigation.tag_importer'), tagging_spreadsheets_path, class: 'btn btn-default' %>
<%= link_to t('navigation.tag_migration'), tag_migrations_path, class: 'btn btn-default' %>
<%= display_header title: t("bulk_tagging.title"), breadcrumbs: [t("navigation.bulk_tag")] do %>
<%= link_to t("navigation.tag_importer"), tagging_spreadsheets_path, class: "btn btn-default" %>
<%= link_to t("navigation.tag_migration"), tag_migrations_path, class: "btn btn-default" %>
<% end %>

<div class="lead">
Expand All @@ -11,17 +11,17 @@
<%= simple_form_for :bulk_tag, url: search_results_for_bulk_tag_path, method: :get do |f| %>
<div class="form-group">
<%= f.input :query, label: false,
input_html: { class: 'form-control', value: query }
input_html: { class: "form-control", value: query }
%>

<%= f.submit t('bulk_tag.search_button'), class: "btn btn-md btn-success" %>
<%= f.submit t("bulk_tag.search_button"), class: "btn btn-md btn-success" %>
</div>
<% end %>

<% if search_results.results.any? %>
<%= render 'search_results', results: search_results.results %>
<%= render "search_results", results: search_results.results %>
<% elsif query.present? %>
<p class="no-content no-content-bordered">No search results for '<%= query %>'</p>
<% end %>

<%= paginate search_results, theme: 'twitter-bootstrap-3' %>
<%= paginate search_results, theme: "twitter-bootstrap-3" %>
28 changes: 14 additions & 14 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
<%= javascript_include_tag "govuk_publishing_components/load-analytics" %>

<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<% end %>

<% content_for :navbar_items do %>
<% if user_can_administer_taxonomy? %>
<li class='<%= active_navigation_item == 'taggings' ? 'active' : nil %>'>
<%= link_to t('navigation.tagging_content'), lookup_taggings_path %>
<li class='<%= active_navigation_item == "taggings" ? "active" : nil %>'>
<%= link_to t("navigation.tagging_content"), lookup_taggings_path %>
</li>
<% end %>

<% if user_can_administer_taxonomy? %>
<li class='<%= active_navigation_item.in?(%w[bulk_tags tag_migrations tagging_spreadsheets]) ? 'active' : nil %>'>
<%= link_to t('navigation.bulk_tag'), new_bulk_tag_path %>
<li class='<%= active_navigation_item.in?(%w[bulk_tags tag_migrations tagging_spreadsheets]) ? "active" : nil %>'>
<%= link_to t("navigation.bulk_tag"), new_bulk_tag_path %>
</li>
<% end %>

<% if user_can_administer_taxonomy? %>
<li class='<%= active_navigation_item.in?(%w[taxons taxon_migrations branches]) ? 'active' : nil %>'>
<%= link_to t('navigation.taxons'), taxons_path %>
<li class='<%= active_navigation_item.in?(%w[taxons taxon_migrations branches]) ? "active" : nil %>'>
<%= link_to t("navigation.taxons"), taxons_path %>
</li>
<% end %>

<% if user_can_administer_taxonomy? %>
<li class='<%= active_navigation_item.in?(%w[tagging_history]) ? 'active' : nil %>'>
<%= link_to t('navigation.tagging_history'), tagging_history_index_path %>
<li class='<%= active_navigation_item.in?(%w[tagging_history]) ? "active" : nil %>'>
<%= link_to t("navigation.tagging_history"), tagging_history_index_path %>
</li>
<% end %>

<% if user_can_administer_taxonomy? %>
<li class='<%= active_navigation_item.in?(%w[health_warnings]) ? 'active' : nil %>'>
<%= link_to t('navigation.taxonomy_health'), taxonomy_health_warnings_path %>
<li class='<%= active_navigation_item.in?(%w[health_warnings]) ? "active" : nil %>'>
<%= link_to t("navigation.taxonomy_health"), taxonomy_health_warnings_path %>
</li>
<% end %>

<% if user_can_access_tagathon_tools? %>
<li class='<%= active_navigation_item.in?(%w[projects project_content_items]) ? 'active' : nil %>'>
<%= link_to t('navigation.projects'), projects_path %>
<li class='<%= active_navigation_item.in?(%w[projects project_content_items]) ? "active" : nil %>'>
<%= link_to t("navigation.projects"), projects_path %>
</li>
<% end %>
<% end %>

<%= render template: 'layouts/govuk_admin_template' %>
<%= render template: "layouts/govuk_admin_template" %>
12 changes: 6 additions & 6 deletions app/views/project_content_items/_flags.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Flag '<%= content_item.title %>' for review</h4>
</div>
<%= form_for content_item, url: update_flags_project_content_item_path(project, content_item), method: :post, remote: true, html: { data: { module: 'radio-toggle' } } do |f| %>
<%= form_for content_item, url: update_flags_project_content_item_path(project, content_item), method: :post, remote: true, html: { data: { module: "radio-toggle" } } do |f| %>

<div class="modal-body flag-for-review">
<div class='radio'>
<label>
<%= f.radio_button :flag, "needs_help", required: true, data: { target: 'need-help-comment' } %>
<%= f.radio_button :flag, "needs_help", required: true, data: { target: "need-help-comment" } %>
I need help tagging this
</label>
</div>

<div id='need-help-comment' class='form-group add-top-margin add-left-border'>
<%= f.label :need_help_comment, "Comment (optional)" %>
<%= f.text_field :need_help_comment, class: 'form-control input-md-4' %>
<%= f.text_field :need_help_comment, class: "form-control input-md-4" %>
</div>

<div class='radio'>
<label>
<%= f.radio_button :flag, "missing_topic", data: { target: 'suggested-tags' } %>
<%= f.radio_button :flag, "missing_topic", data: { target: "suggested-tags" } %>
There's no relevant topic for this
</label>
</div>

<div id='suggested-tags' class='form-group add-top-margin add-left-border'>
<%= f.label :suggested_tags, "Suggest a new topic (optional)" %>
<%= f.text_field :suggested_tags, class: 'form-control input-md-4' %>
<%= f.text_field :suggested_tags, class: "form-control input-md-4" %>
</div>
</div>

<div class='modal-footer'>
<%= f.submit "Continue", class: 'btn btn-success add-right-margin' %>
<%= f.submit "Continue", class: "btn btn-success add-right-margin" %>
<button type="button" class="btn btn-link" data-dismiss="modal">Cancel</button>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/project_content_items/flags.js.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$('#flags-modal')
.html("<%= escape_javascript(render partial: 'flags', locals: local_assigns) %>")
.html("<%= escape_javascript(render partial: "flags", locals: local_assigns) %>")
.promise()
.done(function () {
var radioToggle = new GOVUKAdmin.Modules.RadioToggle;
Expand Down
10 changes: 5 additions & 5 deletions app/views/projects/_bulk_tagging.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<li class='active'><a href='#'>Edit selected</a></li>
</ul>

<%= simple_form_for :bulk_tagging, url: project_bulk_update_path(project), remote: true, html: { class: 'js-bulk-tagger-form' } do |f| %>
<%= simple_form_for :bulk_tagging, url: project_bulk_update_path(project), remote: true, html: { class: "js-bulk-tagger-form" } do |f| %>
<div><span class='js-selected-count'>None</span> selected</div>

<%= f.input :taxons,
placeholder: 'Tags',
placeholder: "Tags",
label: false,
input_html: { class: [:select2, :bulk_tagger, :js_bulk_tagger_input], autocomplete: 'off' }
input_html: { class: [:select2, :bulk_tagger, :js_bulk_tagger_input], autocomplete: "off" }
%>

<div class='bulk-selectors'>
<%= f.input_field :content_items,
collection: content_items,
as: :check_boxes,
include_hidden: false,
class: 'content-selector js-content-selector'
class: "content-selector js-content-selector"
%>
</div>

<%= f.submit 'Apply' %>
<%= f.submit "Apply" %>
<% end %>
</div>
18 changes: 9 additions & 9 deletions app/views/projects/_content_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<div class='content-item'>
<%= simple_form_for content_item, url: project_content_item_path(content_item.project, content_item), remote: true, html: { data: { ref: content_item.id }, class: 'js-content-item-form content-item-form' } do |f| %>
<%= simple_form_for content_item, url: project_content_item_path(content_item.project, content_item), remote: true, html: { data: { ref: content_item.id }, class: "js-content-item-form content-item-form" } do |f| %>
<%= token_tag %>

<% if content_item.needs_help? %>
<%= render partial: "danger_label_with_text", locals: {
label_text: I18n.t('views.projects.flags.help-needed'),
label_text: I18n.t("views.projects.flags.help-needed"),
additional_text_label: "Comment",
additional_text: content_item.need_help_comment,
} %>
<% elsif content_item.missing_topic? %>
<%= render partial: "danger_label_with_text", locals: {
label_text: I18n.t('views.projects.flags.missing-topic'),
label_text: I18n.t("views.projects.flags.missing-topic"),
additional_text_label: "Suggested topic",
additional_text: content_item.suggested_tags,
} %>
Expand All @@ -19,7 +19,7 @@
<% end %>

<h4>
<%= link_to content_item.title, content_item.url, data: {proxy_iframe: 'enabled', modal_url: content_item.proxied_url, toggle: 'modal', target: '#iframe_modal_id'} %>
<%= link_to content_item.title, content_item.url, data: {proxy_iframe: "enabled", modal_url: content_item.proxied_url, toggle: "modal", target: "#iframe_modal_id"} %>
</h4>

<p><%= content_item.description %></p>
Expand All @@ -28,10 +28,10 @@
label: false,
input_html: {
class: [:select2, :tagging_project, :js_bulk_tagger_input],
autocomplete: 'off',
autocomplete: "off",
data: { taxons: content_item.taxons },
value: '',
disabled: 'disabled'
value: "",
disabled: "disabled",
} %>
<% end %>

Expand All @@ -40,9 +40,9 @@
&nbsp;
</p>
<div class='actions actions-inline'>
<%= button_to 'Done', mark_done_project_content_item_path(content_item.project, content_item), class: 'btn btn-primary', form_class: 'js-mark-as-done', remote: true %>
<%= button_to "Done", mark_done_project_content_item_path(content_item.project, content_item), class: "btn btn-primary", form_class: "js-mark-as-done", remote: true %>
<% unless content_item.flag? %>
<%= link_to I18n.t('views.projects.flag_for_review'), flags_project_content_item_path(content_item.project, content_item), class: 'btn btn-link', remote: true, data: { toggle: "modal", target: '#flags-modal' } %>
<%= link_to I18n.t("views.projects.flag_for_review"), flags_project_content_item_path(content_item.project, content_item), class: "btn btn-link", remote: true, data: { toggle: "modal", target: "#flags-modal" } %>
<% end %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/confirm_delete.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= button_to "Confirm delete",
project_path(project),
method: :delete,
class: 'btn btn-danger add-right-margin' %>
class: "btn btn-danger add-right-margin" %>

<%= link_to "Cancel", :back, class: "cancel-link" %>
</div>
Loading

0 comments on commit 7fa691e

Please sign in to comment.