Skip to content

Commit 54f6d98

Browse files
committed
Fix herb lint offenses and make lint:check fail on errors
`parallel_lint` in `lint.rake` was mutating a hash inside `Parallel.map` (which forks processes), so results were invisible to the parent. The hash stayed empty and `{}.compact.all?` always returned true, making lint pass even with errors. Fix by using `Parallel.map` return values directly. Also resolve all 38 herb lint offenses: - Add `nonce: true` to `javascript_include_tag` calls - Split ERB string interpolations into separate `<%= %>` tags - Replace `link_to "#"` with `<button>` element - Add `alt` attribute to `image_tag` - Exclude `public/**/*` from herb linting (static HTML) - Configure per-file rule exclusions for false positives
1 parent 8c545b3 commit 54f6d98

22 files changed

Lines changed: 47 additions & 51 deletions

File tree

.herb.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,23 @@ linter:
3131
# # Additional patterns beyond the defaults for linting
3232
# include:
3333
# - '**/*.xml.erb'
34-
#
35-
# # Patterns to exclude from linting
36-
# exclude:
37-
# - 'app/views/admin/**/*'
34+
35+
# Patterns to exclude from linting
36+
exclude:
37+
- 'public/**/*'
3838

3939
rules:
4040
erb-no-extra-newline:
4141
enabled: true
42-
#
43-
# # Rules can have 'include', 'only', and 'exclude' patterns
44-
# some-rule:
45-
# # Additional patterns to check (additive, ignored when 'only' is present)
46-
# include:
47-
# - 'app/components/**/*'
48-
# # Don't apply this rule to files matching these patterns
49-
# exclude:
50-
# - 'app/views/admin/**/*'
51-
#
52-
# another-rule:
53-
# # Only apply this rule to files matching these patterns (overrides all 'include')
54-
# only:
55-
# - 'app/views/**/*'
56-
# # Exclude still applies even with 'only'
57-
# exclude:
58-
# - 'app/views/admin/**/*'
42+
html-no-unknown-tag:
43+
exclude:
44+
- 'app/views/members/shop/products/_tag.html.erb'
45+
erb-no-unused-expressions:
46+
exclude:
47+
- 'app/views/members/shop/orders/_order.html.erb'
48+
html-require-script-nonce:
49+
exclude:
50+
- 'app/views/shared/_theme_script.html.erb'
5951

6052
formatter:
6153
enabled: true

app/views/active_admin/_html_head.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<%= render "shared/theme_script" %>
99

1010
<%= javascript_importmap_tags "admin" %>
11-
<%= javascript_include_tag "activestorage" %>
11+
<%= javascript_include_tag "activestorage", nonce: true %>
1212

1313
<meta name="turbo-refresh-method" content="morph">
1414
<meta name="turbo-refresh-scroll" content="preserve">

app/views/active_admin/resource/_invoice_preview.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
</div>
55

66
<% unless invoice.processing? %>
7-
<%= image_tag invoice.pdf_file.preview(resize_to_limit: [ 2000, 2000 ]), class: "absolute top-0 z-20" %>
7+
<%= image_tag invoice.pdf_file.preview(resize_to_limit: [ 2000, 2000 ]), alt: "", class: "absolute top-0 z-20" %>
88
<% end %>
99
</div>

app/views/active_storage/blobs/_blob.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="attachment <%= blob.representable? ? "attachment--preview" : "attachment--file" %> <%= "attachment--#{blob.filename.extension}" %>">
1+
<div class="attachment <%= blob.representable? ? "attachment--preview" : "attachment--file" %>">
22
<% limit = local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]
33
# Convert to JPEG and apply quality compression for smaller file sizes.
44
# This is appropriate for newsletters/Trix content where transparency isn't needed.

app/views/demo/registrations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= javascript_include_tag "hashcash", defer: true, data: { turbo_track: "reload" } %>
1+
<%= javascript_include_tag "hashcash", defer: true, nonce: true, data: { turbo_track: "reload" } %>
22

33
<h1 class="mb-4 text-center text-2xl font-semibold md:text-3xl">
44
CSA Admin — <%= set_page_title t("demo.registrations.new.title") %>

app/views/layouts/members/_footer.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<div class="mx-auto mt-12 mb-4 text-gray-300 dark:text-gray-600 <%= "md:mx-0.5" if current_member %>">
7373
<%= link_to csa_admin_website_url, class: "flex items-center text-sm" do %>
7474
<%= icon "logo", class: "size-4 me-2 md:ms-0.5 md:me-3 fill-current", variant: "solid" %>
75-
<%= "CSA Admin" %>
75+
CSA Admin
7676
<% end %>
7777
</div>
7878
</footer>

app/views/members/absences/_absence.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"
66
>
77
<span class="flex min-w-fit flex-row items-center">
8-
<%= "#{l(absence.started_on)}#{l(absence.ended_on)}" %>
9-
<%= " (#{t('.deliveries_count', count: absence.baskets.size)})" %>
8+
<%= l(absence.started_on) %><%= l(absence.ended_on) %>
9+
(<%= t(".deliveries_count", count: absence.baskets.size) %>)
1010
</span>
1111

1212
<% if absence.note? %>

app/views/members/baskets/_basket.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<%= Absence.model_name.human %>
3030

3131
<% unless basket.absence_id? %>
32-
<%= " *" %>
32+
*
3333
<% end %>
3434
</span>
3535
<% end %>

app/views/members/bidding_round/pledges/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
data-hover-id-value="<%= dom_id(membership) %>"
1717
>
1818
<div class="text-center text-xl whitespace-nowrap">
19-
<%= "#{Membership.model_name.human} #{membership.fiscal_year}" %>
19+
<%= Membership.model_name.human %> <%= membership.fiscal_year %>
2020
</div>
2121

2222
<ul class="mt-4 w-full space-y-1">

app/views/members/billing/_membership.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
data-hover-id-value="<%= dom_id(membership) %>"
1010
>
1111
<div class="text-center text-xl whitespace-nowrap">
12-
<%= "#{Membership.model_name.human} #{membership.fiscal_year}" %>
12+
<%= Membership.model_name.human %> <%= membership.fiscal_year %>
1313
</div>
1414

1515
<ul class="mt-4 w-full space-y-1">

0 commit comments

Comments
 (0)