Skip to content

Commit cfba256

Browse files
authored
Merge pull request #272 from joyofrails/chore/erb-lint
Adds Rubocop checks to ERB lint
2 parents 71eaaac + 17bcd34 commit cfba256

File tree

24 files changed

+109
-96
lines changed

24 files changed

+109
-96
lines changed

.erb_lint.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
---
22
EnableDefaultLinters: true
3-
3+
glob: "**/*.{html}{+*,}.erb"
44
exclude:
5-
- '**/vendor/**/*'
6-
- '**/node_modules/**/*'
5+
- vendor/bundle/**/*
6+
- node_modules/**/*
7+
- tmp/**/*
8+
- log/**/*
79

810
linters:
9-
AllowedScriptType:
11+
ErbSafety:
12+
enabled: true
13+
PartialInstanceVariable:
14+
enabled: true
15+
16+
Rubocop:
1017
enabled: true
11-
allowed_types:
12-
- 'application/json'
13-
- 'application/ld+json'
14-
- 'module'
15-
- 'text/html'
16-
- 'text/javascript'
17-
- 'text/ruby'
18-
- 'text/template'
19-
allow_blank: false
20-
disallow_inline_scripts: false
18+
rubocop_config:
19+
require: standard
20+
inherit_gem:
21+
standard: config/base.yml
22+
Layout/InitialIndentation:
23+
Enabled: false
24+
Layout/TrailingEmptyLines:
25+
Enabled: false
26+
Lint/UselessAssignment:
27+
Enabled: false

app/content/layouts/article.html.erb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<% set_meta_tags(
2-
title: current_page.data.title!,
3-
description: current_page.data.description,
4-
keywords: %w[rails hotwire],
5-
og: {
6-
type: "article",
7-
url: current_page.url,
8-
image: current_page.data.meta_image && asset_url(current_page.data.meta_image)
9-
},
10-
twitter: {
11-
card: "summary"
12-
}
13-
) %>
2+
title: current_page.data.title!,
3+
description: current_page.data.description,
4+
keywords: %w[rails hotwire],
5+
og: {
6+
type: "article",
7+
url: current_page.url,
8+
image: current_page.data.meta_image && asset_url(current_page.data.meta_image)
9+
},
10+
twitter: {
11+
card: "summary"
12+
}
13+
) %>
1414
<%= render "application/skip_to_content" %>
1515
<%= render_layout "application" do %>
1616
<article itemscope itemtype="http://schema.org/Article">
1717
<%= render Pages::Header.new(
18-
title: current_page.data.title!,
19-
description: current_page.data.description,
20-
published_on: current_page.data.published&.to_date,
21-
updated_on: current_page.data.updated&.to_date
22-
) %>
18+
title: current_page.data.title!,
19+
description: current_page.data.description,
20+
published_on: current_page.data.published&.to_date,
21+
updated_on: current_page.data.updated&.to_date
22+
) %>
2323
<%- if current_page.data.toc -%>
2424
<aside>
2525
<h2 class="font-semibold mb-4 text-sm leading-6 uppercase tracking-widest">Table of Contents</h2>

app/content/pages/articles.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: Read the latest articles from Joy of Rails
55

66
<section style="min-height: 51vh">
77
<%= render Pages::Header.new(
8-
title: "Articles",
9-
description: "Read the latest articles from Joy of Rails"
10-
) %>
8+
title: "Articles",
9+
description: "Read the latest articles from Joy of Rails"
10+
) %>
1111
<div class="main-content container py-gap">
1212
<%= render Pages::List.new(SitepressArticle.published(params)) %>
1313
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
class Admin::HomeController < Admin::BaseController
22
def index
3+
@nav = {
4+
"Rails Admin" => "/admin/data",
5+
"Newsletters" => admin_newsletters_path,
6+
"Flipper" => "/admin/flipper",
7+
"Mission Control Jobs" => "/admin/jobs",
8+
"Litestream" => "/admin/litestream"
9+
}
310
end
411
end

app/views/admin/home/index.html.erb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
<%
2-
nav = {
3-
"Rails Admin" => "/admin/data",
4-
"Newsletters" => admin_newsletters_path,
5-
"Flipper" => "/admin/flipper",
6-
"Mission Control Jobs" => "/admin/jobs",
7-
"Litestream" => "/admin/litestream",
8-
}
9-
%>
101
<article>
112
<%= render Pages::Header.new(title: "Admin") %>
123
<div class="section-content container py-gap mb-3xl">
134
<ul>
14-
<% nav.each do |label, url| %>
5+
<% @nav.each do |label, url| %>
156
<li>
167
<p class="font-semibold leading-6">
178
<%= link_to url do %>

app/views/admin/newsletters/_form.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
<fieldset>
2525
<%= form.submit class: "button primary" %>
2626
<%= form.submit "Preview", class: "button secondary",
27-
formaction: (newsletter.persisted? ? edit_admin_newsletter_path(newsletter) : new_admin_newsletter_path),
28-
formmethod: "get",
29-
formnovalidate: true,
30-
data: { turbo_frame: dom_id(newsletter, :markdown) } %>
27+
formaction: (newsletter.persisted? ? edit_admin_newsletter_path(newsletter) : new_admin_newsletter_path),
28+
formmethod: "get",
29+
formnovalidate: true,
30+
data: {turbo_frame: dom_id(newsletter, :markdown)} %>
3131
</fieldset>
3232

3333
<%= turbo_frame_tag dom_id(newsletter, :markdown) do %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div id="<%= dom_id(newsletter, :markdown) %>" class="article-content joy-border-subtle p-4 mx--4">
2-
<%= basic_markdown (newsletter&.content || "").html_safe %>
2+
<%= basic_markdown(newsletter&.content || "") %>
33
</div>

app/views/admin_users/sessions/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<div>
1818
<div class="flex items-center justify-between">
19-
<%= form.label :password, class:"block text-sm font-medium leading-6" %>
19+
<%= form.label :password, class: "block text-sm font-medium leading-6" %>
2020
<!-- <div class="text-sm">
2121
<a href="#" class="font-semibold">Forgot password?</a>
2222
</div> -->
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% if custom_syntax_highlight? %>
2-
<%= stylesheet_link_tag find_syntax_highlight.asset_path, media: "all", data: { turbo_track: "reload", syntax_highlight: find_syntax_highlight.name } %>
2+
<%= stylesheet_link_tag find_syntax_highlight.asset_path, media: "all", data: {turbo_track: "reload", syntax_highlight: find_syntax_highlight.name} %>
33
<% else %>
4-
<%= stylesheet_link_tag Settings::SyntaxHighlight.default.asset_path, media: "all", data: { turbo_track: "reload", syntax_highlight: find_syntax_highlight.name } %>
4+
<%= stylesheet_link_tag Settings::SyntaxHighlight.default.asset_path, media: "all", data: {turbo_track: "reload", syntax_highlight: find_syntax_highlight.name} %>
55
<% end %>

app/views/emails/newsletter_mailer/newsletter.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= render Markdown::Base.new(@newsletter.content.html_safe) %>
1+
<%= render Markdown::Base.new(@newsletter.content) %>
22

33
--Ross
44

0 commit comments

Comments
 (0)