Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds erb lint to project #4059

Merged
merged 8 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
glob: "**/*.{html,text,js}{+*,}.erb"
exclude:
- "**/vendor/**/*"
- "**/node_modules/**/*"
EnableDefaultLinters: true
linters:
AllowedScriptType:
enabled: true
allowed_types:
- "application/json"
- "text/javascript"
- "text/html"
- "module"
- "esms-options"
disallow_inline_scripts: false
15 changes: 8 additions & 7 deletions .github/workflows/ruby_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ on:
branches:
- main
paths-ignore:
- 'doc/**'
- '*.md'
- 'bin/*'
- "doc/**"
- "*.md"
- "bin/*"
pull_request:
branches:
- main
paths-ignore:
- 'doc/**'
- '*.md'
- 'bin/*'
- "doc/**"
- "*.md"
- "bin/*"

jobs:
ruby_lint:

runs-on: ubuntu-latest

steps:
Expand All @@ -31,3 +30,5 @@ jobs:

- name: lint
run: bundle exec rubocop
- name: lint erb files
run: bundle exec erblint --lint-all
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you are so inclined, you can open a draft PR as you continue to work on it.
1. Add a test for your change. If you are adding functionality or fixing a bug, you should add a test!

1. Run linters and fix any linting errors they brings up.
- `rubocop -a`
- `bin/lint`

1. Push to your branch/fork and submit a pull request. Include the issue number (ex. `Resolves #1`) in the PR description. This will ensure the issue gets closed automatically when the pull request gets merged.

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ group :development, :test do
gem "rubocop-rails", "~> 2.23.1"
# Default rules for Rubocop.
gem "standard", "~> 1.33"
# Erb linter.
gem "erb_lint"
end

group :development do
Expand Down
18 changes: 17 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ GEM
erubi (>= 1.0.0)
rack (>= 0.9.0)
rouge (>= 1.0.0)
better_html (2.0.2)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
Expand Down Expand Up @@ -183,6 +190,13 @@ GEM
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
erb_lint (0.5.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop
smart_properties
erubi (1.12.0)
et-orbi (1.2.7)
tzinfo
Expand Down Expand Up @@ -403,7 +417,7 @@ GEM
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.24.0)
parser (3.3.0.2)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pdf-core (0.9.0)
Expand Down Expand Up @@ -581,6 +595,7 @@ GEM
rack-protection (= 3.1.0)
tilt (~> 2.0)
slop (3.6.0)
smart_properties (1.17.0)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
Expand Down Expand Up @@ -676,6 +691,7 @@ DEPENDENCIES
discard (~> 1.3)
dotenv-rails
dry-struct
erb_lint
factory_bot_rails
faker
filterrific
Expand Down
4 changes: 2 additions & 2 deletions app/views/account_request_mailer/approval_request.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Here are their details:
* <%= ar.humanize %>: <%= val %>
<% end %>

Create This Organization: <%=new_admin_organization_url(token: @account_request.identity_token) %>
Reject This Organization: <%=for_rejection_admin_account_requests_url(token: @account_request.identity_token) %>
Create This Organization: <%= new_admin_organization_url(token: @account_request.identity_token) %>
Reject This Organization: <%= for_rejection_admin_account_requests_url(token: @account_request.identity_token) %>
17 changes: 8 additions & 9 deletions app/views/account_request_mailer/confirmation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@
<p>
Finally, we've made a series of getting started videos with detailed directions on setting up your essentials bank in Human Essentials, check them out:
<br>
<a href='https://youtu.be/w53iaJtlQUo'>Part 1</a><br/>
<a href='https://youtu.be/3-CF0wsG0h4'>Part 2</a><br/>
<a href='https://youtu.be/WkJahWsdZzc'>Part 3</a><br/>
<a href='https://youtu.be/STl0MfLQYbc'>Part 4</a><br/>
<a href='https://youtu.be/oREioR1Qg6c'>Part 5</a><br/>
<a href='https://youtu.be/feg59oW6V3M'>Part 6</a><br/>
<a href='https://youtu.be/wyD034nvqag'>Part 7</a><br/>
<a href='https://youtu.be/v3AyrL0pHw0'>Part 8</a><br/>
<a href='https://youtu.be/w53iaJtlQUo'>Part 1</a><br>
<a href='https://youtu.be/3-CF0wsG0h4'>Part 2</a><br>
<a href='https://youtu.be/WkJahWsdZzc'>Part 3</a><br>
<a href='https://youtu.be/STl0MfLQYbc'>Part 4</a><br>
<a href='https://youtu.be/oREioR1Qg6c'>Part 5</a><br>
<a href='https://youtu.be/feg59oW6V3M'>Part 6</a><br>
<a href='https://youtu.be/wyD034nvqag'>Part 7</a><br>
<a href='https://youtu.be/v3AyrL0pHw0'>Part 8</a><br>
Please let us know when you would like to begin using Human Essentials and we will set you up and send you a welcome email.
</p>

