Skip to content

Commit

Permalink
Merge pull request #2274 from alphagov/erb-lint-update
Browse files Browse the repository at this point in the history
Erb lint update
  • Loading branch information
syed-ali-tw authored Aug 19, 2024
2 parents 681ba14 + 02ac290 commit 3610f6a
Show file tree
Hide file tree
Showing 93 changed files with 353 additions and 289 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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
name: Lint Ruby
uses: alphagov/govuk-infrastructure/.github/workflows/rubocop.yml@main

lint-erb:
name: Lint Ruby
uses: alphagov/govuk-infrastructure/.github/workflows/erblint.yml@main

test-javascript:
name: Test JavaScript
uses: alphagov/govuk-infrastructure/.github/workflows/jasmine.yml@main
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem "aws-sdk-s3", "~> 1"
gem "bootsnap", require: false
gem "bootstrap-kaminari-views"
gem "diffy"
gem "erb_lint"
gem "erubis"
gem "flipflop"
gem "gds-api-adapters"
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ GEM
aws-sigv4 (1.9.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.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)
bootsnap (1.18.4)
msgpack (~> 1.2)
Expand Down Expand Up @@ -143,6 +150,13 @@ GEM
diffy (3.4.2)
docile (1.4.0)
domain_name (0.6.20240107)
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)
erubis (2.7.0)
execjs (2.9.1)
Expand Down Expand Up @@ -748,6 +762,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 @@ -819,6 +834,7 @@ DEPENDENCIES
climate_control
database_cleaner-mongoid
diffy
erb_lint
erubis
factory_bot_rails
flipflop
Expand Down
6 changes: 3 additions & 3 deletions app/views/answers/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<h2 class="remove-top-margin add-bottom-margin h3">Edit Answer</h2>
</legend>

<%= render :partial => 'shared/common_edition_attributes', :locals => {:f => f} %>
<%= render :partial => "shared/common_edition_attributes", :locals => {:f => f} %>

<%= form_group(f, :body) do %>
<%= f.text_area :body, rows: 20, disabled: @resource.locked_for_edits?, class: "input-md-10 form-control", data: {
module: "paste-html-to-govspeak"
module: "paste-html-to-govspeak",
} %>
<% end %>
</fieldset>
</div>
</div>

<%= render partial: 'shared/workflow_buttons', locals: { f: f } %>
<%= render partial: "shared/workflow_buttons", locals: { f: f } %>
6 changes: 3 additions & 3 deletions app/views/artefacts/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<%= content_for :page_title, "New artefact" %>
<%= form_for(@artefact, html: { class: 'artefact', id: 'edit_artefact' }) do |f| %>
<%= form_for(@artefact, html: { class: "artefact", id: "edit_artefact" }) do |f| %>
<fieldset class="inputs">
<legend class="page-header">
<h1><%= yield :page_title %></h1>
</legend>

<%= render :partial => 'shared/legacy_error_summary', locals: { object: @artefact} %>
<%= render :partial => "shared/legacy_error_summary", locals: { object: @artefact} %>

<div class="row">
<div class="col-md-12">
Expand All @@ -24,7 +24,7 @@
<%= f.select :kind, formats.map { |s| [s.humanize, s]}, { include_blank: "Select a format" }, { class: "input-md-4 form-control" } %>
<% end %>

<%= f.hidden_field :owning_app, value: 'publisher' %>
<%= f.hidden_field :owning_app, value: "publisher" %>

<%= form_group(f, :language) do %>
<%= f.select :language, { "English" => "en", "Welsh" => "cy" }, {}, { class: "input-md-4 form-control" } %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/campaigns/_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<fieldset class="inputs">
<div class="row">
<div class="col-md-8">
<%= render :partial => 'shared/common_edition_attributes', :locals => {:f => f} %>
<%= render :partial => "shared/common_edition_attributes", :locals => {:f => f} %>
</div>
</div>

Expand Down Expand Up @@ -69,4 +69,4 @@
</div>
</fieldset>

<%= render partial: 'shared/workflow_buttons', locals: { f: f } %>
<%= render partial: "shared/workflow_buttons", locals: { f: f } %>
2 changes: 1 addition & 1 deletion app/views/campaigns/_image_upload.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% end %>
</p>
<% end %>
<p><%= label_tag do %>Remove image? <%= check_box_tag "edition[remove_#{format}_image]", "1", false, disabled: @resource.locked_for_edits?, class: 'js-no-ajax' %><% end %></p>
<p><%= label_tag do %>Remove image? <%= check_box_tag "edition[remove_#{format}_image]", "1", false, disabled: @resource.locked_for_edits?, class: "js-no-ajax" %><% end %></p>
<% end %>
<div class="form-group">
<span class="form-label">
Expand Down
34 changes: 17 additions & 17 deletions app/views/completed_transactions/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h2 class="remove-top-margin add-bottom-margin h3">Edit Completed transaction</h2>
</legend>

