Skip to content

Commit 90b419b

Browse files
Include basic pre-commit hook set
- Good standard to apply for formatting - The white-space fixer - Also apply formatting to existing files - Json validity checker - Ensure line endings are `lf` for consistency - Prevent accidental upload of large files - Ensure files end with newline
1 parent b0da0b6 commit 90b419b

13 files changed

+41
-27
lines changed

.github/workflows/destroy-infrastructure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
CLUSTER_IDENTIFIER=$(grep -oP 'db_cluster\s*=\s*"\K[^"]+' env/${{ inputs.environment }}.tfvars)
5151
aws rds modify-db-cluster --db-cluster-identifier "$CLUSTER_IDENTIFIER" --no-deletion-protection
5252
echo "DB cluster delete protection removed: proceeding to delete stage"
53-
else
53+
else
5454
echo "DB cluster not in state: proceeding to delete stage"
5555
fi
5656

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ jobs:
106106
cache: yarn
107107
- run: yarn install --immutable --immutable-cache --check-cache
108108
- uses: pre-commit/action@v3.0.1
109+
with:
110+
extra_args: "--all-files --hook=manual"

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ repos:
44
hooks:
55
- id: terraform_fmt
66
files: \.(tf|tfvars|hcl)$
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: trailing-whitespace
11+
exclude: \.(enc|erb)$
12+
- id: end-of-file-fixer
13+
exclude: \.(enc|erb|csv|svg|rladr)$
14+
- id: check-json
15+
- id: check-added-large-files # Default is fail on files larger than 500kB
16+
- id: mixed-line-ending
17+
args: [--fix=lf] # Ensure all line endings are LF
18+
exclude: \.csv$
719
- repo: local
820
hooks:
921
- id: prettier

app/components/app_activity_log_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class AppActivityLogComponent < ViewComponent::Base
77
nhsuk-u-font-weight-normal">
88
<%= day.to_fs(:long) %>
99
</h2>
10-
10+
1111
<% events.each do |event| %>
1212
<%= render AppLogEventComponent.new(card: true, **event) %>
1313
<% end %>

app/components/app_compare_consent_form_and_patient_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AppCompareConsentFormAndPatientComponent < ViewComponent::Base
99
<%= govuk_summary_list(rows: consent_form_rows) %>
1010
<% end %>
1111
</div>
12-
12+
1313
<div class="nhsuk-grid-column-one-half nhsuk-card-group__item">
1414
<%= render AppCardComponent.new(colour: "blue") do |card| %>
1515
<% card.with_heading { "Child record" } %>

app/components/app_log_event_component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ class AppLogEventComponent < ViewComponent::Base
99
<h3 class="<% if card %>nhsuk-card__heading <% end %>nhsuk-heading-s">
1010
<%= invalidated ? tag.s(title) : title %>
1111
</h3>
12-
12+
1313
<% if body.present? %>
1414
<blockquote><p>
1515
<%= invalidated ? tag.s(body) : body %>
1616
</p></blockquote>
1717
<% end %>
18-
18+
1919
<p class="nhsuk-body-s nhsuk-u-margin-0 nhsuk-u-secondary-text-color">
2020
<% if programmes.any? %>
2121
<%= render AppProgrammeTagsComponent.new(programmes) %>
2222
&nbsp;
2323
<% end %>
2424
<%= invalidated ? tag.s(subtitle) : subtitle %>
2525
</p>
26-
26+
2727
<% if card %>
2828
</div></div>
2929
<% end %>