<p>Human Essential Team</p>

2 changes: 1 addition & 1 deletion app/views/account_request_mailer/rejection.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
</head>
<body>
<p>Greetings from the Human Essentials Team,</p>
Expand Down
1 change: 0 additions & 1 deletion app/views/account_requests/confirm.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
</div>
</div>
</div>

1 change: 0 additions & 1 deletion app/views/account_requests/invalid_token.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
</div>
</div>
</div>

4 changes: 2 additions & 2 deletions app/views/account_requests/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= radio_button_tag(:account, :partner, false, class: 'form-check-input account_type') %>
<%= label_tag(:account, "I am a Partner Agency to an Essentials Bank. I distribute the diapers/period supplies that I receive from essentials banks directly to the public.", class: 'form-check-label') %>
</div>

<% if @bank_selected %>
<script type="module">
$(document).ready(function() {
Expand Down Expand Up @@ -60,7 +60,7 @@
<%= simple_form_for(@account_request) do |f| %>
<%= f.error_notification %>
<%= render partial: "shared/flash" %>

<div class="form-inputs">
<div class="form-inputs">
<%= f.input :name, autofocus: true %>
Expand Down
1 change: 0 additions & 1 deletion app/views/account_requests/received.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
<p style="color: #ff0505;">Please check your spam filters for a email from <strong>no-reply@humanessentials.app</strong></p>
</div>
</div>

6 changes: 3 additions & 3 deletions app/views/adjustments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<div class="row">
<div class="form-group col-lg-4 col-md-4 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Storage Location", scope: :at_location, collection: @storage_locations, key: :id, value: :name, selected: @selected_location) %>

</div>
<div class="form-group col-lg-4 col-md-4 col-sm-6 col-xs-12">
<%= filter_select(scope: :by_user, collection: @users, key: :id, value: :name, selected: @selected_user) %>
Expand All @@ -53,7 +53,7 @@
adjustments_path(format: :csv, filters: filter_params.merge(date_range: date_range_params)),
text: "Export Adjustments"
) if @adjustments.any? %>