<%= render :partial => 'shared/common_edition_attributes', :locals => {:f => f} %>
<%= render :partial => "shared/common_edition_attributes", :locals => {:f => f} %>

<%= form_group(f, :body, help: "The body text is overwritten by the service feedback survey") do %>
<%= f.text_area :body, rows: 20, disabled: "disabled", class: "input-md-10 form-control" %>
Expand All @@ -27,25 +27,25 @@
</p>

<div class="form-group">
<%= f.radio_button :promotion_choice, 'none',
{ checked: (f.object.promotion_choice == "none"), disabled: @resource.locked_for_edits?, class: 'promotion-choice-none' } %>
<%= f.label :promotion_choice, "Don't promote anything on this page", value: 'none' %>
<%= f.radio_button :promotion_choice, "none",
{ checked: (f.object.promotion_choice == "none"), disabled: @resource.locked_for_edits?, class: "promotion-choice-none" } %>
<%= f.label :promotion_choice, "Don't promote anything on this page", value: "none" %>
<br />
<%= f.radio_button :promotion_choice, 'organ_donor',
{ checked: (f.object.promotion_choice == "organ_donor"), disabled: @resource.locked_for_edits?, class: 'promotion-choice-organ-donor' } %>
<%= f.label :promotion_choice, "Promote organ donation", value: 'organ_donor' %>
<%= f.radio_button :promotion_choice, "organ_donor",
{ checked: (f.object.promotion_choice == "organ_donor"), disabled: @resource.locked_for_edits?, class: "promotion-choice-organ-donor" } %>
<%= f.label :promotion_choice, "Promote organ donation", value: "organ_donor" %>
<br />
<%= f.radio_button :promotion_choice, 'bring_id_to_vote',
{ checked: (f.object.promotion_choice == "bring_id_to_vote"), disabled: @resource.locked_for_edits?, class: 'promotion-choice-bring-id-to-vote' } %>
<%= f.label :promotion_choice, "Promote bring photo ID to vote", value: 'bring_id_to_vote' %>
<%= f.radio_button :promotion_choice, "bring_id_to_vote",
{ checked: (f.object.promotion_choice == "bring_id_to_vote"), disabled: @resource.locked_for_edits?, class: "promotion-choice-bring-id-to-vote" } %>
<%= f.label :promotion_choice, "Promote bring photo ID to vote", value: "bring_id_to_vote" %>
<br />
<%= f.radio_button :promotion_choice, 'mot_reminder',
{ checked: (f.object.promotion_choice == "mot_reminder"), disabled: @resource.locked_for_edits?, class: 'promotion-choice-mot-reminder' } %>
<%= f.label :promotion_choice, "Promote MOT reminders", value: 'mot_reminder' %>
<%= f.radio_button :promotion_choice, "mot_reminder",
{ checked: (f.object.promotion_choice == "mot_reminder"), disabled: @resource.locked_for_edits?, class: "promotion-choice-mot-reminder" } %>
<%= f.label :promotion_choice, "Promote MOT reminders", value: "mot_reminder" %>
<br />
<%= f.radio_button :promotion_choice, 'electric_vehicle',
{ checked: (f.object.promotion_choice == "electric_vehicle"), disabled: @resource.locked_for_edits?, class: 'promotion-choice-electric-vehicle' } %>
<%= f.label :promotion_choice, "Promote electric vehicles", value: 'electric_vehicle' %>
<%= f.radio_button :promotion_choice, "electric_vehicle",
{ checked: (f.object.promotion_choice == "electric_vehicle"), disabled: @resource.locked_for_edits?, class: "promotion-choice-electric-vehicle" } %>
<%= f.label :promotion_choice, "Promote electric vehicles", value: "electric_vehicle" %>

<%= form_group(f, :promotion_choice_url, attributes: { id: "promotion-choice-url" }) do %>
<%= f.text_field :promotion_choice_url, disabled: @resource.locked_for_edits?, class: "input-md-8 form-control" %>
Expand All @@ -63,4 +63,4 @@
</div>
</div>