app/components/app_patient_card_component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ class AppPatientCardComponent < ViewComponent::Base
1010
text: "Record updated with child’s date of death"
1111
) %>
1212
<% end %>
13-
13+
1414
<% if patient.invalidated? %>
1515
<%= render AppStatusComponent.new(
1616
text: "Record flagged as invalid"
1717
) %>
1818
<% end %>
19-
19+
2020
<% if patient.restricted? %>
2121
<%= render AppStatusComponent.new(
2222
text: "Record flagged as sensitive"
@@ -30,7 +30,7 @@ class AppPatientCardComponent < ViewComponent::Base
3030
<h3 class="nhsuk-heading-s nhsuk-u-margin-bottom-2">
3131
<%= parent_relationship.label_with_parent %>
3232
</h3>
33-
33+
3434
<%= render AppParentSummaryComponent.new(parent_relationship:) %>
3535
<% end %>
3636
<% end %>

app/components/app_patient_session_search_result_card_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AppPatientSessionSearchResultCardComponent < ViewComponent::Base
1515
row.with_key { "Year group" }
1616
row.with_value { helpers.patient_year_group(patient) }
1717
end
18-
18+
1919
if action_required
2020
summary_list.with_row do |row|
2121
row.with_key { "Action required" }
@@ -30,7 +30,7 @@ class AppPatientSessionSearchResultCardComponent < ViewComponent::Base
3030
end
3131
end
3232
end %>
33-
33+
3434
<% if context == :register && can_register_attendance? %>
3535
<div class="app-button-group">
3636
<%= helpers.govuk_button_to "Attending", create_session_register_path(session, patient, "present", search_form: params[:search_form]&.permit!), class: "app-button--secondary app-button--small" %>

app/components/app_patient_session_table_component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AppPatientSessionTableComponent < ViewComponent::Base
1111
<% row.with_cell(text: "Programme") %>
1212
<% end %>
1313
<% end %>
14-
14+
1515
<% table.with_body do |body| %>
1616
<% patient_sessions.each do |patient_session| %>
1717
<% patient_session.programmes.each do |programme| %>
@@ -21,7 +21,7 @@ class AppPatientSessionTableComponent < ViewComponent::Base
2121
<%= link_to patient_session.session.location.name,
2222
session_patient_programme_path(patient_session.session, patient_session.patient, programme) %>
2323
<% end %>
24-
24+
2525
<% row.with_cell do %>
2626
<span class="nhsuk-table-responsive__heading">Session dates</span>
2727
<ul class="nhsuk-list app-list--spaced">
@@ -30,7 +30,7 @@ class AppPatientSessionTableComponent < ViewComponent::Base
3030
<% end %>
3131
</ul>
3232
<% end %>
33-
33+
3434
<% row.with_cell do %>
3535
<span class="nhsuk-table-responsive__heading">Programme</span>
3636
<%= render AppProgrammeTagsComponent.new([programme]) %>

app/components/app_search_component.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class AppSearchComponent < ViewComponent::Base
1111
label: { text: "Search", class: "nhsuk-u-visually-hidden" },
1212
autocomplete: "off",
1313
class: "app-search-input__input" %>
14-
14+
1515
<button class="nhsuk-button nhsuk-button--secondary app-button--icon app-search-input__submit" data-module="nhsuk-button" type="submit">
1616
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" focusable="false" role="img">
1717
<title>Search</title>
1818
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z" fill="currentColor"></path>
1919
</svg>
2020
</button>
2121
</div>
22-
22+
2323
<% if consent_statuses.any? %>
2424
<%= f.govuk_radio_buttons_fieldset :consent_status, legend: { text: "Consent status", size: "s" } do %>
2525
<%= f.govuk_radio_button :consent_status, "", label: { text: "Any" } %>
@@ -28,7 +28,7 @@ class AppSearchComponent < ViewComponent::Base
2828
<% end %>
2929
<% end %>
3030
<% end %>
31-
31+
3232
<% if triage_statuses.any? %>
3333
<%= f.govuk_radio_buttons_fieldset :triage_status, legend: { text: "Triage outcome", size: "s" } do %>
3434
<%= f.govuk_radio_button :triage_status, "", label: { text: "Any" } %>
@@ -37,7 +37,7 @@ class AppSearchComponent < ViewComponent::Base
3737
<% end %>
3838
<% end %>
3939
<% end %>
40-
40+
4141
<% if register_statuses.any? %>
4242
<%= f.govuk_radio_buttons_fieldset :register_status, legend: { text: "Registration status", size: "s" } do %>
4343
<%= f.govuk_radio_button :register_status, "", label: { text: "Any" } %>
@@ -46,7 +46,7 @@ class AppSearchComponent < ViewComponent::Base
4646
<% end %>
4747
<% end %>
4848
<% end %>
49-
49+
5050
<% if session_statuses.any? %>
5151
<%= f.govuk_radio_buttons_fieldset :session_status, legend: { text: "Vaccination status", size: "s" } do %>
5252
<%= f.govuk_radio_button :session_status, "", label: { text: "Any" } %>
@@ -55,7 +55,7 @@ class AppSearchComponent < ViewComponent::Base
5555
<% end %>
5656
<% end %>
5757
<% end %>
58-
58+
5959
<% if programme_statuses.any? %>
6060
<%= f.govuk_radio_buttons_fieldset :programme_status, legend: { text: "Programme outcome", size: "s" } do %>
6161
<%= f.govuk_radio_button :programme_status, "", label: { text: "Any" } %>

0 commit comments

Comments
 (0)