<%= new_button_to new_adjustment_path(organization_id: current_organization), {text: "New Adjustment"} %>
</span>
</div>
Expand Down Expand Up @@ -107,4 +107,4 @@
</div>
</div>
</div>
</section>
</section>
2 changes: 1 addition & 1 deletion app/views/adjustments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</tr>
</thead>
<tbody>
<% @adjustment.line_items.each do |line_item| %>
<% @adjustment.line_items.each do |line_item| %>
<tr class="<%= line_item.quantity > 0 ? "positive" : "negative" %>">
<td><%= (line_item.quantity > 0) ? "Added " : "Removed " %></td>
<td><%= line_item.item.name %></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<td><%= open_account_request.created_at&.strftime("%m/%d/%Y") %></td>
<td>
<%= open_account_request.organization_name %>
<br/><%= open_account_request.organization_website %>
<br><%= open_account_request.organization_website %>
</td>
<td><%= open_account_request.request_details %></td>
<td><%= open_account_request.status.titleize %></td>
<td>
<%= open_account_request.name %>
<br/><%= open_account_request.email %>
<br><%= open_account_request.email %>
</td>
<td><%= js_button(text: 'Reject',
icon: 'ban',
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/account_requests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
<tr>
<td>
<%= account_request.organization_name %>
<br/><%= account_request.organization_website %>
<br><%= account_request.organization_website %>
</td>
<td><%= account_request.request_details %></td>
<td><%= account_request.name %>
<br/><%= account_request.email %>
<br><%= account_request.email %>
</td>
<td><%= account_request.status.titleize %></td>
<td><%= account_request.confirmed_at&.strftime("%m/%d/%Y") || "N/A" %></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/barcode_items/_barcode_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% end %>
</div><!-- /.row -->
</div><!-- /.box-body -->
<input type="hidden" value="" id="trigger-field-id"/>
<input type="hidden" value="" id="trigger-field-id">
</div>
<div class="modal-footer justify-content-between">

Expand Down
1 change: 0 additions & 1 deletion app/views/admin/barcode_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
</div><!-- /.container-fluid -->
</section>


<section class="content">
<div class="container-fluid">
<div class="row">
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/barcode_items/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :title, "Admin - Inventory - Barcode Items - #{@barcode_item.item.name}" %>
<h1>
Barcode Information
<small>for <%= @barcode_item.item.name %></small>
<small>for <%= @barcode_item.item.name %></small>
</h1>
</div>
<div class="col-sm-6">
Expand All @@ -22,7 +22,6 @@
</div><!-- /.container-fluid -->
</section>


<section class="content">
<div class="container-fluid">
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/base_items/_dropdown.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
collection: @base_items,
label: "Base Item",
error: "Please choose what kind of basic item this is",
wrapper: :input_group %>
wrapper: :input_group %>
2 changes: 1 addition & 1 deletion app/views/admin/base_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
</div>
</div>
</div>
</section>
</section>
2 changes: 1 addition & 1 deletion app/views/admin/base_items/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
</div>
</div>
</div>
</section>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<td><%= link_to broadcast_announcement.link, broadcast_announcement.link %></td>
<td><%= broadcast_announcement.user&.name || "N/A" %></td>
<td><%= broadcast_announcement.expiry %>
<% if broadcast_announcement.expired? %>
<% if broadcast_announcement.expired? %>
<span class="badge badge-danger bg-danger">Expired</span>
<% end %>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/broadcast_announcements/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="col-sm-6">
<% content_for :title, "Send broadcast announcement" %>
<h1>
Broadcast Announcement to Banks
Broadcast Announcement to Banks
</h1>
</div>
<div class="col-sm-6">
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@
<ul class="users-list clearfix">
<% @recent_organizations.each do |org| %>
<li>
<%#= image_tag(org&.logo)
%>
<%#= image_tag(org&.logo) %>
<%= link_to org.name, admin_organization_path(org.id), class: "users-list-name" %>
<span class="users-list-date"><%= time_ago_in_words(org.created_at) %></span>
</li>
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/organizations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<%= f.rich_text_area :default_email_text %>
<% end %>


<%= f.input :logo, wrapper: :input_group do %>

<% if @organization.logo.attached? %>
Expand Down
9 changes: 0 additions & 9 deletions app/views/admin/partners/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
</div><!-- /.container-fluid -->
</section>






<section class="content">
<div class="container-fluid">
<div class="row">
Expand Down Expand Up @@ -60,7 +55,3 @@
</div>
</div>
</section>




3 changes: 1 addition & 2 deletions app/views/admin/users/_roles.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
class: 'select form-control',
data: { 'double-select-target': 'source',
'action': 'double-select#sourceChanged'
}
%>
} %>
</div>
</div>
<div class="form-group">
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/users/_user_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
<span class="input-group-text"><%= fa_icon "envelope" %></span>
<%= f.input_field :email, class: "form-control" %>
<% end %>

1 change: 0 additions & 1 deletion app/views/admin/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@
<% unless @user == current_user %>
<%= render partial: 'roles', object: @user, as: :user %>
<% end %>

2 changes: 0 additions & 2 deletions app/views/admin/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
</div><!-- /.container-fluid -->
</section>



<section class="content">
<div class="container-fluid">
<div class="row">
Expand Down
Loading
Loading