<%= render partial: 'shared/workflow_buttons', locals: { f: f } %>
<%= render partial: "shared/workflow_buttons", locals: { f: f } %>
4 changes: 2 additions & 2 deletions app/views/downtimes/_datetime_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="govuk-grid-column-one-half">
<%= render "govuk_publishing_components/components/fieldset", {
legend_text: date_legend_text,
heading_size: "m"
heading_size: "m",
} do %>
<%= render "govuk_publishing_components/components/date_input", {
hint: "For example, 01 08 2022",
Expand All @@ -38,7 +38,7 @@
<div class="govuk-grid-column-one-half">
<%= render "govuk_publishing_components/components/fieldset", {
legend_text: time_legend_text,
heading_size: "m"
heading_size: "m",
} do %>
<%= render "time_input", {
hint: "For example, 9:30 or 19:30",
Expand Down
2 changes: 1 addition & 1 deletion app/views/downtimes/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
margin_bottom: 8,
label: {
heading_size: "m",
text: "Message"
text: "Message",
},
hint: "Message is auto-generated once a schedule has been made.",
id: "downtime_message",
Expand Down
11 changes: 5 additions & 6 deletions app/views/downtimes/_time_input.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<%

id ||= "input-#{SecureRandom.hex(4)}"
name ||= nil
items ||= [
{ :name => "hour", :width => 2 },
{ :name => "minute", :width => 2 }
{ :name => "minute", :width => 2 },
]

legend_text ||= nil
Expand Down Expand Up @@ -37,7 +36,7 @@
<%= render "govuk_publishing_components/components/hint", {
id: hint_id,
text: hint,
margin_bottom: 2
margin_bottom: 2,
} %>
<% end %>

Expand All @@ -54,7 +53,7 @@
<%= tag.div class: "govuk-date-input__item" do %>
<%= render "govuk_publishing_components/components/input", {
label: {
text: item[:label] || item[:name].capitalize
text: item[:label] || item[:name].capitalize,
},
grouped: true,
has_error: has_error,
Expand All @@ -63,7 +62,7 @@
width: item[:width],
id: item[:id],
type: "number",
data: item[:data]
data: item[:data],
} %>
<% end %>
<% end %>
Expand All @@ -75,7 +74,7 @@
describedby: aria_described_by,
legend_text: legend_text,
text: fieldset_content,
role: "group"
role: "group",
} %>
<% else %>
<%= fieldset_content %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/downtimes/delete.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<% content_for :page_title, 'Remove downtime message' %>
<% content_for :title, 'Remove downtime message' %>
<% content_for :page_title, "Remove downtime message" %>
<% content_for :title, "Remove downtime message" %>

<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/lead_paragraph", {
text: "Are you sure you want to remove the scheduled downtime message for \"#{@downtime.artefact.name}\"?",
margin_bottom: 8
margin_bottom: 8,
} %>

<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module': 'downtime-message' } do |f| %>
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: "form well remove-top-margin", 'data-module': "downtime-message" } do |f| %>
<div class="govuk-button-group">
<%= render "govuk_publishing_components/components/button", {
text: "Remove",
destructive: true
destructive: true,
} %>
<%= link_to "Cancel", downtimes_path, class: "govuk-link govuk-link--no-visited-state" %>
</div>
Expand Down
14 changes: 7 additions & 7 deletions app/views/downtimes/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<% content_for :page_title, 'Edit downtime message' %>
<% content_for :title, 'Edit downtime message' %>
<% content_for :page_title, "Edit downtime message" %>
<% content_for :title, "Edit downtime message" %>
<% content_for :title_context, @downtime.artefact.name %>
<% unless @downtime.errors.empty? %>
<% content_for :error_summary, render("shared/error_summary", { object: @downtime }) %>
<% content_for :error_summary, render("shared/error_summary", { object: @downtime }) %>
<% end %>

<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/lead_paragraph", {
text: "Downtime message appear on the service's start page one day before the downtime is due to occur.",
margin_bottom: 6
margin_bottom: 6,
} %>

<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module': 'downtime-message' } do |f| %>
<%= render 'form', f: f %>
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: "form well remove-top-margin", 'data-module': "downtime-message" } do |f| %>
<%= render "form", f: f %>
<div class="govuk-button-group">
<%= render "govuk_publishing_components/components/button", {
text: "Save",
value: "save",
name: "save"
name: "save",
} %>

<%= link_to "Cancel", downtimes_path, class: "govuk-link govuk-link--no-visited-state" %>
Expand Down
12 changes: 6 additions & 6 deletions app/views/downtimes/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<% content_for :page_title, 'Downtime messages' %>
<% content_for :page_title, "Downtime messages" %>
<% content_for :title, "Downtime messages" %>

<div class="govuk-grid-column-full">

<%= render "govuk_publishing_components/components/lead_paragraph", {
text: "Show a message on a published transaction start page for a specific time.",
margin_bottom: 6
margin_bottom: 6,
} %>

<%= render "govuk_publishing_components/components/table", {
Expand All @@ -19,12 +19,12 @@
text: "Service Status",
},
{
text: tag.span("Action", class: "govuk-visually-hidden")
text: tag.span("Action", class: "govuk-visually-hidden"),
},
{
text: tag.span("Link to view live on GOV.UK", class: "govuk-visually-hidden")
}
text: tag.span("Link to view live on GOV.UK", class: "govuk-visually-hidden"),
},
],
rows: transactions_table_entries(@transactions.to_a)
rows: transactions_table_entries(@transactions.to_a),
} %>
</div>
Loading

0 comments on commit 3610f6a

Please sign in to comment.